Releases: realm/SwiftLint
0.52.2: Crisper Clearer Pleats
Breaking
- None.
Experimental
- None.
Enhancements
- Exclude simple assignments of the form
self.x = x
from being reported by
theredundant_self_in_closure
rule.
SimplyDanny
#4988
Bug Fixes
-
Make
unhandled_throwing_task
opt-in instead of enabled by default. The rule
is still prone to false positives at this point, so this makes enabling the
rule a conscious decision by end-users.
JP Simard
#4987 -
Fix
unhandled_throwing_task
false positives when theTask
is returned or
where the throwing code is handled in aResult
initializer.
JP Simard
#4987
Using Bazel
With bzlmod:
bazel_dep(name = "swiftlint", version = "0.52.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 = "2b95a592304bc377aa29d92683618376975f93553be62f132de7424819f6fc4a",
url = "https://github.com/realm/SwiftLint/releases/download/0.52.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.52.1: Crisp Clear Pleats
0.52.1: Crisp Clear Pleats
Bug Fixes
-
Let the
validates_start_with_lowercase
option in name configurations
expect a severity (warning or error). Not setting it disables the check.
Boolean values are now deprecated. Atrue
value enables the check as an
error for the time being to keep the previous behavior.
SimplyDanny
#2180 -
Fixed a false positive in
unhandled_throwing_task
.
kylebshr
#4984 -
Fix Bazel release tarball for compiling on macOS.
JP Simard
#4985
0.52.0: Crisp Clear Pleats
Breaking
-
The
attributes
rule now expects attributes with arguments to be placed
on their own line above the declaration they are supposed to influence.
This applies to attributes with any kinds of arguments including single
key path arguments which were previously handled in a different way. This
behavior can be turned off by settingattributes_with_arguments_always_on_line_above
to `false.
SimplyDanny
#4843 -
The internal module structure for SwiftLint has changed to split the
monolithicSwiftLintFramework
into newSwiftLintCore
for core linter
infrastructure,SwiftLintBuiltInRules
for built-in rules and
SwiftLintExtraRules
to add your own native rules to SwiftLint.
JP Simard
Experimental
- None.
Enhancements
-
Add new
superfluous_else
rule that triggers onif
-statements when an
attachedelse
-block can be removed, because all branches of the previous
if
-block(s) would certainly exit the current scope already.
SimplyDanny -
Add
sorted_enum_cases
rule which warns when enum cases are not sorted.
kimdv -
Add new
redundant_self_in_closure
rule that triggers in closures on
explicitly usedself
when it's actually not needed due to:- Strongly captured
self
({ [self] in ... }
) - Closure used in a struct declaration (
self
can always be omitted) - Anonymous closures that are directly called (
{ ... }()
) as they are
definitly not escaping - Weakly captured
self
with explicit unwrapping
- Strongly captured
-
Extend
xct_specific_matcher
rule to check for boolean asserts on (un)equal
comparisons. The rule can be configured with the matchers that should trigger
rule violations. By default, all matchers trigger, but that can be limited to
justone-argument-asserts
ortwo-argument-asserts
.
SimplyDanny
JP Simard
#3726 -
Trigger
prefer_self_in_static_references
rule on more type references.
SimplyDanny -
Adds a new
reporters
command, to improve discoverability of reporters.
Martin Redington
#4819 -
Adds
test_parent_classes
option to theno_magic_numbers
rule.
Violations within test classes will now be ignored by default.
Martin Redington
#4896 -
Stop enforcing calls to super from the override functions
setUp()
,
tearDown()
,setUpWithError()
, andtearDownWithError()
inXCTestCase
subclasses.
AndrewDMontgomery
#4875 -
Prepend
warning:
to error messages so that they show in Xcode.
whiteio
#4923 -
The
attributes
rule received a new boolean option
attributes_with_arguments_always_on_line_above
which istrue
by default.
Setting it tofalse
ensures that attributes with arguments like
@Persisted(primaryKey: true)
don't violate the rule if they are on the same
line with the variable declaration.
SimplyDanny
#4843 -
Add new
unhandled_throwing_task
rule that triggers when a Task with an
implicit error type has unhandled trys or errors thrown inside its body.
This results in errors being silently discarded, which may be unexpected.
See this forum thread for more details: https://forums.swift.org/t/56066
kylebshr
Bug Fixes
-
Fix
lower_acl_than_parent
rule rewriter by preserving leading whitespace.
SimplyDanny
#4860 -
Ignore block comments in
let_var_whitespace
rule.
SimplyDanny
#4871 -
Fix false positives in
indentation_width
rule.
Sven Münnich -
Do not trigger
reduce_boolean
onreduce
methods with a first named
argument that is different frominto
.
SimplyDanny
#4894 -
Work around dyld warning about duplicate SwiftSyntax classes.
keith
#4782 -
Improve lint times of SwiftLintPlugin by moving the
excludedPaths(fileManager:)
operation out of the linting iterations.
andyyhope
#4844
Using Bazel
With bzlmod:
bazel_dep(name = "swiftlint", version = "0.52.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 = "22973f004310a1e5611ae6d08077e907be4883929d10c049cc0b9846463b3d9a",
url = "https://github.com/realm/SwiftLint/releases/download/0.52.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.52.0: Crisp Clear Pleats
Breaking
-
The
attributes
rule now expects attributes with arguments to be placed
on their own line above the declaration they are supposed to influence.
This applies to attributes with any kinds of arguments including single
key path arguments which were previously handled in a different way. This
behavior can be turned off by settingattributes_with_arguments_always_on_line_above
to `false.
SimplyDanny
#4843 -
The internal module structure for SwiftLint has changed to split the
monolithicSwiftLintFramework
into newSwiftLintCore
for core linter
infrastructure,SwiftLintBuiltInRules
for built-in rules and
SwiftLintExtraRules
to add your own native rules to SwiftLint.
JP Simard
Experimental
- None.
Enhancements
-
Add new
superfluous_else
rule that triggers onif
-statements when an
attachedelse
-block can be removed, because all branches of the previous
if
-block(s) would certainly exit the current scope already.
SimplyDanny -
Add
sorted_enum_cases
rule which warns when enum cases are not sorted.
kimdv -
Add new
redundant_self_in_closure
rule that triggers in closures on
explicitly usedself
when it's actually not needed due to:- Strongly captured
self
({ [self] in ... }
) - Closure used in a struct declaration (
self
can always be omitted) - Anonymous closures that are directly called (
{ ... }()
) as they are
definitly not escaping - Weakly captured
self
with explicit unwrapping
- Strongly captured
-
Extend
xct_specific_matcher
rule to check for boolean asserts on (un)equal
comparisons. The rule can be configured with the matchers that should trigger
rule violations. By default, all matchers trigger, but that can be limited to
justone-argument-asserts
ortwo-argument-asserts
.
SimplyDanny
JP Simard
#3726 -
Trigger
prefer_self_in_static_references
rule on more type references.
SimplyDanny -
Adds a new
reporters
command, to improve discoverability of reporters.
Martin Redington
#4819 -
Adds
test_parent_classes
option to theno_magic_numbers
rule.
Violations within test classes will now be ignored by default.
Martin Redington
#4896 -
Stop enforcing calls to super from the override functions
setUp()
,
tearDown()
,setUpWithError()
, andtearDownWithError()
inXCTestCase
subclasses.
AndrewDMontgomery
#4875 -
Prepend
warning:
to error messages so that they show in Xcode.
whiteio
#4923 -
The
attributes
rule received a new boolean option
attributes_with_arguments_always_on_line_above
which istrue
by default.
Setting it tofalse
ensures that attributes with arguments like
@Persisted(primaryKey: true)
don't violate the rule if they are on the same
line with the variable declaration.
SimplyDanny
#4843 -
Add new
unhandled_throwing_task
rule that triggers when a Task with an
implicit error type has unhandled trys or errors thrown inside its body.
This results in errors being silently discarded, which may be unexpected.
See this forum thread for more details: https://forums.swift.org/t/56066
kylebshr
Bug Fixes
-
Fix
lower_acl_than_parent
rule rewriter by preserving leading whitespace.
SimplyDanny
#4860 -
Ignore block comments in
let_var_whitespace
rule.
SimplyDanny
#4871 -
Fix false positives in
indentation_width
rule.
Sven Münnich -
Do not trigger
reduce_boolean
onreduce
methods with a first named
argument that is different frominto
.
SimplyDanny
#4894 -
Work around dyld warning about duplicate SwiftSyntax classes.
keith
#4782 -
Improve lint times of SwiftLintPlugin by moving the
excludedPaths(fileManager:)
operation out of the linting iterations.
andyyhope
#4844
Using Bazel
With bzlmod:
bazel_dep(name = "swiftlint", version = "0.52.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 = "c5021aff12fd0e0cbf17c232d8f0e28a27ccf886d5a871681cb78f7b30a20faa",
url = "https://github.com/realm/SwiftLint/releases/download/0.52.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.51.0: bzllint
0.51.0: bzllint
Breaking
-
Deprecate the
unused_capture_list
rule in favor of the Swift compiler
warning. At the same time, make it an opt-in rule.
Cyberbeni
#4656 -
Deprecate the
inert_defer
rule in favor of the Swift compiler warning.
At the same time, make it an opt-in rule.
SimplyDanny
#4615
Experimental
- None.
Enhancements
-
Add
duplicate_conditions
rule which warns when a condition is duplicated
in separate branches of the same branching statement (if-else, or switch).
1in1
#4666 -
Add local links to rule descriptions to every rule listed
inRule Directory.md
.
kattouf -
Make forceExclude work with directly specified files.
jimmya
#4609 -
Adds
all
pseudo-rule foropt_in_rules
- enables all opt in rules
that are not listed indisabled_rules
Martin Redington
#4540 -
Separate analyzer rules as an independent section in the rule directory of
the reference.
Ethan Wong
#4664 -
Add rule identifier to output of Emoji reporter.
SimplyDanny
#4707 -
Interpret strings in
excluded
option ofidentifier_name
,
type_name
andgeneric_type_name
rules as regex.
Moly
#4655 -
Add new
direct_return
rule that triggers onreturn
statements returning
variables that have been declared in the statement before only.
SimplyDanny -
Add
period_spacing
opt-in rule that checks periods are not followed
by 2 or more spaces in comments.
Julioacarrettoni
#4624 -
Allow to pass a rule identifier to the
swiftlint docs
command to open its
specific documentation website, e.g.swiftlint docs for_where
.
SimplyDanny
#4707 -
Allow new Quick APIs
aroundEach
andjustBeforeEach
for
quick_discouraged_call
.
David Steinacher
#4626 -
Add
relative-path
reporter to generate reports with relative file paths.
Roya1v
#4660 -
Let
number_separator
rule trigger on misplaced separators, e.g.10_00
.
SimplyDanny
#4637 -
Rewrite
multiline_arguments
rule using SwiftSyntax, ignoring trailing
closures.
Marcelo Fabri
#3399
#3605 -
Speed up linting by up to 6% updating to use a newer version of
SwiftSyntax
.
JP Simard -
Catch more valid
legacy_multiple
violations.
JP Simard -
Catch more valid
no_magic_numbers
violations.
JP Simard -
Add
blanket_disable_command
rule that checks whether
rules are re-enabled after being disabled.
Martin Redington
#4731 -
Add
invalid_swiftlint_command
rule that validates
// swiftlint:enable
anddisable
commands.
Martin Redington
#4546 -
Improve
identifier_name
documentation.
Martin Redington
#4767 -
Adds
include_multiline_strings
option toindentation_width
rule.
Martin Redington
#4248 -
Adds a new
summary
reporter, that displays the number of violations
of each rule in a text table.
Martin Redington
Bug Fixes
-
Report violations in all
<scope>_length
rules when the error threshold is
smaller than the warning threshold.
SimplyDanny
#4645 -
Consider custom attributes in
attributes
rule.
SimplyDanny
#4599 -
Fix whitespaces issue in auto-fix of
redundant_optional_initialization
rule when multiple variable declaration are involved.
SimplyDanny
#4794 -
Stop triggering
strict_fileprivate
rule on symbols implementing a protocol
in the same file.
SimplyDanny
#4692 -
Fix false positives on
private_subject
rule when using
subjects inside functions.
Marcelo Fabri
#4643 -
Fix for compiler directives masking subsequent
opening_brace
violations.
Martin Redington
#3712 -
Rewrite
explicit_type_interface
rule with SwiftSyntax fixing a
false-positive in if-case-let statements.
SimplyDanny
#4548 -
Stop triggering
unused_capture_list
on captured variable that is only
referenced by a shorthand optional binding (if let capturedVar { ... }
).
SimplyDanny
#4804 -
Ensure that negative literals in initializers do not trigger
no_magic_numbers
rule.
SimplyDanny
#4677 -
Fix caching of
indentation_width
rule.
SimplyDanny
#4121 -
Updated JUnit reporter to output error count and warning count.
patricks
#4725 -
Fix correction on
lower_acl_than_parent
rule foropen
declarations.
Marcelo Fabri
#4753 -
Fix
void_return
rule to support async and async throws functions.
Mathias Schreck
#4772 -
Fix false positives in
attributes
rule when using property wrappers
with keypath arguments.
JP Simard -
Fix for
superfluous_disable_command
not being completely disabled
bydisable
commands.
Martin Redington
#4788 -
Fixed correction for
trailing_comma
rule wrongly removing trailing
comments.
Martin Redington
#4814
Using Bazel
With bzlmod:
bazel_dep(name = "swiftlint", version = "0.51.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 = "8369ca218c4c898b7af202e2ec6180062396f659debca49a1d6c66902a3a37c3",
url = "https://github.com/realm/SwiftLint/releases/download/0.51.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.51.0-rc.2: bzllint
This is a prerelease version. It won't be published to Homebrew, CocoaPods or bzlmod. But there are many other ways to install:
- Downloading the attached
SwiftLint.pkg
installer and launching it - Downloading the attached
portable_swiftlint.zip
archive, extracting it and moving the binary fromportable_swiftlint/swiftlint
to/usr/local/bin
or elsewhere in yourPATH
- Using Mint:
mint install realm/[email protected]
- Cloning and building from source:
git clone https://github.com/realm/SwiftLint.git && cd SwiftLint && git checkout 0.51.0-rc.2 && make install
- Docker:
docker run -it -v `pwd`:`pwd` -w `pwd` ghcr.io/realm/swiftlint:0.51.0-rc.2
- Bazel: See instructions at the bottom
Changes from 0.50.3: 0.50.3...0.51.0-rc.2
Changes from 0.51.0-rc.1: 0.51.0-rc.1...0.51.0-rc.2
Breaking
-
Deprecate the
unused_capture_list
rule in favor of the Swift compiler
warning. At the same time, make it an opt-in rule.
Cyberbeni
#4656 -
Deprecate the
inert_defer
rule in favor of the Swift compiler warning.
At the same time, make it an opt-in rule.
SimplyDanny
#4615
Experimental
- None.
Enhancements
-
Add local links to rule descriptions to every rule listed
inRule Directory.md
.
kattouf -
Make forceExclude work with directly specified files.
jimmya
#issue_number -
Separate analyzer rules as an independent section in the rule directory of
the reference.
Ethan Wong
#4664 -
Add rule identifier to output of Emoji reporter.
SimplyDanny
#4707 -
Interpret strings in
excluded
option ofidentifier_name
,
type_name
andgeneric_type_name
rules as regex.
Moly
#4655 -
Add new
direct_return
rule that triggers onreturn
statements returning
variables that have been declared in the statement before only.
SimplyDanny -
Add
period_spacing
opt-in rule that checks periods are not followed
by 2 or more spaces in comments.
Julioacarrettoni
#4624 -
Allow to pass a rule identifier to the
swiftlint docs
command to open its
specific documentation website, e.g.swiftlint docs for_where
.
SimplyDanny
#4707 -
Allow new Quick APIs
aroundEach
andjustBeforeEach
for
quick_discouraged_call
.
David Steinacher
#4626 -
Add
relative-path
reporter to generate reports with relative file paths.
Roya1v
#4660 -
Let
number_separator
rule trigger on misplaced separators, e.g.10_00
.
SimplyDanny
#4637 -
Rewrite
multiline_arguments
rule using SwiftSyntax, ignoring trailing
closures.
Marcelo Fabri
#3399
#3605 -
Speed up linting by up to 6% updating to use a newer version of
SwiftSyntax
.
JP Simard -
Catch more valid
legacy_multiple
violations.
JP Simard -
Catch more valid
no_magic_numbers
violations.
JP Simard
Bug Fixes
-
Report violations in all
<scope>_length
rules when the error threshold is
smaller than the warning threshold.
SimplyDanny
#4645 -
Consider custom attributes in
attributes
rule.
SimplyDanny
#4599 -
Stop triggering
strict_fileprivate
rule on symbols implementing a protocol
in the same file.
SimplyDanny
#4692 -
Fix false positives on
private_subject
rule when using
subjects inside functions.
Marcelo Fabri
#4643 -
Fix for compiler directives masking subsequent
opening_brace
violations.
Martin Redington
#3712 -
Rewrite
explicit_type_interface
rule with SwiftSyntax fixing a
false-positive in if-case-let statements.
SimplyDanny
#4548 -
Ensure that negative literals in initializers do not trigger
no_magic_numbers
rule.
SimplyDanny
#4677 -
Fix caching of
indentation_width
rule.
SimplyDanny
#4121 -
Updated JUnit reporter to output error count and warning count.
patricks
#4725 -
Fix correction on
lower_acl_than_parent
rule foropen
declarations.
Marcelo Fabri
#4753 -
Fix
void_return
rule to support async and async throws functions.
Mathias Schreck
#4772 -
Fix false positives in
attributes
rule when using property wrappers
with keypath arguments.
JP Simard
Using Bazel
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 = "43737f28a578d8d8d7ab7df2fb80225a6b23b9af9655fcdc66ae38eb2abcf2ed",
url = "https://github.com/bazelbuild/rules_apple/releases/download/2.0.0/rules_apple.2.0.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 = "f0e37c2ca277ef8c50d865cbdb75326592bcba11b786caf1fccc3111e9925e01",
url = "https://github.com/realm/SwiftLint/releases/download/0.51.0-rc.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.51.0-rc.1: bzllint
This is a prerelease version. It won't be published to Homebrew, CocoaPods or bzlmod. But there are many other ways to install:
- Downloading the attached
SwiftLint.pkg
installer and launching it - Downloading the attached
portable_swiftlint.zip
archive, extracting it and moving the binary fromportable_swiftlint/swiftlint
to/usr/local/bin
or elsewhere in yourPATH
- Using Mint:
mint install realm/[email protected]
- Cloning and building from source:
git clone https://github.com/realm/SwiftLint.git && cd SwiftLint && git checkout 0.51.0-rc.1 && make install
- Docker:
docker run -it -v `pwd`:`pwd` -w `pwd` ghcr.io/realm/swiftlint:0.51.0-rc.1
- Bazel: See instructions at the bottom
Changes from 0.50.3: 0.50.3...0.51.0-rc.1
Breaking
-
Deprecate the
unused_capture_list
rule in favor of the Swift compiler
warning. At the same time, make it an opt-in rule.
Cyberbeni
#4656 -
Deprecate the
inert_defer
rule in favor of the Swift compiler warning.
At the same time, make it an opt-in rule.
SimplyDanny
#4615
Experimental
- None.
Enhancements
-
Add local links to rule descriptions to every rule listed
inRule Directory.md
.
kattouf -
Make forceExclude work with directly specified files.
jimmya
#issue_number -
Separate analyzer rules as an independent section in the rule directory of
the reference.
Ethan Wong
#4664 -
Add rule identifier to output of Emoji reporter.
SimplyDanny
#4707 -
Interpret strings in
excluded
option ofidentifier_name
,
type_name
andgeneric_type_name
rules as regex.
Moly
#4655 -
Add new
direct_return
rule that triggers onreturn
statements returning
variables that have been declared in the statement before only.
SimplyDanny -
Add
period_spacing
opt-in rule that checks periods are not followed
by 2 or more spaces in comments.
Julioacarrettoni
#4624 -
Allow to pass a rule identifier to the
swiftlint docs
command to open its
specific documentation website, e.g.swiftlint docs for_where
.
SimplyDanny
#4707 -
Allow new Quick APIs
aroundEach
andjustBeforeEach
for
quick_discouraged_call
.
David Steinacher
#4626 -
Add
relative-path
reporter to generate reports with relative file paths.
Roya1v
#4660 -
Let
number_separator
rule trigger on misplaced separators, e.g.10_00
.
SimplyDanny
#4637 -
Rewrite
multiline_arguments
rule using SwiftSyntax, ignoring trailing
closures.
Marcelo Fabri
#3399
#3605 -
Speed up linting by up to 6% updating to use a newer version of
SwiftSyntax
.
JP Simard -
Catch more valid
legacy_multiple
violations.
JP Simard -
Catch more valid
no_magic_numbers
violations.
JP Simard
Bug Fixes
-
Report violations in all
<scope>_length
rules when the error threshold is
smaller than the warning threshold.
SimplyDanny
#4645 -
Consider custom attributes in
attributes
rule.
SimplyDanny
#4599 -
Stop triggering
strict_fileprivate
rule on symbols implementing a protocol
in the same file.
SimplyDanny
#4692 -
Fix false positives on
private_subject
rule when using
subjects inside functions.
Marcelo Fabri
#4643 -
Fix for compiler directives masking subsequent
opening_brace
violations.
Martin Redington
#3712 -
Rewrite
explicit_type_interface
rule with SwiftSyntax fixing a
false-positive in if-case-let statements.
SimplyDanny
#4548 -
Ensure that negative literals in initializers do not trigger
no_magic_numbers
rule.
SimplyDanny
#4677 -
Fix caching of
indentation_width
rule.
SimplyDanny
#4121 -
Updated JUnit reporter to output error count and warning count.
patricks
#4725 -
Fix correction on
lower_acl_than_parent
rule foropen
declarations.
Marcelo Fabri
#4753 -
Fix
void_return
rule to support async and async throws functions.
Mathias Schreck
#4772 -
Fix false positives in
attributes
rule when using property wrappers
with keypath arguments.
JP Simard
Using Bazel
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 = "43737f28a578d8d8d7ab7df2fb80225a6b23b9af9655fcdc66ae38eb2abcf2ed",
url = "https://github.com/bazelbuild/rules_apple/releases/download/2.0.0/rules_apple.2.0.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 = "f44b1e1c9aac0b4febbfae8479fc4e60df099066076fb10dfc0f42fd83731170",
url = "https://github.com/realm/SwiftLint/releases/download/0.51.0-rc.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.50.3: Bundle of Towels
Breaking
- None.
Experimental
- None.
Enhancements
-
The
SwiftLintPlugin
SwiftPM plugin now uses a prebuilt binary on
macOS.
Tony Arnold
JP Simard
#4558 -
Don't trigger
shorthand_operator
violations inside a shorthand
operator function declaration.
Marcelo Fabri
#4611 -
The
balanced_xctest_lifecycle
,single_test_class
,
empty_xctest_method
andtest_case_accessibility
rules will now be
applied to subclasses ofQuickSpec
, as well asXCTestCase
, by
default.
Martin Redington -
Add
test_parent_classes
option tobalanced_xctest_lifecycle
,
single_test_class
andempty_xctest_method
rules.
Martin Redington
#4200 -
Show warnings in the console for Analyzer rules that are listed in the
opt_in_rules
configuration section.
SimplyDanny
#4612
Bug Fixes
-
Fix configuration parsing error in
unused_declaration
rule.
SimplyDanny
#4612 -
Skip
defer
statements being last in an#if
block if the#if
statement is not itself the last statement in a block.
SimplyDanny
#4615 -
Fix false positives in
empty_enum_arguments
when the called
expression is an identifier or an init call.
Steffen Matthischke
#4597 -
Fix correction issue in
comma
when there was too much whitespace
following the comma.
JP Simard
Using Bazel
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 = "f94e6dddf74739ef5cb30f000e13a2a613f6ebfa5e63588305a71fce8a8a9911",
url = "https://github.com/bazelbuild/rules_apple/releases/download/1.1.3/rules_apple.1.1.3.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 = "b8c4d765bcd8b533fcc2e15f32482a1a17572f143b65af388f7d5ac99994a99a",
url = "https://github.com/realm/SwiftLint/releases/download/0.50.3/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 -c opt @SwiftLint//:swiftlint -- --help
0.50.1: Artisanal Clothes Pegs Fixup Edition
Breaking
- None.
Experimental
- None.
Enhancements
-
Moved the validation of doc comments in local scopes out of
orphaned_doc_comment
and into a new opt-inlocal_doc_comment
rule.
JP Simard
#4573 -
SwiftLint's Swift Package Build Tool Plugin will now only scan files
in the target being built.
Tony Arnold
#4406
Bug Fixes
-
Fix building with
swift build -c release
.
JP Simard
#4559
#4560 -
Fix false positives in
lower_acl_than_parent
when the nominal parent
is an extension.
Steffen Matthischke
#4564 -
Fix
minimum_fraction_length
handling innumber_separator
.
JP Simard
#4576 -
Fix false positives in
closure_spacing
.
JP Simard
#4565
#4582 -
Fix line count calculation for multiline string literals.
JP Simard
#4585 -
Fix false positives in
unused_closure_parameter
when using
identifiers with backticks.
JP Simard
#4588 -
Fix
type_name
regression where names with backticks would trigger
violations.
JP Simard
#4571
0.50.0: Artisanal Clothes Pegs
Breaking
-
SwiftLint now requires Swift 5.7 or higher to build.
JP Simard -
Exclude
weak_delegate
rule from autocorrection due to behavioral changes
leading to potential undefined behavior or bugs.
SimplyDanny
#3577 -
The
anyobject_protocol
rule is now deprecated and will be completely removed
in a future release because it is now handled by the Swift compiler.
JP Simard -
Built-in SwiftLint rules are no longer marked as
public
in
SwiftLintFramework. This only impacts the programmatic API for the
SwiftLintFramework module.
JP Simard
Experimental
- None.
Enhancements
-
SwiftSyntax libraries have been updated from the previous 5.6 release and now
use the new parser written in Swift.
Swift 5.7+ features should now be parsed more accurately.
We've also measured an improvement in lint times of up to 15%.
This should also fix some deployment issues where the exact version of the
internal SwiftSyntax parser needed to be available.
If you notice any unexpected changes to lint results, please file an issue on
the SwiftLint issue tracker. We can look into it and if it's a SwiftSyntax
parser regression we can re-file it upstream.
JP Simard
#4031 -
Rewrite some rules with SwiftSyntax, fixing some false positives and catching
more violations:anonymous_argument_in_multiline_closure
array_init
attributes
balanced_xctest_lifecycle
block_based_kvo
class_delegate_protocol
closing_brace
closure_body_length
closure_parameter_position
collection_alignment
comment_spacing
computed_accessors_order
conditional_returns_on_newline
contains_over_filter_count
contains_over_filter_is_empty
contains_over_first_not_nil
contains_over_range_nil_comparison
convenience_type
deployment_target
discarded_notification_center_observer
discouraged_assert
discouraged_direct_init
discouraged_none_name
discouraged_object_literal
discouraged_optional_boolean
duplicate_enum_cases
duplicated_key_in_dictionary_literal
dynamic_inline
empty_collection_literal
empty_count
empty_enum_arguments
empty_parameters
empty_parentheses_with_trailing_closure
empty_string
enum_case_associated_values_count
explicit_enum_raw_value
explicit_init
explicit_top_level_acl
fallthrough
file_name
first_where
flatmap_over_map_reduce
for_where
force_try
force_unwrapping
function_body_length
function_default_parameter_at_end
function_parameter_count
generic_type_name
ibinspectable_in_extension
identical_operands
implicit_getter
implicitly_unwrapped_optional
inclusive_language
inert_defer
is_disjoint
joined_default_parameter
large_tuple
last_where
legacy_cggeometry_functions
legacy_constant
legacy_constructor
legacy_hashing
legacy_multiple
legacy_nsgeometry_functions
legacy_objc_type
legacy_random
lower_acl_than_parent
multiline_arguments_brackets
multiline_parameters
multiple_closures_with_trailing_closure
no_extension_access_modifier
no_fallthrough_only
no_space_in_method_call
notification_center_detachment
nslocalizedstring_key
nslocalizedstring_require_bundle
nsobject_prefer_isequal
number_separator
object_literal
operator_whitespace
optional_enum_case_matching
orphaned_doc_comment
overridden_super_call
override_in_extension
pattern_matching_keywords
prefer_nimble
prefer_self_in_static_references
prefer_self_type_over_type_of_self
prefer_zero_over_explicit_init
prefixed_toplevel_constant
private_action
private_outlet
private_over_fileprivate
private_subject
private_unit_test
prohibited_interface_builder
prohibited_super_call
protocol_property_accessors_order
quick_discouraged_focused_test
quick_discouraged_pending_test
raw_value_for_camel_cased_codable_enum
reduce_boolean
reduce_into
redundant_discardable_let
redundant_nil_coalescing
redundant_objc_attribute
redundant_optional_initialization
redundant_set_access_control
redundant_string_enum_value
required_deinit
required_enum_case
return_arrow_whitespace
self_in_property_initialization
shorthand_operator
single_test_class
sorted_first_last
static_operator
strict_fileprivate
strong_iboutlet
switch_case_alignment
switch_case_on_newline
test_case_accessibility
toggle_bool
trailing_comma
trailing_semicolon
type_body_length
type_name
unneeded_break_in_switch
unneeded_parentheses_in_closure_argument
unowned_variable_capture
untyped_error_in_catch
unused_capture_list
unused_closure_parameter
unused_control_flow_label
unused_enumerated
unused_optional_binding
unused_setter_value
valid_ibinspectable
vertical_parameter_alignment
weak_delegate
xct_specific_matcher
xctfail_message
Marcelo Fabri
SimplyDanny
JP Simard
#2915
-
The "body length" family of rules have changed how they calculate body
line count to be significantly more correct and intuitive. However,
this is likely to require adjustments to your configuration or disable
commands to account for the changes.
JP Simard -
Add ability to filter rules for
generate-docs
subcommand.
kattouf -
Add new
excludes_trivial_init
configuration formissing_docs
rule
to exclude initializers without any parameters.
Marcelo Fabri
#4107 -
Add new
ns_number_init_as_function_reference
rule to catchNSNumber.init
andNSDecimalNumber.init
being used as function references since it
can cause the wrong initializer to be used, causing crashes. See
swiftlang/swift#51036 for more info.
Marcelo Fabri -
Add
accessibility_trait_for_button
rule to warn if a SwiftUI
View has a tap gesture added to it without having the button or
link accessibility trait.
Ryan Cole -
Add methods from SE-0348 to
UnusedDeclarationRule
.
JP Simard -
Include the configured
bind_identifier
inself_binding
violation
messages.
JP Simard -
The
self_binding
rule now catches shorthand optional bindings (for example
if let self {}
) when using abind_identifier
different thanself
.
Marcelo Fabri -
Add
library_content_provider
file type tofile_types_order
rule
to allowLibraryContentProvider
to be ordered independent frommain_type
.
dahlborn -
Add
test_parent_classes
option totest_case_accessibility
rule, which
allows detection in subclasses of XCTestCase.
Martin Redington
#4200 -
Add a new
shorthand_optional_binding
opt-in rule that triggers in Swift 5.7
when a shadowing optional binding is created in anif
orguard
statement.
SimplyDanny
#4202 -
Use SwiftSyntax instead of SourceKit to determine if a file has parser errors
before applying corrections. This speeds up corrections significantly when
none of the rules use SourceKit.
JP Simard -
Add Swift Package Build Tool Plugin with support for Swift Packages
and Xcode projects.
Johannes Ebeling
#3679
#3840 -
Make
private_unit_test
rule correctable.
SimplyDanny -
Disregard whitespace differences in
identical_operands
rule. That is, the rule
now also triggers if the left-hand side and the right-hand side of an operation
only differ in trivia.
SimplyDanny -
Print violations in realtime if
--progress
and--output
are both set.
JP Simard -
Trigger
prefer_self_in_static_references
rule on more type references like:- Key paths (e.g.
\MyType.myVar
->\Self.myVar
) - Computed properties (e.g.
var i: Int { MyType.myVar )
->var i: Int { Self.myVar }
) - Constructor calls (e.g.
MyType()
->Self()
)
- Key paths (e.g.
-
Update
for_where
rule, adding a new configuration
allow_for_as_filter
to allow usingfor in
with a singleif
inside
when there's areturn
statement inside theif
's body.
Marcelo Fabri
#4040 -
`quick_disco...
0.50.0-rc.4: Artisanal Clothes Pegs
This is a prerelease version. It won't be published to Homebrew or CocoaPods. But there are many other ways to install:
- Downloading the attached
SwiftLint.pkg
installer and launching it - Downloading the attached
portable_swiftlint.zip
archive, extracting it and moving the binary fromportable_swiftlint/swiftlint
to/usr/local/bin
or elsewhere in yourPATH
- Using Mint:
mint install realm/[email protected]
- Cloning and building from source:
git clone https://github.com/realm/SwiftLint.git && cd SwiftLint && git checkout 0.50.0-rc.4 && make install
- Docker:
docker run -it -v `pwd`:`pwd` -w `pwd` ghcr.io/realm/swiftlint:0.50.0-rc.4
- Bazel: See instructions at the bottom
Changes from 0.49.1: 0.49.1...0.50.0-rc.4
Changes from 0.50.0-rc.3: 0.50.0-rc.3...0.50.0-rc.4
Breaking
-
SwiftLint now requires Swift 5.7 or higher to build.
JP Simard -
Exclude
weak_delegate
rule from autocorrection due to behavioral changes
leading to potential undefined behavior or bugs.
SimplyDanny
#3577 -
The
anyobject_protocol
rule is now deprecated and will be completely removed
in a future release because it is now handled by the Swift compiler.
JP Simard
Experimental
- None.
Enhancements
-
Adds
NSError
to the list of types indiscouraged_direct_init
.
jszumski
#4508 -
Fix SwiftLint support on Xcode Cloud.
JagCesar
westerlund
#4484 -
Add
no_magic_numbers
rule to avoid "Magic Numbers".
Henrik Storch
#4031 -
SwiftSyntax libraries have been updated from the previous 5.6 release and now
use the new parser written in Swift.
Swift 5.7+ features should now be parsed more accurately.
We've also measured an improvement in lint times of up to 15%.
This should also fix some deployment issues where the exact version of the
internal SwiftSyntax parser needed to be available.
If you notice any unexpected changes to lint results, please file an issue on
the SwiftLint issue tracker. We can look into it and if it's a SwiftSyntax
parser regression we can re-file it upstream.
JP Simard
#4031 -
Add ability to filter rules for
generate-docs
subcommand.
kattouf -
Add new
excludes_trivial_init
configuration formissing_docs
rule
to exclude initializers without any parameters.
Marcelo Fabri
#4107 -
Add new
ns_number_init_as_function_reference
rule to catchNSNumber.init
andNSDecimalNumber.init
being used as function references since it
can cause the wrong initializer to be used, causing crashes. See
swiftlang/swift#51036 for more info.
Marcelo Fabri -
Rewrite some rules with SwiftSyntax, fixing some false positives and catching
more violations:anonymous_argument_in_multiline_closure
array_init
attributes
block_based_kvo
class_delegate_protocol
closing_brace
closure_body_length
closure_parameter_position
collection_alignment
comment_spacing
computed_accessors_order
conditional_returns_on_newline
contains_over_filter_count
contains_over_filter_is_empty
contains_over_first_not_nil
contains_over_range_nil_comparison
convenience_type
deployment_target
discarded_notification_center_observer
discouraged_assert
discouraged_direct_init
discouraged_none_name
discouraged_object_literal
discouraged_optional_boolean
duplicate_enum_cases
duplicated_key_in_dictionary_literal
dynamic_inline
empty_collection_literal
empty_count
empty_enum_arguments
empty_parameters
empty_parentheses_with_trailing_closure
empty_string
enum_case_associated_values_count
explicit_enum_raw_value
explicit_init
explicit_top_level_acl
fallthrough
file_name
first_where
flatmap_over_map_reduce
for_where
force_try
force_unwrapping
function_body_length
function_default_parameter_at_end
function_parameter_count
generic_type_name
ibinspectable_in_extension
identical_operands
implicit_getter
implicitly_unwrapped_optional
inclusive_language
inert_defer
is_disjoint
joined_default_parameter
large_tuple
last_where
legacy_cggeometry_functions
legacy_constant
legacy_constructor
legacy_hashing
legacy_multiple
legacy_nsgeometry_functions
legacy_objc_type
legacy_random
lower_acl_than_parent
multiline_arguments_brackets
multiline_parameters
multiple_closures_with_trailing_closure
no_extension_access_modifier
no_fallthrough_only
no_space_in_method_call
notification_center_detachment
nslocalizedstring_require_bundle
nsobject_prefer_isequal
number_separator
operator_whitespace
optional_enum_case_matching
orphaned_doc_comment
overridden_super_call
override_in_extension
prefer_nimble
prefer_self_type_over_type_of_self
prefer_zero_over_explicit_init
prefixed_toplevel_constant
private_action
private_outlet
private_over_fileprivate
private_subject
private_unit_test
prohibited_interface_builder
prohibited_super_call
protocol_property_accessors_order
quick_discouraged_focused_test
quick_discouraged_pending_test
raw_value_for_camel_cased_codable_enum
reduce_boolean
reduce_into
redundant_discardable_let
redundant_nil_coalescing
redundant_objc_attribute
redundant_optional_initialization
redundant_set_access_control
redundant_string_enum_value
required_deinit
return_arrow_whitespace
self_in_property_initialization
shorthand_operator
single_test_class
sorted_first_last
static_operator
strict_fileprivate
strong_iboutlet
switch_case_alignment
switch_case_on_newline
test_case_accessibility
toggle_bool
trailing_comma
trailing_semicolon
type_body_length
type_name
unneeded_break_in_switch
unneeded_parentheses_in_closure_argument
unowned_variable_capture
untyped_error_in_catch
unused_capture_list
unused_closure_parameter
unused_control_flow_label
unused_enumerated
unused_optional_binding
unused_setter_value
valid_ibinspectable
vertical_parameter_alignment
weak_delegate
xct_specific_matcher
xctfail_message
Marcelo Fabri
SimplyDanny
JP Simard
#2915
-
The "body length" family of rules have changed how they calculate body
line count to be significantly more correct and intuitive. However,
this is likely to require adjustments to your configuration or disable
commands to account for the changes.
JP Simard -
Add
accessibility_trait_for_button
rule to warn if a SwiftUI
View has a tap gesture added to it without having the button or
link accessibility trait.
Ryan Cole -
Add methods from SE-0348 to
UnusedDeclarationRule
.
JP Simard -
Include the configured
bind_identifier
inself_binding
violation
messages.
JP Simard -
Add
library_content_provider
file type tofile_types_order
rule
to allowLibraryContentProvider
to be ordered independent frommain_type
.
dahlborn -
Add
test_parent_classes
option totest_case_accessibility
rule, which
allows detection in subclasses of XCTestCase.
Martin Redington
#4200 -
Add a new
shorthand_optional_binding
opt-in rule that triggers in Swift 5.7
when a shadowing optional binding is created in anif
orguard
statement.
SimplyDanny
#4202 -
Use SwiftSyntax instead of SourceKit to determine if a file has parser errors
before applying corrections. This speeds up corrections significantly when
none of the rules use SourceKit.
JP Simard -
Add Swift Package Build Tool Plugin with support for Swift Packages
and Xcode projects.
Johannes Ebeling
#3679
#3840 -
Make
private_unit_test
rule correctable.
SimplyDanny -
Disregard whitespace differences in
identical_operands
rule. That is, the rule
now also triggers if the left-hand side and the right-h...