Releases: realm/SwiftLint
0.28.0: EcoBoost
Breaking
- Completely remove the
--use-tabs
option of theautocorrect
command that
was deprecated in 0.24.1. In its place, define anindentation
key in your
configuration files.
JP Simard
Experimental
-
Add a new
swiftlint analyze
command which can lint Swift files using the
full type-checked AST. Rules of theAnalyzerRule
type will be added over
time. The compiler log path containing the cleanswiftc
build command
invocation (incremental builds will fail) must be passed toanalyze
via
the--compiler-log-path
flag.
e.g.--compiler-log-path /path/to/xcodebuild.log
JP Simard -
Add an
explicit_self
analyzer rule to enforce the use of explicit references
toself.
when accessing instance variables or functions.
JP Simard
#321 -
Add an
unused_import
analyzer rule to lint for unnecessary imports.
JP Simard
#2248 -
Add an
unused_private_declaration
analyzer rule to lint for unused private
declarations.
JP Simard
Enhancements
-
Add
legacy_random
opt-in rule to encourage the use of.random(in:)
instead ofarc4random
,arc4random_uniform
, anddrand48
.
Joshua Kaplan -
Improve performance of
line_length
and
multiple_closures_with_trailing_closure
rules.
Marcelo Fabri -
Add
closure_body_length
opt-in rule to enforce the maximum number
of lines a closure should have. Requires Swift 4.2.
Ornithologist Coder
#52 -
Add SonarQube reporter.
Yusuke Ohashi
#2350 -
Add
prohibited_interface_builder
opt-in rule to validate that@IBOutlet
s
and@IBAction
s are not used.
Marcelo Fabri
#2365 -
Add
inert_defer
rule to validate thatdefer
is not used at the end of a
scope.
Marcelo Fabri
#2123 -
Add
toggle_bool
opt-in rule which suggests usingsomeBool.toggle()
over
someBool = !someBool
. Requires Swift 4.2.
Dalton Claybrook
#2369 -
Add
identical_operands
opt-in rule to validate that operands are different
expressions in comparisons.
Marcelo Fabri
#1371 -
Add
collection_alignment
opt-in rule to validate that all elements in a
collection literal are aligned vertically.
Dalton Claybrook
#2326 -
Add
static_operator
opt-in rule to enforce that operators are declared as
static functions instead of free functions.
Marcelo Fabri
#2395 -
Specify what type of compiler protocol initializer violated the
compiler_protocol_init
rule.
Timofey Solonin
#2422
Bug Fixes
-
Fix
comma
rule false positives on object literals (for example, images).
Marcelo Fabri
#2345 -
Fix false positive on
file_name
rule when using nested types.
Marcelo Fabri
#2325 -
Fix crash on
multiline_function_chains
rule when using some special
characters inside the function calls.
Marcelo Fabri
#2360 -
Change
autocorrect --format
to run format before autocorrect, fixing
conflicts between default indentation and rules which modify indentation
(i.e.closure_end_indentation
).
Ornithologist Coder
#2374 -
Fix false positive on
empty_count
rule when assessing binary, octal and
hexadecimal integer literals.
Timofey Solonin
#2423
0.27.0: Heavy Duty
Breaking
- None.
Enhancements
-
Append
modifier_order
description with failure reason.
Daniel Metzing
#2269 -
Decrease default severity of
superfluous_disable_command
towarning
.
Frederick Pietschmann
#2250 -
Don't touch files when running
autocorrect --format
if the contents haven't
changed.
Marcelo Fabri
#2249 -
Add
only_enforce_after_first_closure_on_first_line
configuration
tomultiline_arguments
Mike Ciesielka
#1896 -
Add
anyobject_protocol
opt-in rule which suggests usingAnyObject
over
class
for class-only protocols.
Ornithologist Coder
#2283 -
Add options
prefix_pattern
andsuffix_pattern
to rulefile_name
.
Cihat Gündüz
#2309 -
Add new bool config option
if_only
to ruleconditional_returns_on_newline
to specify that the rule should only be applied toif
statements.
Cihat Gündüz
#2307 -
Add support for globs in
excluded
file paths.
Keith Smiley
#2316 -
Add
only_private
configuration toprefixed_toplevel_constant
rule.
Keith Smiley
#2315 -
Make rule
explicit_type_interface
compatible with rule
redundant_type_annotation
via new optionallow_redundancy
.
Cihat Gündüz
#2312 -
Add
missing_docs
rule to warn against undocumented declarations.
Nef10
Andrés Cecilia Luque
#1652
Bug Fixes
-
Fix an issue with
control_statement
where commas in clauses prevented the
rule from applying.
Allen Wu -
Fix
explicit_enum_raw_value
,generic_type_name
,implicit_return
,
required_enum_case
,quick_discouraged_call
,array_init
,
closure_parameter_position
andunused_closure_parameter
rules
when linting with Swift 4.2.
Marcelo Fabri -
Fix
identifier_name
rule false positives withenum
when linting
using Swift 4.2.
Marcelo Fabri
Jacob Greenfield
#2231 -
Fix a crash when running with Swift 4.2.
Norio Nomura
SR-7954 -
Fix false positive on
attributes
rule when linting a line that is below
a line with a declaration that has attributes.
Marcelo Fabri
#2297 -
redundant_optional_initialization
rule now lints local variables.
Marcelo Fabri
#2233 -
Fix autocorrection for
redundant_type_annotation
rule.
Marcelo Fabri
#2314
0.26.0: Maytagged Pointers
Breaking
-
SwiftLint now requires Swift 4.0 or higher to build.
JP Simard -
The
fallthrough
rule is now opt-in.
Marcelo Fabri
#1892
Enhancements
-
Add optional filename verification to the
file_header
rule.
All occurrences in the pattern of theSWIFTLINT_CURRENT_FILENAME
placeholder are replaced by the name of the validated file.
Anders Hasselqvist
#1079 -
Updates the
untyped_error_in_catch
rule to support autocorrection.
Daniel Metzing -
Add
no_fallthrough_only
rule to check thatcase
statements do not
contain only afallthrough
.
Austin Belknap -
Add
indented_cases
support toswitch_case_alignment
rule.
Shai Mishali
#2119 -
Add opt-in
modifier_order
to enforce the order of declaration modifiers.
Requires Swift 4.1 or later.
Jose Cheyo Jimenez
Daniel Metzing
#1472
#1585 -
Validate implicit
subscript
getter inimplicit_getter
rule when using
Swift 4.1 or later.
Marcelo Fabri
#898 -
Add
unavailable_function
opt-in rule to validate that functions that are
currently unimplemented (using a placeholderfatalError
) are marked with
@available(*, unavailable)
.
Marcelo Fabri
#2127 -
Updates the
closure_end_indentation
rule to support autocorrection.
Eric Horacek -
Updates the
literal_expression_end_indentation
rule to support
autocorrection.
Eric Horacek -
Add a new
multiline_function_chains
rule to validate that chained function
calls start either on the same line or one per line.
Eric Horacek
#2214 -
Improves the
mark
rule's autocorrection.
Eric Horacek -
Add
redundant_set_access_control
rule to warn against using redundant
setter ACLs on variable declarations.
Marcelo Fabri
#1869 -
Add a new
ignores_interpolated_strings
config parameter to theline_length
rule to ignore lines that include interpolated strings from this rule.
Michael Gray
#2100 -
Add a new
ignores_default_parameters
config parameter to the
function_parameter_count
rule to ignore default parameter when calculating
parameter count. True by default.
Varun P M
#2171 -
Add
empty_xctest_method
opt-in rule which warns against empty
XCTest methods.
Ornithologist Coder
#2190 -
Add
function_default_parameter_at_end
opt-in rule to validate that
parameters with defaults are located toward the end of the parameter list in a
function declaration.
Marcelo Fabri
#2176 -
Add
file_name
opt-in rule validating that file names contain the name of a
type or extension declared in the file (if any).
JP Simard
#1420 -
Add
convenience_type
opt-in rule to validate that types hosting only static
members should be enums to avoid instantiation.
Marcelo Fabri
#1871
Bug Fixes
-
Update
LowerACLThanParent
rule to not lint extensions.
Keith Smiley
#2164 -
Fix operator usage spacing nested generics false positive.
Eric Horacek
#1341
#1897 -
Fix autocorrection for several rules
(empty_parentheses_with_trailing_closure
,explicit_init
,
joined_default_parameter
,redundant_optional_initialization
and
unused_closure_parameter
) when used with preprocessor macros.
John Szumski
Marcelo Fabri -
Fix
unneeded_parentheses_in_closure_argument
false negatives when multiple
violations are nested.
Marcelo Fabri
#2188 -
Fix false negatives in
implicit_return
rule when using closures as
function arguments.
Marcelo Fabri
#2187 -
Fix false positives in
attributes
rule when@testable
is used.
Marcelo Fabri
#2211 -
Fix false positives in
prohibited_super_call
rule.
Marcelo Fabri
#2212 -
Fix a false positive in
unused_closure_parameter
rule when a parameter
is used in a string interpolation.
Marcelo Fabri
#2062 -
Fixes a case where the
closure_end_indentation
rule wouldn't lint the end
indentation of non-trailing closure parameters.
Eric Horacek
#2121
0.25.1: Lid Locked
This is the last release to support building with Swift 3.2 and Swift 3.3.
The next release will require Swift 4.0 or higher to build.
Breaking
- None.
Enhancements
-
Add
LowerACLThanParent
rule.
Keith Smiley
#2136 -
Add
UIOffsetMake
tolegacy_constructor
rule.
Nealon Young
#2126 -
Add a new
excluded
config parameter to theexplicit_type_interface
rule
to exempt certain types of variables from the rule.
Rounak Jain
#2028 -
Add
empty_string
opt-in rule to validate against comparing strings to""
instead of using.isEmpty
.
Davide Sibilio -
Add
untyped_error_in_catch
opt-in rule to warn against declaring errors
without an explicit type in catch statements instead of using the implicit
error
variable.
Daniel Metzing
#2045 -
Add
all
keyword for use in disable / enable statement:
// swiftlint:disable all
.
It allows disabling SwiftLint entirely, in-code, for a particular section.
fredpi
#2071 -
Adds
--force-exclude
option tolint
andautocorrect
commands, which will
force SwiftLint to exclude files specified in the configexcluded
even if
they are explicitly specified with--path
.
Ash Furrow
#2051 -
Adds
discouraged_optional_collection
opt-in rule to encourage the use of
empty collections instead of optional collections.
Ornithologist Coder
#1885 -
Add 4.1.0, 4.1.1 and 4.2.0 to Swift version detection.
Norio Nomura
#2143 -
Support building with Swift 4.1.
Norio Nomura
#2038
Bug Fixes
-
Fixes an issue with the
yoda_condition
rule where the severity would always
display as a warning, and the reason would display as the severity type.
Twig -
Fix TODOs lint message to state that TODOs should be resolved instead of
avoided.
Adonis Peralta
#150 -
Fix some cases where
colon
rule wouldn't autocorrect dictionary literals.
Marcelo Fabri
#2050 -
Fix linux crash on sources with surrogate pair emojis as variable names.
Cyril Lashkevich -
Make
legacy_constructor
rule more reliable, especially for autocorrecting.
Marcelo Fabri
#2098 -
Fix
colon
rule autocorrect when preprocessor macros are present.
Marcelo Fabri
#2099 -
Fix crash when saving cache if there're entries referring to the same path
but with different capitalization.
Marcelo Fabri
#2032 -
Fix several rules (
empty_enum_arguments
,explicit_init
empty_parentheses_with_trailing_closure
,joined_default_parameter
,
redundant_optional_initialization
,redundant_void_return
and
unused_closure_parameter
) rules autocorrection inside functions or other
declarations.
Marcelo Fabri -
Fix
redundant_void_return
rule autocorrect when preprocessor macros are
present.
John Szumski
#2115 -
Fix issue where the autocorrect done message used the plural form of "files"
even if only 1 file changed.
John Szumski -
Fix false positives in
attributes
rule when using Swift 4.1.
Marcelo Fabri
#2125
#2141
0.25.0: Cleaning the Lint Filter
Breaking
- None.
Enhancements
- Adds
discouraged_optional_boolean
opt-in rule to discourage
the use of optional booleans.
Ornithologist Coder
#2011
Bug Fixes
-
Fix some cases where
colon
rule wouldn't be autocorrected.
Manabu Nakazawa -
Fix false positives in
explicit_acl
rule when declaring functions and
properties in protocols or implementingdeinit
.
Marcelo Fabri
#2014 -
Fix false negatives in
unneeded_parentheses_in_closure_argument
rule
when using_
as one of the closure arguments.
Marcelo Fabri
#2017 -
Fix several rules that use attributes when linting with a Swift 4.1 toolchain.
Marcelo Fabri
#2019 -
Don't trigger violations in
let_var_whitespace
rule when using local
variables when linting with a Swift 4.1 toolchain.
Marcelo Fabri
#2021 -
Improve
type_name
rule violations to be positioned on the type name.
Marcelo Fabri
#2021 -
Use SourceKit to validate
associatedtype
andtypealias
intype_name
rule
when linting with Swift 4.1.
Marcelo Fabri
#2021 -
Fix some cases where violations would still be triggered when using the
ignores_function_declarations
configuration ofline_length
rule.
Manabu Nakazawa -
Fix false positive in
empty_enum_arguments
rule when using closures.
Marcelo Fabri
#2041 -
Fix false positives in
force_unwrapping
rule when declaring functions that
return implicitly unwrapped collections (for example[Int]!
or
[AnyHashable: Any]!
).
Marcelo Fabri
#2042 -
Fix directories with a
.swift
suffix being treated as files.
Jamie Edge
#1948
0.24.2: Dented Tumbler
Breaking
- None.
Enhancements
- None.
Bug Fixes
0.24.1: Dented Tumbler
Breaking
- None.
Enhancements
-
Invalidate cache when Swift patch version changes.
Norio Nomura -
Add
private_action
opt-in rule which warns against public
@IBAction methods.
Ornithologist Coder
#1931 -
Add
yoda_condition
opt-in rule which warns when Yoda conditions are used.
That is, when the constant portion of the expression is on the left side of a
conditional statement.
Daniel Metzing
#1924 -
Indentation can now be specified via a configuration file.
Noah McCann
RubenSandwich
#319 -
Add
required_enum_case
opt-in rule which allows enums that
conform to protocols to require one or more cases. Useful for
result enums.
Donald Ritter -
Add
discouraged_object_literal
opt-in rule which encourages initializers
over object literals.
Ornithologist Coder
#1987 -
Adds
prefixed_toplevel_constant
opt-in rule which encourages top-level
constants to be prefixed byk
.
Ornithologist Coder
#1907 -
Added
explicit_acl
opt-in rule to enforce explicit access control levels.
Josep Rodriguez
#1822
Bug Fixes
-
Fix false positives in
control_statement
rule when methods with keyword
names are used.
Marcelo Fabri
#1946 -
Fix false positives in
for_where
rule when pattern matching (if case
)
is used.
Marcelo Fabri
#1968 -
Fix false positives in
unused_closure_parameter
rule when closure is wrapped
in parentheses.
JP Simard
#1979
0.24.0: Timed Dry
Breaking
-
SwiftLint now requires Xcode 9 and Swift 3.2+ to build.
Marcelo Fabri -
Remove
SwiftExpressionKind.other
.
Marcelo Fabri
Enhancements
-
Add
sorted_first_last
opt-in rule to encourage usingmin()
ormax()
oversorted().first
orsorted().last
.
Tom Quist
#1932 -
Add
quick_discouraged_focused_test
opt-in rule which warns against
focused tests in Quick tests.
Ornithologist Coder
#1905 -
Add
override_in_extension
opt-in rule that warns against overriding
declarations in anextension
.
Marcelo Fabri
#1884 -
Add
[f,x]{describe, context, itBehavesLike}
toquick_discouraged_call
rule.
Ornithologist Coder
#1903 -
Add
quick_discouraged_pending_test
opt-in rule which warns against
pending tests in Quick tests.
Ornithologist Coder
#1909 -
Speed up equality tests for
[Rule]
andConfiguration
values.
JP Simard -
Make
Configuration
conform toHashable
.
JP Simard -
Speed up reading cached results by about 200%.
JP Simard -
Add
catch
to the statements checked by thecontrol_statement
rule.
JP Simard -
Make
sorted_imports
correctable.
Samuel Susla
JP Simard
#1822 -
Make
sorted_imports
only validate within "groups" of imports on directly
adjacent lines.
Samuel Susla
JP Simard
#1822
Bug Fixes
-
Extend
first_where
andcontains_over_first_not_nil
rules to also detect
cases where calls tofilter
andfirst
are parenthesized.
Tom Quist -
Correct equality tests for
Configuration
values. They previously didn't
account forwarningThreshold
orcachePath
.
JP Simard -
Fix false positive in
multiline_parameters
rule when parameter is a closure
with default value.
Ornithologist Coder
#1912 -
Fix caching on Linux.
JP Simard -
Fix crashes due to races.
JP Simard -
Fix
String.characters
deprecation warnings when compiling with Swift
4.0.2.
JP Simard
0.24.1: Dented Tumbler
Breaking
- None.
Enhancements
-
Invalidate cache when Swift patch version changes.
Norio Nomura -
Add
private_action
opt-in rule which warns against public
@IBAction methods.
Ornithologist Coder
#1931 -
Add
yoda_condition
opt-in rule which warns when Yoda conditions are used.
That is, when the constant portion of the expression is on the left side of a
conditional statement.
Daniel Metzing
#1924 -
Indentation can now be specified via a configuration file.
Noah McCann
RubenSandwich
#319 -
Add
required_enum_case
opt-in rule which allows enums that
conform to protocols to require one or more cases. Useful for
result enums.
Donald Ritter -
Add
discouraged_object_literal
opt-in rule which encourages initializers
over object literals.
Ornithologist Coder
#1987 -
Adds
prefixed_toplevel_constant
opt-in rule which encourages top-level
constants to be prefixed byk
.
Ornithologist Coder
#1907 -
Added
explicit_acl
opt-in rule to enforce explicit access control levels.
Josep Rodriguez
#1822
Bug Fixes
-
Fix false positives in
control_statement
rule when methods with keyword
names are used.
Marcelo Fabri
#1946 -
Fix false positives in
for_where
rule when pattern matching (if case
)
is used.
Marcelo Fabri
#1968 -
Fix false positives in
unused_closure_parameter
rule when closure is wrapped
in parentheses.
JP Simard
#1979
0.24.0: Timed Dry
Breaking
-
SwiftLint now requires Xcode 9 and Swift 3.2+ to build.
Marcelo Fabri -
Remove
SwiftExpressionKind.other
.
Marcelo Fabri
Enhancements
-
Add
sorted_first_last
opt-in rule to encourage usingmin()
ormax()
oversorted().first
orsorted().last
.
Tom Quist
#1932 -
Add
quick_discouraged_focused_test
opt-in rule which warns against
focused tests in Quick tests.
Ornithologist Coder
#1905 -
Add
override_in_extension
opt-in rule that warns against overriding
declarations in anextension
.
Marcelo Fabri
#1884 -
Add
[f,x]{describe, context, itBehavesLike}
toquick_discouraged_call
rule.
Ornithologist Coder
#1903 -
Add
quick_discouraged_pending_test
opt-in rule which warns against
pending tests in Quick tests.
Ornithologist Coder
#1909 -
Speed up equality tests for
[Rule]
andConfiguration
values.
JP Simard -
Make
Configuration
conform toHashable
.
JP Simard -
Speed up reading cached results by about 200%.
JP Simard -
Add
catch
to the statements checked by thecontrol_statement
rule.
JP Simard -
Make
sorted_imports
correctable.
Samuel Susla
JP Simard
#1822 -
Make
sorted_imports
only validate within "groups" of imports on directly
adjacent lines.
Samuel Susla
JP Simard
#1822
Bug Fixes
-
Extend
first_where
andcontains_over_first_not_nil
rules to also detect
cases where calls tofilter
andfirst
are parenthesized.
Tom Quist -
Correct equality tests for
Configuration
values. They previously didn't
account forwarningThreshold
orcachePath
.
JP Simard -
Fix false positive in
multiline_parameters
rule when parameter is a closure
with default value.
Ornithologist Coder
#1912 -
Fix caching on Linux.
JP Simard -
Fix crashes due to races.
JP Simard -
Fix
String.characters
deprecation warnings when compiling with Swift
4.0.2.
JP Simard
0.23.1: Rewash: Forgotten Load Edition
Breaking
- None.
Enhancements
- None.
Bug Fixes
-
Fix false positive in
array_init
rule when using amap
that
doesn't take a closure.
Marcelo Fabri
#1878 -
superfluous_disable_command
rule can now be disabled as expected when
using// swiftlint:disable superfluous_disable_command
.
Marcelo Fabri
#1890
0.23.0: Permanent Press Cycle
Breaking
- None.
Enhancements
-
Fix csv reporter to output records with new lines.
atetlaw -
Add
contains_over_first_not_nil
rule to encourage usingcontains
over
first(where:) != nil
.
Samuel Susla
#1514 -
Add
fallthrough
rule that flags usage offallthrough
.
Marcelo Fabri
#1834 -
Improve
colon
rule to catch violations in dictionary types
(e.g.[String: Int]
), when usingAny
and on function calls.
Marcelo Fabri
#1074
#1389 -
Add
switch_case_alignment
rule to validate thatcase
anddefault
statements are vertically aligned with their enclosingswitch
statement.
Austin Lu -
Add
array_init
opt-in rule to validate thatArray(foo)
should be preferred
overfoo.map({ $0 })
.
Marcelo Fabri
#1271 -
Truncate long configuration console descriptions to fit in the console window
when runningswiftlint rules
.
JP Simard
#1002 -
Add
multiline_arguments
opt-in rule that warns to either keep
all the arguments of a function call on the same line,
or one per line.
Marcel Jackwerth -
Add
unneeded_break_in_switch
rule to validate that no extrabreak
s are
added inswitch
statements.
Marcelo Fabri
#1870 -
Add
literal_expression_end_indentation
opt-in rule to validate that
array and dictionary literals ends have the same indentation as the line
that started them.
Marcelo Fabri
#1435
Bug Fixes
-
Improve how
opening_brace
rule reports violations locations.
Marcelo Fabri
#1811 -
Fix false negatives in
unneeded_parentheses_in_closure_argument
rule
when using capture lists.
Marcelo Fabri
#1817 -
Fix handling of attributes (
lazy
,objc
, etc.) for thelet_var_whitespace
rule.
David Catmull
#1770
#1812 -
Fix false positives in
for_where
rule when usingif var
insidefor
.
Marcelo Fabri
#1838 -
Fix false positive in
class_delegate_protocol
rule when using Swift 4.0.1.
Marcelo Fabri
#1856 -
Print multi-line configuration values in a single line when running
swiftlint rules
to avoid breaking the table format.
JP Simard
#1002 -
Ignore SwiftLint commands (
swiftlint:(disable|enable)
) infile_header
rule, making it work better withsuperfluous_disable_command
rule.
Marcelo Fabri
#1810 -
Fix false negatives in
generic_type_name
,identifier_name
andtype_name
rules when usingallowed_symbols
.
Marcelo Fabri