Releases: realm/SwiftLint
0.58.2: New Yearβs Fresh Fold
Breaking
- None.
Experimental
- None.
Enhancements
- None.
Bug Fixes
- Fix version being reported by the binary consumed from the Docker image.
SimplyDanny
#5966
Using Bazel
With bzlmod:
// Pending BCR update
bazel_dep(name = "swiftlint", version = "0.58.2", repo_name = "SwiftLint")
Without bzlmod, put this in your WORKSPACE
:
WORKSPACE
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "build_bazel_rules_apple",
sha256 = "9e26307516c4d5f2ad4aee90ac01eb8cd31f9b8d6ea93619fc64b3cbc81b0944",
url = "https://github.com/bazelbuild/rules_apple/releases/download/2.2.0/rules_apple.2.2.0.tar.gz",
)
load(
"@build_bazel_rules_apple//apple:repositories.bzl",
"apple_rules_dependencies",
)
apple_rules_dependencies()
load(
"@build_bazel_rules_swift//swift:repositories.bzl",
"swift_rules_dependencies",
)
swift_rules_dependencies()
load(
"@build_bazel_rules_swift//swift:extras.bzl",
"swift_rules_extra_dependencies",
)
swift_rules_extra_dependencies()
http_archive(
name = "SwiftLint",
sha256 = "3377c9115221a14a52fa7533c065e48d7de729114cc534c10dcf61036dc59807",
url = "https://github.com/realm/SwiftLint/releases/download/0.58.2/bazel.tar.gz",
)
load("@SwiftLint//bazel:repos.bzl", "swiftlint_repos")
swiftlint_repos()
load("@SwiftLint//bazel:deps.bzl", "swiftlint_deps")
swiftlint_deps()
Then you can run SwiftLint in the current directory with this command:
bazel run @SwiftLint//:swiftlint -- --help
0.58.1: New Yearβs Fresh Fold
Breaking
-
If you are referring to the
swiftlint
binary from an Artifact Bundle consumed via Swift Package Manager
in an Xcode Run Script Build Phase, make sure to update the path from"$SWIFT_PACKAGE_DIR"/swiftlintplugins/SwiftLintBinary/SwiftLintBinary.artifactbundle/swiftlint-*/bin/swiftlint
to
"$SWIFT_PACKAGE_DIR"/swiftlintplugins/SwiftLintBinary/SwiftLintBinary.artifactbundle/swiftlint-*-macos/bin/swiftlint
in order to make Xcode use the binary built for macOS.
SimplyDanny
#5954 -
Revert changes to improve performance when exclude patterns resolve to a large set of files. While resolving files
indeed got much faster in certain setups, it leads to missed exclusions for nested configurations and when the linted
folder is not the current folder.
SimplyDanny
#5953
Experimental
- None.
Enhancements
- None.
Bug Fixes
-
Fix
redundant_sendable
correction by removing a remaining trailing comma as well whenSendable
was last.
SimplyDanny
#5952 -
Remove lints for
redundant_sendable
on protocols, whereSendable
is not redundant.
riley-williams
#5958 -
Add
ib_segue_action
to default configuration oftype_contents_order
rule on the same level asib_action
to define and document a standard position.
SimplyDanny
#5524
Using Bazel
With bzlmod:
// Pending BCR update
bazel_dep(name = "swiftlint", version = "0.58.1", repo_name = "SwiftLint")
Without bzlmod, put this in your WORKSPACE
:
WORKSPACE
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "build_bazel_rules_apple",
sha256 = "9e26307516c4d5f2ad4aee90ac01eb8cd31f9b8d6ea93619fc64b3cbc81b0944",
url = "https://github.com/bazelbuild/rules_apple/releases/download/2.2.0/rules_apple.2.2.0.tar.gz",
)
load(
"@build_bazel_rules_apple//apple:repositories.bzl",
"apple_rules_dependencies",
)
apple_rules_dependencies()
load(
"@build_bazel_rules_swift//swift:repositories.bzl",
"swift_rules_dependencies",
)
swift_rules_dependencies()
load(
"@build_bazel_rules_swift//swift:extras.bzl",
"swift_rules_extra_dependencies",
)
swift_rules_extra_dependencies()
http_archive(
name = "SwiftLint",
sha256 = "94b2c63592859e0fc60f53ff4002b9ceb87fb712106ce250548261860d8a9575",
url = "https://github.com/realm/SwiftLint/releases/download/0.58.1/bazel.tar.gz",
)
load("@SwiftLint//bazel:repos.bzl", "swiftlint_repos")
swiftlint_repos()
load("@SwiftLint//bazel:deps.bzl", "swiftlint_deps")
swiftlint_deps()
Then you can run SwiftLint in the current directory with this command:
bazel run @SwiftLint//:swiftlint -- --help
0.58.0: New Yearβs Fresh Fold
Breaking
-
The command plugin now requires write permissions so that it works with the
--fix
option without an error.
SimplyDanny -
The artifact bundle name has changed.
SwiftLintBinary-macos.artifactbundle.zip
is now called
SwiftLintBinary.artifactbundle.zip
. It now includes an AMD64 Linux binary.
Bradley Mackey
#5514 -
The
inert_defer
andunused_capture_list
rules have completely been removed after being deprecated for 2 years.
SimplyDanny -
SwiftLint now requires a Swift 5.10 or higher compiler to build. The Swift Package Manager plugins continue to work with Swift 5.9.
SimplyDanny -
The
private_unit_test
rule's deprecatedregex
configuration option has been removed after 2 years.
Martin Redington
#5912
Experimental
- None.
Enhancements
-
Add Xcode command plugin allowing to run SwiftLint from within Xcode.
SimplyDanny -
Add new
async_without_await
opt-in rule that checks if anasync
declaration contains at least oneawait
.
Jan Kolarik
#5082 -
Support replacing identity expressions with
\.self
inprefer_key_path
rule from Swift 6 on.
SimplyDanny -
Support linting only provided file paths with command plugins.
DanSkeel -
Add new category for
@IBSegueAction
totype_contents_order
rule.
dk-talks
SimplyDanny -
Add option to disable
redundant_discardable_let
rule in SwiftUI view bodies.
SimplyDanny
#3855 -
Add new
redundant_sendable
rule that triggers onSendable
conformances of
types that are implicitly alreadySendable
due to being actor-isolated. It
is enabled by default.
SimplyDanny -
Improve performance when exclude patterns resolve to a large set of files.
SimplyDanny
#5018
Bug Fixes
-
Ignore TipKit's
#Rule
macro inempty_count
rule.
Ueeek
#5883 -
Ignore super calls with trailing closures in
unneeded_override
rule.
SimplyDanny
#5886 -
If violations are detected by
lint
oranalyze
, still perform an update
check for new versions of SwiftLint if requested.
Martin Redington
#5904
Using Bazel
With bzlmod:
// Pending BCR update
bazel_dep(name = "swiftlint", version = "0.58.0", repo_name = "SwiftLint")
Without bzlmod, put this in your WORKSPACE
:
WORKSPACE
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "build_bazel_rules_apple",
sha256 = "9e26307516c4d5f2ad4aee90ac01eb8cd31f9b8d6ea93619fc64b3cbc81b0944",
url = "https://github.com/bazelbuild/rules_apple/releases/download/2.2.0/rules_apple.2.2.0.tar.gz",
)
load(
"@build_bazel_rules_apple//apple:repositories.bzl",
"apple_rules_dependencies",
)
apple_rules_dependencies()
load(
"@build_bazel_rules_swift//swift:repositories.bzl",
"swift_rules_dependencies",
)
swift_rules_dependencies()
load(
"@build_bazel_rules_swift//swift:extras.bzl",
"swift_rules_extra_dependencies",
)
swift_rules_extra_dependencies()
http_archive(
name = "SwiftLint",
sha256 = "7f069bc44c548896f78b80cdf223643f6f6da5093a934e834dd7f68eaf1d1940",
url = "https://github.com/realm/SwiftLint/releases/download/0.58.0/bazel.tar.gz",
)
load("@SwiftLint//bazel:repos.bzl", "swiftlint_repos")
swiftlint_repos()
load("@SwiftLint//bazel:deps.bzl", "swiftlint_deps")
swiftlint_deps()
Then you can run SwiftLint in the current directory with this command:
bazel run @SwiftLint//:swiftlint -- --help
0.57.1: Squeaky Clean Cycle
Breaking
- None.
Experimental
- None.
Enhancements
-
Suggest failable
String(bytes:encoding:)
initializer in
optional_data_string_conversion
rule as it accepts allSequence
types.
Jordan Rose
SimplyDanny -
Support reading files to lint from Input File Lists provided
by Run Script Build Phases in Xcode using the command-line
argument--use-script-input-file-lists
.
BlueVirusX -
Adds a
lenient
configuration file setting, equivalent to the--lenient
command line option.
Martin Redington
#5801 -
Support type casting on configuration option values defined by environment variables.
Without a cast, these values would always be treated as strings leading to a potentially
invalid configuration.
SimplyDanny
#5774 -
Add new option
max_number_of_single_line_parameters
that allows only the specified maximum
number of parameters to be on one line whenallows_single_line = true
. If the limit is
exceeded, the rule will still trigger. Confusing option combinations likeallows_single_line = false
together withmax_number_of_single_line_parameters > 1
will be reported.
kimdv
SimplyDanny
#5781 -
The
redundant_type_annotation
rule gains a new option,
ignore_properties
, that skips enforcement on members in a
type declaration (like astruct
). This helps the rule coexist with
theexplicit_type_interface
rule that requires such redundancy.
jaredgrubb
#3750 -
Allow inherited isolation parameter to be first in function signatures
depending on the new optionignore_first_isolation_inheritance_parameter
which istrue
by default.
SimplyDanny
#5793
Bug Fixes
-
Run command plugin in whole package if no targets are defined in the
package manifest.
SimplyDanny
#5787 -
Silence
superfluous_else
rule onif
expressions with only a single
availability condition.
SimplyDanny
#5833 -
Stop triggering the
control_statement
rule on closures being directly
called as conditions.
SimplyDanny
#5846 -
Do not trigger
self_in_property_initialization
rule onself
in
key paths expressions.
SimplyDanny
#5835 -
Allow to specify transitive modules to be taken into account by
unused_import
rule. This avoids that required imports are removed.
Paul Taykalo
SimplyDanny
#5167 -
Only pass cache path and directory paths to commands that accept these arguments
in the command plugin.
SimplyDanny
#5848 -
Do not throw deprecation warning if deprecated property is not
presented in configuration.
chipp
#5791 -
The
prefer_type_checking
rule will no longer trigger for non-optional
type casting (as
), or for comparisons to optional types.
Martin Redington
#5802 -
Fixes an issue where the
superfluous_disable_command
rule could generate
false positives for nested disable commands for custom rules.
Martin Redington
#5788 -
Fixes the
--only-rule
command line option, when a default.swiftlint.yml
is absent. Additionally rules specified with--only-rule
on the command
line can now be disabled in a child configuration, to allow specific
directories to be excluded from the rule (or from being auto-corrected by
the rule), and--only-rule
can now be specified multiple times
to run multiple rules.
Martin Redington
#5711
Using Bazel
With bzlmod:
// Pending BCR update
bazel_dep(name = "swiftlint", version = "0.57.1", repo_name = "SwiftLint")
Without bzlmod, put this in your WORKSPACE
:
WORKSPACE
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "build_bazel_rules_apple",
sha256 = "9e26307516c4d5f2ad4aee90ac01eb8cd31f9b8d6ea93619fc64b3cbc81b0944",
url = "https://github.com/bazelbuild/rules_apple/releases/download/2.2.0/rules_apple.2.2.0.tar.gz",
)
load(
"@build_bazel_rules_apple//apple:repositories.bzl",
"apple_rules_dependencies",
)
apple_rules_dependencies()
load(
"@build_bazel_rules_swift//swift:repositories.bzl",
"swift_rules_dependencies",
)
swift_rules_dependencies()
load(
"@build_bazel_rules_swift//swift:extras.bzl",
"swift_rules_extra_dependencies",
)
swift_rules_extra_dependencies()
http_archive(
name = "SwiftLint",
sha256 = "78f9a8dfd3cb4b6b5ff173892c7f273cae0b67f3a0a1bd8651fe10029693f5f4",
url = "https://github.com/realm/SwiftLint/releases/download/0.57.1/bazel.tar.gz",
)
load("@SwiftLint//bazel:repos.bzl", "swiftlint_repos")
swiftlint_repos()
load("@SwiftLint//bazel:deps.bzl", "swiftlint_deps")
swiftlint_deps()
Then you can run SwiftLint in the current directory with this command:
bazel run @SwiftLint//:swiftlint -- --help
0.57.0: Squeaky Clean Cycle
Breaking
-
The deprecated
anyobject_protocol
rule has now been removed.
Martin Redington
#5769 -
Revert the part of the
non_optional_string_data_conversion
rule that enforces non-failable conversions ofData
to UTF-8
String
. This is due to the fact that the data to be converted
can be arbitrary and especially doesn't need to represent a valid
UTF-8-encoded string.
Sam Rayner
#5263
Experimental
- None.
Enhancements
-
Add
ignore_multiline_type_headers
andignore_multiline_statement_conditions
options toopening_brace
rule to allow opening braces to be on a new line after
multiline type headers or statement conditions. Renameallow_multiline_func
to
ignore_multiline_function_signatures
.
leonardosrodrigues0
#3720 -
Add new
optional_data_string_conversion
rule to enforce
failable conversions ofData
to UTF-8String
.
Sam Rayner
#5263 -
The
no_magic_numbers
rule will now ignore violations in
SwiftUI'sPreview
macro.
Martin Redington
#5778
Bug Fixes
-
superfluous_disable_command
violations are now triggered for
custom rules.
Marcelo Fabri
Martin Redington
SimplyDanny
#4754 -
Trailing comments are now preserved by the
opening_brace
rule when
rewriting.
Martin Redington
#5751
Using Bazel
With bzlmod:
// Pending BCR update
bazel_dep(name = "swiftlint", version = "0.57.0", repo_name = "SwiftLint")
Without bzlmod, put this in your WORKSPACE
:
WORKSPACE
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "build_bazel_rules_apple",
sha256 = "9e26307516c4d5f2ad4aee90ac01eb8cd31f9b8d6ea93619fc64b3cbc81b0944",
url = "https://github.com/bazelbuild/rules_apple/releases/download/2.2.0/rules_apple.2.2.0.tar.gz",
)
load(
"@build_bazel_rules_apple//apple:repositories.bzl",
"apple_rules_dependencies",
)
apple_rules_dependencies()
load(
"@build_bazel_rules_swift//swift:repositories.bzl",
"swift_rules_dependencies",
)
swift_rules_dependencies()
load(
"@build_bazel_rules_swift//swift:extras.bzl",
"swift_rules_extra_dependencies",
)
swift_rules_extra_dependencies()
http_archive(
name = "SwiftLint",
sha256 = "82343de268e63d196cf878bd77e88289ec6ea64054d328e92fe1baae18733104",
url = "https://github.com/realm/SwiftLint/releases/download/0.57.0/bazel.tar.gz",
)
load("@SwiftLint//bazel:repos.bzl", "swiftlint_repos")
swiftlint_repos()
load("@SwiftLint//bazel:deps.bzl", "swiftlint_deps")
swiftlint_deps()
Then you can run SwiftLint in the current directory with this command:
bazel run @SwiftLint//:swiftlint -- --help
0.56.2: Heat Pump Dryer
Breaking
- None.
Experimental
- None.
Enhancements
- None.
Bug Fixes
-
Ignore initializers with attributes in
unneeded_synthesized_initializer
rule.
SimplyDanny
#5153 -
Silence
prefer_key_path
rule on macro expansion expressions.
SimplyDanny
#5744 -
Check
if
expressions nested arbitrarily deep incontrasted_opening_brace
rule.
SimplyDanny
#5752 -
Align left closure brace with associated parent function call in
contrasted_opening_brace
rule.
SimplyDanny
#5752 -
Align left brace of additional trailing closures with right brace of previous trailing closure
incontrasted_opening_brace
rule.
SimplyDanny
#5752 -
Trigger on empty closure blocks in
no_empty_block
rule.
SimplyDanny
#5762 -
Silence
unneeded_override
rule on methods and initializers with attributes.
SimplyDanny
#5753
Using Bazel
With bzlmod:
// Pending BCR update
bazel_dep(name = "swiftlint", version = "0.56.2", repo_name = "SwiftLint")
Without bzlmod, put this in your WORKSPACE
:
WORKSPACE
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "build_bazel_rules_apple",
sha256 = "9e26307516c4d5f2ad4aee90ac01eb8cd31f9b8d6ea93619fc64b3cbc81b0944",
url = "https://github.com/bazelbuild/rules_apple/releases/download/2.2.0/rules_apple.2.2.0.tar.gz",
)
load(
"@build_bazel_rules_apple//apple:repositories.bzl",
"apple_rules_dependencies",
)
apple_rules_dependencies()
load(
"@build_bazel_rules_swift//swift:repositories.bzl",
"swift_rules_dependencies",
)
swift_rules_dependencies()
load(
"@build_bazel_rules_swift//swift:extras.bzl",
"swift_rules_extra_dependencies",
)
swift_rules_extra_dependencies()
http_archive(
name = "SwiftLint",
sha256 = "d607223592fb87c67e91d899e8e33b5e0b04da5306afd994c4331c2881b6832d",
url = "https://github.com/realm/SwiftLint/releases/download/0.56.2/bazel.tar.gz",
)
load("@SwiftLint//bazel:repos.bzl", "swiftlint_repos")
swiftlint_repos()
load("@SwiftLint//bazel:deps.bzl", "swiftlint_deps")
swiftlint_deps()
Then you can run SwiftLint in the current directory with this command:
bazel run @SwiftLint//:swiftlint -- --help
0.56.1: Heat Pump Dryer
Breaking
- None.
Experimental
- None.
Enhancements
- None.
Bug Fixes
- Let
contrasted_opening_brace
be an opt-in rule.
SimplyDanny
Using Bazel
With bzlmod:
// Pending BCR update
bazel_dep(name = "swiftlint", version = "0.56.1", repo_name = "SwiftLint")
Without bzlmod, put this in your WORKSPACE
:
WORKSPACE
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "build_bazel_rules_apple",
sha256 = "9e26307516c4d5f2ad4aee90ac01eb8cd31f9b8d6ea93619fc64b3cbc81b0944",
url = "https://github.com/bazelbuild/rules_apple/releases/download/2.2.0/rules_apple.2.2.0.tar.gz",
)
load(
"@build_bazel_rules_apple//apple:repositories.bzl",
"apple_rules_dependencies",
)
apple_rules_dependencies()
load(
"@build_bazel_rules_swift//swift:repositories.bzl",
"swift_rules_dependencies",
)
swift_rules_dependencies()
load(
"@build_bazel_rules_swift//swift:extras.bzl",
"swift_rules_extra_dependencies",
)
swift_rules_extra_dependencies()
http_archive(
name = "SwiftLint",
sha256 = "100aa8cbe1c42b0503d5b0a6c1944b9955c1c1795d59e39a4c1d3a5a3153c5b6",
url = "https://github.com/realm/SwiftLint/releases/download/0.56.1/bazel.tar.gz",
)
load("@SwiftLint//bazel:repos.bzl", "swiftlint_repos")
swiftlint_repos()
load("@SwiftLint//bazel:deps.bzl", "swiftlint_deps")
swiftlint_deps()
Then you can run SwiftLint in the current directory with this command:
bazel run @SwiftLint//:swiftlint -- --help
0.56.0: Heat Pump Dryer
Breaking
-
The deprecated
--path
and--in-process-sourcekit
arguments have now been
removed completely.
Martin Redington
SimplyDanny
#5614 -
When SwiftLint corrects violations automatically (
swiftlint lint --fix
)
it doesn't report the exact location of the fix any longer. The new format
is<file-path>: Correcting <rule-name>
without line and column numbers.
Reason: Correction positions are likely just incorrect, especially when
multiple rules apply their rewrites. Fixing that is not trivial and likely
not worth the effort also considering that there haven't been any bug
reports about wrong correction positions so far.
SimplyDanny
Experimental
- None.
Enhancements
-
Linting got up to 30% faster due to the praisworthy performance
improvements done in the SwiftSyntax library. -
Rewrite the following rules with SwiftSyntax:
missing_docs
-
Add new
prefer_key_path
rule that triggers when a trailing closure on a standard
function call is only hosting a (chained) member access expression since the closure
can be replaced with a key path argument. Likewise, it triggers on closure arguments.
SimplyDanny -
Adds
baseline
andwrite_baseline
configuration file settings, equivalent
to the--baseline
and--write-baseline
command line options.
Martin Redington
#5552 -
Add
no_empty_block
opt-in rule to validate that code blocks are not empty.
They should at least contain a comment.
Ueeek
#5615 -
Add new
contrasted_opening_brace
rule that enforces opening
braces to be on a separate line after the preceding declaration.
SimplyDanny -
Add new
unused_parameter
rule that triggers on function/initializer/subscript
parameters that are not used inside of the function/initializer/subscript.
SimplyDanny
#2120 -
Support
--target
paths being passed to command plugin by Xcode.
SimplyDanny
#5603 -
Add modified configurations to examples in rule documentation.
SimplyDanny -
Add new option
evaluate_effective_access_control_level
tomissing_docs
rule. Setting it totrue
stops the rule from triggering on declarations
inside of types with lower visibility. These declarations effectively
have at most the same access level.
SimplyDanny -
Add new
--check-for-updates
command line option for thelint
,analyze
,
andversion
subcommands to check for new versions of SwiftLint, and an
equivalentcheck_for_updates
configuration file setting.
Martin Redington
SimplyDanny
Ian Leitch
#5613 -
Add new
--only-rule
command line option for thelint
andanalyze
,
subcommands that overrides configuration file rule enablement and
disablement, in particular to facilitate running--fix
for single rules
without having to temporarily edit the configuration file.
Martin Redington
#5666
Bug Fixes
-
Fix a few false positives and negatives by updating the parser to support
Swift 6 with all its new language constructs.
SimplyDanny -
Stop triggering
mark
rule on "mark" comments in the middle of another
comment.
SimplyDanny
#5592 -
Don't consider specialized imports with attributes as duplicates in
duplicate_imports
rule.
SimplyDanny
#5716 -
Use correct types and relative paths in SARIF reporter output. Generally
avoid escaping slashes in JSON output as well.
SimplyDanny
#5598
#5599 -
Keep initializers with attributed parameters in
unneeded_synthesized_initializer
rule.
SimplyDanny
#5153 -
Make
vertical_whitespace_between_cases
rule work for
cases ending with a string literal.
ilendemli
#5612 -
Ignore access level modifiers restricted to value setting in
extension_access_modifier
rule.
SimplyDanny
#5623 -
Fix
baseline compare
incorrectly reporting some violations
as new, and also now sorts the violations frombaseline compare
deterministically.
Martin Redington
#5606 -
Fix rewriting for
implicit_return
rule when violations are
nested within each other.
Martin Redington
#5660 -
Fix
opening_brace
correction and make sure that disable commands
are taken into account before applying a fix.
swiftty
SimplyDanny
#5598 -
Violations of the
typesafe_array_init
rule will now be correctly
reported as such, instead of as violations of thearray_init
rule.
Martin Redington
#5709
Using Bazel
With bzlmod:
// Pending BCR update
bazel_dep(name = "swiftlint", version = "0.56.0", repo_name = "SwiftLint")
Without bzlmod, put this in your WORKSPACE
:
WORKSPACE
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "build_bazel_rules_apple",
sha256 = "9e26307516c4d5f2ad4aee90ac01eb8cd31f9b8d6ea93619fc64b3cbc81b0944",
url = "https://github.com/bazelbuild/rules_apple/releases/download/2.2.0/rules_apple.2.2.0.tar.gz",
)
load(
"@build_bazel_rules_apple//apple:repositories.bzl",
"apple_rules_dependencies",
)
apple_rules_dependencies()
load(
"@build_bazel_rules_swift//swift:repositories.bzl",
"swift_rules_dependencies",
)
swift_rules_dependencies()
load(
"@build_bazel_rules_swift//swift:extras.bzl",
"swift_rules_extra_dependencies",
)
swift_rules_extra_dependencies()
http_archive(
name = "SwiftLint",
sha256 = "40a7873d54899ace4e485317d172c19507135ae1b3683159d521cc1daa42e196",
url = "https://github.com/realm/SwiftLint/releases/download/0.56.0/bazel.tar.gz",
)
load("@SwiftLint//bazel:repos.bzl", "swiftlint_repos")
swiftlint_repos()
load("@SwiftLint//bazel:deps.bzl", "swiftlint_deps")
swiftlint_deps()
Then you can run SwiftLint in the current directory with this command:
bazel run @SwiftLint//:swiftlint -- --help
0.55.1: Universal Washing Powder
Breaking
- None.
Experimental
- None.
Enhancements
- Clarify wording of
static_over_final_class
rule's violation message.
SimplyDanny
#5570
Bug Fixes
-
Fix Bazel build when
bzlmod
is not in use by adding transitive dependencies
explicitly.
SimplyDanny
#5568 -
Treat condionally activatable variable declarations and initializer as if
they were always active inunneeded_synthesized_initializer
rule to avoid
compilation issues when unexpected items are there after all.
SimplyDanny
#5574 -
Silence
unused_enumerated
rule when$0
in a closure is explicitly unpacked.
SimplyDanny
#5573 -
Remove redundant initializers in
unneeded_override
rule only when checking
initializers is actually enabled in the configuration.
SimplyDanny
#5571 -
Respect comments before opening brace in
opening_brace
rule when there is
one space before the brace after the comment. Everything else is still a
violation, yet the rewriter will not remove the comment anymore.
SimplyDanny
#5578
Using Bazel
With bzlmod:
// Pending BCR update
bazel_dep(name = "swiftlint", version = "0.55.1", repo_name = "SwiftLint")
Without bzlmod, put this in your WORKSPACE
:
WORKSPACE
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "build_bazel_rules_apple",
sha256 = "9e26307516c4d5f2ad4aee90ac01eb8cd31f9b8d6ea93619fc64b3cbc81b0944",
url = "https://github.com/bazelbuild/rules_apple/releases/download/2.2.0/rules_apple.2.2.0.tar.gz",
)
load(
"@build_bazel_rules_apple//apple:repositories.bzl",
"apple_rules_dependencies",
)
apple_rules_dependencies()
load(
"@build_bazel_rules_swift//swift:repositories.bzl",
"swift_rules_dependencies",
)
swift_rules_dependencies()
load(
"@build_bazel_rules_swift//swift:extras.bzl",
"swift_rules_extra_dependencies",
)
swift_rules_extra_dependencies()
http_archive(
name = "SwiftLint",
sha256 = "78220a0b97db39edb08ead8e663aef415915e7d6631ba39ef3cc69b39352f664",
url = "https://github.com/realm/SwiftLint/releases/download/0.55.1/bazel.tar.gz",
)
load("@SwiftLint//bazel:repos.bzl", "swiftlint_repos")
swiftlint_repos()
load("@SwiftLint//bazel:deps.bzl", "swiftlint_deps")
swiftlint_deps()
Then you can run SwiftLint in the current directory with this command:
bazel run @SwiftLint//:swiftlint -- --help
0.55.0: Universal Washing Powder
Breaking
-
Rewrite
SwiftLintBuildToolPlugin
usingBUILD_WORKSPACE_DIRECTORY
without relying
on the--config
option.
Garric Nahapetian -
Introduce SwiftLintCommandPlugin.
Rename SwiftLintBuildToolPlugin.
Add Swift Package Manager installation instructions.
garricn -
Fix Code Climate reporter output by having lower case severity
values to comply with the Code Climate specification.
waitButY -
The
superfluous_disable_command
rule will now be enabled for theanalyze
command, unless it has been disabled, and will warn about superfluous
disablement of analyzer rules.
Martin Redington
#4792 -
With the introduction of the
consider_default_literal_types_redundant
option to theredundant_type_annotation
rule,Bool
literals will no
longer be considered redundant by default. Set this option to true to
preserve the previous behavior.
Garric Nahapetian
Experimental
- Add two new options to the
lint
andanalyze
commands:--write-baseline
to save a baseline to disk, and--baseline
to read a saved baseline and
use it to filter out detected pre-existing violations. A newbaseline
command uses the reporters to print the violations in a baseline.
Martin Redington
#5475
#3421
Enhancements
-
Add a reporter that outputs violations in the Static
Analysis Results Interchange Format (SARIF).
waitButY -
Ignore absence of a non-initial local config instead of
falling back to default.
kohtenko -
Add new option
ignore_typealiases_and_associatedtypes
to
nesting
rule. It excludestypealias
andassociatedtype
declarations from the analysis.
marunomi
#3183 -
Prevent from compiling
SwiftLint
target when only usingSwiftLintPlugin
on macOS.
Julien Baillon
#5372 -
Allow to set the severity of rules (if they have one) in the short form
rule_name: warning|error
provided that no other attributes need to be
configured.
SimplyDanny -
Add new
ignore_one_liners
option toswitch_case_alignment
rule to ignore switch statements written in a single line.
tonell-m
#5373 -
Add new
shorthand_argument
rule that triggers on shorthand arguments
like$0
,$1
, etc. in closures if they are too far away from the
beginning of the closure. Options allow further cases to always trigger.
SimplyDanny
#70 -
Warn when
--fix
comes together with--strict
or--lenient
as only--fix
takes effect then.
SimplyDanny
#5387 -
Add new
one_declaration_per_file
rule that allows only a
single class/struct/enum/protocol declaration per file.
Extensions are an exception; more than one is allowed.
Muhammad Zeeshan
#2802 -
Add new
ignore_attributes
option toredundant_type_annotation
rule
that allows disabling the rule for properties that are marked with at least
one of the configured attributes.
tonell-m
#5366 -
Rewrite the following rules with SwiftSyntax:
explicit_acl
extension_access_modifier
identifier_name
let_var_whitespace
mark
multiline_literal_brackets
nesting
nimble_operator
opening_brace
orphaned_doc_comment
redundant_type_annotation
trailing_closure
void_return
SimplyDanny
kishikawakatsumi
Marcelo Fabri
swiftty
KS1019
tonell-m -
Print invalid keys when configuration parsing fails.
SimplyDanny
#5347 -
Add new
final_test_case
rule that triggers on non-final test classes.
SimplyDanny -
Make
superfluous_else
rule auto-correctable.
SimplyDanny -
Support other scope-exiting statements
continue
,break
andthrow
in
superfluous_else
rule.
SimplyDanny -
Trigger on
-> ()
return signatures inreturn_value_from_void_function
rule. Moreover, support automatic fixes for obvious cases.
SimplyDanny -
Refine violation position of
trailing_closure
rule.
SimplyDanny -
Trigger on the declaration keyword (i.e.
let
,var
,func
,subscript
)
instead of thestatic
orclass
keywords in theexplicit_acl
rule.
SimplyDanny -
Allow to configure more operators in
identifier_name
rule. The new option
is namedadditional_operators
. Use it to add more operators to the list
of default operators known to the rule.
SimplyDanny
#1762 -
Stop triggering
no_magic_numbers
rule on literals used in range
expressions assigned to variables.
SimplyDanny
#5430 -
Add
affect_initializers
option to allowunneeded_override
rule
to affect initializers.
leonardosrodrigues0
#5265 -
Respect scattered disable commands in auto-correction of
duplicate_imports
rule.
SimplyDanny
#5418 -
Add new
non_optional_string_data_conversion
rule to enforce
non-failable conversions of UTF-8String
<->Data
.
Ben P
#5263 -
Refine violation position of
superfluous_else
rule.
SimplyDanny -
Make
sorted_enum_cases
rule's comparison case-insensitive to
avoid unexpected ordering.
Oleg Kokhtenko -
Add
excluded_lines_patterns
toline_length
to avoid linting lines
that contain one of the patterns.
kasrababaei -
Make
empty_count
auto-correctable.
KS1019 -
Make
private_swiftui_state
auto-correctable.
mt00chikin -
Make
trailing_closure
correctable.
KS1019 -
Add new
static_over_final_class
rule to preferstatic
over
final class
declaration.
phlippieb
#5471 -
Extends
unused_enumerated
rule to cover closure parameters, to
detect cases likelist.enumerated().map { idx, _ in idx }
and
list.enumerated().map { $1 }
.
Martin Redington
#5470 -
Include
Double
,Int
andString
to the exiting redundant type validation
check ofBool
in theredundant_type_annotation
rule. Add
consider_default_literal_types_redundant
option supportingBool
,
Double
,Int
andString
. Setting this option totrue
lets the rule
consider said types in declarations likelet i: Int = 1
or
let s: String = ""
as redundant.
Garric Nahapetian
Bug Fixes
-
Invalid keys in a configuration don't lead to the default configuration being
used anymore. The invalid key will just be reported but otherwise ignored.
SimplyDanny
#5565 -
Fix version comparison algorithm which caused some version-dependent rules to
misbehave with Swift 5.10.
chandlerwall
#5517 -
Silence
discarded_notification_center_observer
rule in closures. Furthermore,
handleget
andset
accessors correctly and consider implicit returns.
SimplyDanny
#4801 -
Fix some false positives in
let_var_whitespace
rule that would happen
when attributes attached to declarations were spread over multiple lines.
SimplyDanny
#4801 -
Support
private_over_fileprivate
rule for actors.
SimplyDanny
#5489 -
Ensure that declarations referenced only as extended types do not count as
used by means of theunused_declaration
rule.
SimplyDanny
[#5550](#555...