Releases: realm/SwiftLint
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...
0.54.0: Macro-Economic Forces
Breaking
- SwiftLint now requires Swift 5.9 or higher to build.
SimplyDanny
JP Simard
Experimental
- None.
Enhancements
-
Add
only
configuration option totodo
rule which allows to specify
whether the rule shall trigger onTODO
s,FIXME
s or both.
gibachan
#5233 -
Make
unneeded_break_in_switch
auto correctable.
KS1019 -
Speed up
closure_parameter_position
rule when there are no violations.
Marcelo Fabri -
Rewrite
cyclomatic_complexity
rule using SwiftSyntax.
Marcelo Fabri -
Rewrite
redundant_void_return
rule using SwiftSyntax.
Also include redundant void return clauses for closures in addition to
functions. This can be disabled by configuring the rule with
include_closures: false
.
Marcelo Fabri
JP Simard -
Rewrite
discouraged_optional_collection
rule using SwiftSyntax, catching
more violations.
JP Simard -
Rewrite
duplicate_imports
rule using SwiftSyntax.
JP Simard -
Handle
viewIsAppearing
in thetype_contents_order
rule.
u-abyss
#5259 -
Rewrite
vertical_parameter_alignment_on_call
rule using SwiftSyntax, fixing
some false positives.
Marcelo Fabri
#3581 -
Rewrite
no_grouping_extension
rule using SwiftSyntax.
Marcelo Fabri
Bug Fixes
-
Fix false positive in
implicit_getter
rule when using unknown accessors.
kabiroberai
#5300 -
Fix correction of
explicit_init
rule by keeping significant trivia.
BB9z
#5289 -
Fix invalid corrections for opaque and existential optionals in
syntactic_sugar
rule.
SimplyDanny
#5277 -
Fix false positive in
unused_import
rule that triggered on
@_exported
imports which could break downstream modules if removed.
jszumski
#5242 -
Fix false positive in
unused_import
rule when using a constructor
defined in a transitive module.
jszumski
#5246
Using Bazel
With bzlmod:
// Pending BCR update
bazel_dep(name = "swiftlint", version = "0.54.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 = "3a97a7d225c6a39716c48aea88eee38df052f678bf6dad73f62c746a3d9cc10c",
url = "https://github.com/realm/SwiftLint/releases/download/0.54.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.53.0: Laundry List
Breaking
-
Hide all
Reporter
s from SwiftLint's' public interface.
SimplyDanny -
The options
inlcuded
,name
andmessage
are from now on ignored in the
configuration for theprivate_unit_test
rule. The optionregex
is still
supported but is deprecated. It's recommended to use the list
test_parent_classes
instead which accepts names of parent test classes.
SimplyDanny -
Remove support for disable and enable commands in multiline comments.
Martin Redington
#4798
Experimental
- None.
Enhancements
-
Show specific violation message for the
attributes
rule when the option
always_on_line_above
orattributes_with_arguments_always_on_line_above
is involved.
chrisngabp
5103 -
Rewrite
control_statement
rule using SwiftSyntax.
SimplyDanny -
Add new
non_overridable_class_declaration
rule that triggers onclass
function and variable declarations in final classes that are not final
themselves or private.
SimplyDanny -
The Homebrew formula for SwiftLint now also installs completion scripts for
Bash, Zsh and fish.
SimplyDanny -
Add new
private_swiftui_state_property
opt-in rule to encourage setting
SwiftUI@State
and@StateObject
properties to private.
mt00chikin
#3173 -
The
implicit_return
rule now supports the kindssubscript
and
initializer
in theincluded
configuration list.
SimplyDanny -
Add
unneeded_override
rule to remove function overrides that only
call super.
keith
5139 -
Show a rule's active YAML configuration in output of
swiftlint rules <rule>
.
SimplyDanny -
Add
invokeTest()
tooverridden_super_call
defaults.
DylanBettermannDD -
Add
--config-only
option torules
command allowing to print only the YAML
configuration of a single or all rules.
SimplyDanny -
Add
--default-config
option torules
command allowing to use default
values for configurations being printed for a single rule or all rules.
SimplyDanny -
Add
include_bare_init
option to theexplicit_init
rule.include_bare_init
encourages using named constructors over.init()
and type inference.
Martin Redington
#5203 -
Improved the reported location and reasons provided for issues
detected by theinvalid_seiftlint_command
rule.
Martin Redington
#5204 -
100 is no longer considered to be a magic number by the
no_magic_numbers
rule.
Martin Redington
#5215 -
Adds a
strict
configuration file setting, equivalent to the--strict
command line option.
Martin Redington
#5226 -
Extend
implicitly_unwrapped_optional
rule with the new mode
weak_except_iboutlets
that only checksweak
variables.
Ricky Tan
Bug Fixes
-
Respect grapheme clusters in counting the number of characters in the
collection_alignment
rule.
kishikawakatsumi
#4837 -
Fix false positive in
control_statement
rule that triggered on conditions
with trailing closures where parentheses are recommended by the compiler.
SimplyDanny
#5135 -
Fix runtime error when an excluded directory does not exist.
SimplyDanny
#5078 -
Support
switch
expressions used in expression contexts in
switch_case_alignment
rule.
SimplyDanny
#5191
#5227
#5080 -
Fix bug in
prefer_self_in_static_references
rule that triggered on
initializers of computed properties in classes when the property had an
accessor block.
SimplyDanny
#5118 -
Document
exclude_ranges
option fornumber_separator
rule.
SimplyDanny -
Rewrite
implicit_return
rule with SwiftSyntax fixing a few false positives
and false negatives in the process.
SimplyDanny
#5161 -
Make sure
severity
is configurable fortype_contents_order
rule.
SimplyDanny -
Bazel: Mark
rules_xcodeproj
as a development dependency.
Thi Doãn
JP Simard
#4737 -
Fix false negatives for the
unneeded_synthesized_initializer
rule
for nested structs in classes.
Martin Redington
#5120 -
Fix some unexpected rule enablement interactions between parent and
child configurations.
Martin Redington
#4876 -
The
no_magic_numbers
rule will not trigger for violations in an
extension, if the extended class inherits from one of the specified
test_parent_classes
, as long as the class declaration and the
extension are in the same source file.
Martin Redington
#5137 -
Fix false positive in the
ns_number_init_as_function_reference
rule
when callingNSNumber.init(value:)
directly.
Marcelo Fabri
#5172 -
The
no_magic_numbers
rule will not trigger for bitwise shift
operations.
Martin Redington
#5171 -
The
accessibility_label_for_image
rule will no longer ignore the
Image(systemName:)
constructor, as many system images do not
have good accessibility labels.
Martin Redington
#5165 -
Fix false positives for
superfluous_disable_command
rule.
Martin Redington
#4798 -
Fix false positive in the
test_case_accessibility
rule.
gibachan
#5211
Using Bazel
With bzlmod:
// Pending BCR update
bazel_dep(name = "swiftlint", version = "0.53.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 = "75839dc9e8a492a86bb585a3cda3d73b58997d7a14d02f1dba94171766bb8599",
url = "https://github.com/realm/SwiftLint/releases/download/0.53.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.52.4: Lid Switch
Breaking
- None.
Experimental
- None.
Enhancements
-
Handle static
spec
methods inquick_discouraged_call
rule. The method
type changed from an instance method to a class method in Quick 7.
SimplyDanny
#5072 -
Prettify the rule configuration presentation on the command line as well as
on the website.
SimplyDanny
Bug Fixes
-
Fix false positives for the
unneeded_synthesized_initializer
rule, when
no argument initializers had side-effects.
Martin Redington
#5075 -
Ignore
switch
expressions assigned to variables inswitch_case_alignment
rule.
SimplyDanny
#5080 -
Fix auto-correction for the
direct_return
rule, when statements have
trailing comments.
Martin Redington
#5081 -
Fix false positives for the
private_subject
rule when creating subjects
inside initializers.
kasrababaei -
Fix false positive for
prefer_self_in_static_references
when a class
inherits from another class with generic types.
kasrababaei
Using Bazel
With bzlmod:
// Pending BCR update: https://github.com/bazelbuild/bazel-central-registry/pull/750
bazel_dep(name = "swiftlint", version = "0.52.4", 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 = "c6ea58b9c72082cdc1ada4a2d48273ecc355896ed72204cedcc586b6ccb8aca6",
url = "https://github.com/realm/SwiftLint/releases/download/0.52.4/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.3: Duplicate Hampers
Breaking
- None.
Experimental
- None.
Enhancements
-
Make severity for unallowed symbols configurable. The option name is
unallowed_symbols_severity
. It accepts the two valueswarning
anderror
(default) as usual.
SimplyDanny -
Mention a rule's identifier in the console message that is printed when the
rule's associated configuration entry contains invalid values.
SimplyDanny -
Silence
xct_specific_matcher
rule on "one argument asserts" if there are
potential types or tuples involved in the comparison as types and tuples do
not conform toEquatable
.
SimplyDanny
#4990 -
Add
grouping
option to thesorted_imports
rule allowing
to sort groups of imports defined by their preceding attributes
(e.g.@testable
,@_exported
, ...).
hiltonc -
Add new
--silence-deprecation-warnings
flag that silences deprecation
warnings that would otherwise be printed to the console.
SimplyDanny
#4989 -
Do not trigger
redundant_self_in_closure
rule when another idenfierx
in
scope shadows the field accessed byself.x
to avoid semantical changes.
SimplyDanny
#5010 -
Rewrite
todo
rule with SwiftSyntax.
woxtu -
Adds an
unneeded_synthesized_initializer
rule, based on
swift-format
'sUseSynthesizedInitializer
rule, which warns
when a defined default or memberwise initializer would have been
automatically synthesized.
Martin Redington
Bug Fixes
-
The option
validates_start_with_lowercase
can now be disabled by setting it
tooff
.
SimplyDanny
#5036 -
Do not trigger
prefer_self_in_static_references
rule ontypealias
declarations in classes.
SimplyDanny
#5009 -
Do not trigger
prefer_self_in_static_references
rule on collection types in
classes, but on initializers like[C]()
in all types.
SimplyDanny
#5042 -
Fix false positives on
redundant_objc_attribute
rule for enums
and private members.
Martin Redington
#4633 -
Fix autocorrect for
CGIntersectionRect
inlegacy_cggeometry_functions
rule.
Haoocen
#5023 -
Fix false positives on
sorted_first_last
rule whenfirst
/last
have
a predicate.
woxtu
#3023 -
Work around dyld warning about duplicate SwiftSyntax classes with Xcode 15
betas.
keith
JP Simard
#4782
Using Bazel
With bzlmod:
bazel_dep(name = "swiftlint", version = "0.52.3", 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 = "20c09504184d2496a4b40bc6f77a03d443fe4ba79b4bbbab61382bc5241d24aa",
url = "https://github.com/realm/SwiftLint/releases/download/0.52.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 @SwiftLint//:swiftlint -- --help
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