Changelog History
Page 1
-
v0.50.1 Changes
๐ฅ 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 #4560Fix false positives in
lower_acl_than_parent
when the nominal parent is an extension.
Steffen Matthischke #4564Fix
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 #4585Fix 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
-
v0.50.0 Changes
๐ฅ Breaking
๐ SwiftLint now requires Swift 5.7 or higher to build.
JP SimardExclude
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 #4031Rewrite 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.
kattoufAdd new
excludes_trivial_init
configuration formissing_docs
rule to exclude initializers without any parameters.
Marcelo Fabri #4107Add 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 https://github.com/apple/swift/issues/51036 for more info.
Marcelo FabriAdd
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 SimardInclude the configured
bind_identifier
inself_binding
violation messages.
JP SimardThe
self_binding
rule now catches shorthand optional bindings (for exampleif let self {}
) when using abind_identifier
different thanself
.
Marcelo FabriAdd
library_content_provider
file type tofile_types_order
rule to allowLibraryContentProvider
to be ordered independent frommain_type
.
dahlbornAdd
test_parent_classes
option totest_case_accessibility
rule, which allows detection in subclasses of XCTestCase.
Martin Redington #4200Add 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 #3840Make
private_unit_test
rule correctable.
SimplyDannyDisregard 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 SimardTrigger
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 configurationallow_for_as_filter
to allow usingfor in
with a singleif
inside when there's areturn
statement inside theif
's body.
Marcelo Fabri #4040quick_discouraged_call
,quick_discouraged_focused_test
andquick_discouraged_pending_test
rules now trigger on subclasses ofQuickSpec
. Marcelo Fabri #44200๏ธโฃ The
type_name
rule now validates protocol declarations by default. You can opt-out by using thevalidate_protocols
key in your configuration:type_name: validate_protocols: false
Report how much memory was used when
--benchmark
is specified.
JP SimardAdds
NSError
to the list of types indiscouraged_direct_init
.
jszumski #4508๐ Fix SwiftLint support on Xcode Cloud.
JagCesar westerlund #4484Add
no_magic_numbers
rule to avoid "Magic Numbers".
Henrik Storch #4031Add new option
only_enforce_before_trivial_lines
tovertical_whitespace_closing_braces
rule. It restricts the rule to apply only before trivial lines (containing only closing braces, brackets and parentheses). This allows empty lines before non-trivial lines of code (e.g. if-else-statements).
benjamin-kramer #3940
๐ Bug Fixes
Respect
validates_start_with_lowercase
option when linting function names.
Chris Brakebill #2708Do not report variables annotated with
@NSApplicationDelegateAdaptor
and@WKExtensionDelegateAdaptor
inweak_delegate
rule.
Till Hainbach #3598 #3611๐ Fix false-positives related to the
willMove
lifecycle method intype_contents_order
rule.
SimplyDanny #3478Do no longer autocorrect usage of
NSIntersectionRect
inlegacy_nsgeometry_functions
rule.
SimplyDanny #3703๐ Fix Analyzer rules in Xcode 14.
SimplyDanny #4208โ Add column for SourceKit usage to
rules
command.
JP SimardMake
nsobject_prefer_isequal
rule work for nested@objc
classes. Also consider the@objcMembers
annotation.
SimplyDanny๐จ Print fixed content at most once to STDOUT.
SimplyDanny #4211๐ Fix fatal error when content given via STDIN is corrected in the
trailing_newline
rule.
SimplyDanny #4234Fix false-positives from
multiline_arguments_brackets
when a function call has a single line trailing closure.
CraigSiemens #4510
-
v0.49.1 Changes
๐ Note: The default branch for the SwiftLint git repository was renamed from โก๏ธ
master
tomain
on September 1st. Please update any code or automation accordingly.๐ฅ Breaking
- None.
Experimental
- None.
โจ Enhancements
โ Add new
self_binding
opt-in rule to enforce thatself
identifiers are consistently re-bound to a common identifier name. Configurebind_identifier
to the name you want to use. Defaults toself
.
JP Simard #2495โ Add
--output
option to lint and analyze commands to write to a file instead of to stdout.
JP Simard #4048โ Add
--progress
flag to lint and analyze commands to show a live-updating progress bar instead of each file being processed.
JP Simard๐จ
--fix
now works with--use-stdin
, printing the output to to STDOUT instead of crashing.
SimplyDanny #4127
๐ Bug Fixes
โ Migrate
empty_xctest_method
rule to SwiftSyntax fixing some false positives.
SimplyDanny #3647 #3691Fix false positives in
redundant_discardable_let
when usingasync let
.
Martin Hosna #4142๐จ Consistently print error/info messages to stderr instead of stdout, which wasn't being done for errors regarding remote configurations.
JP Simard
-
v0.49.0 Changes
๐ Note: The default branch for the SwiftLint git repository will be renamed from โก๏ธ
master
tomain
on September 1st. Please update any code or automation accordingly.๐ฅ Breaking
๐ SwiftLint now requires Swift 5.6 or higher to build, and macOS 12 or higher to run.
JP Simard๐จ Code Climate reports now use SHA256 strings as the issue fingerprint values.
JP Simard๐ Make
comma_inheritance
an opt-in rule.
Steve Madsen #4027๐ The
autocorrect
command that was deprecated in 0.43.0 has now been completely removed. Use--fix
instead.
JP Simardโ Remove the
AutomaticTestableRule
protocol. All examples listed in rules are now tested automatically to make sure they are correct.
SimplyDanny๐ Deprecate the
--in-process-sourcekit
command line flag. SwiftLint now always uses an in-process SourceKit.
JP Simard
Experimental
- None.
โจ Enhancements
Make
duplicate_imports
rule correctable. Fixduplicate_imports
rule reporting redundant violations when more than one duplicate is present.
Timofey Solonin๐ Support for building SwiftLint with bazel.
JP Simard๐ Support for writing custom private native rules when building with bazel.
JP Simard Keith Smiley #3516๐ Make
comma
rule about 10x faster, finding some previously missed cases and fixing some previously wrong corrections.
JP Simard๐ Make
colon
rule about 7x faster, finding some previously missed cases.
JP Simard๐ Make
closure_spacing
rule about 9x faster, finding some previously missed cases and fixing some previously wrong corrections.
JP Simard SimplyDanny #4090Introduce new configuration option
include_compiler_directives
(true
by default) for theindentation_width
rule that allows to ignore compiler directives in the indentation analysis. This is especially useful if one (or a formatter) prefers to have compiler directives always at the very beginning of a line.
SimplyDanny #4030Enable (recursive) globs in
included
file paths.
sarastro-nlCustom rules are now broken down per rule instead of in aggregate in
--benchmark
.
JP Simard๐จ The
version
command now has an optional--verbose
flag that prints out the full version info, notably the build ID, which can be used to determine if twoswiftlint
executables are identical.
JP SimardUpdate documentation for
multiline_arguments_brackets
andmultiline_literal_brackets
to make it immediately obvious that common examples will trigger.
chrisjf #4060๐ The
--compile-commands
argument can now parse SwiftPM yaml files produced when runningswift build
at.build/{debug,release}.yaml
.
JP SimardAdd new configuration option
allowed_no_space_operators
tooperator_usage_whitespace
rule. It allows to specify custom operators which shall not be considered by the rule.
imben123โ Add new protocols to remove some boilerplate involved in writing SwiftSyntax-based rules.
JP Simard
๐ Bug Fixes
Fix false positive in
self_in_property_initialization
rule when using closures insidedidSet
and other accessors.
Marcelo Fabri #4041๐ Fix false positive in
Duplicated Key in Dictionary Literal Violation
rule when using keys that are generated at runtime with the same source code.
OrEliyahu #4012๐ Fix false positive in
yoda_condition
rule by basing it on SwiftSyntax.
SimplyDanny #4081๐ Fix false negatives in
first_where
rule when filtering array of dictionaries with String keys.
KS1019๐ Fix broken correction for
explicit_init
rule.
KS1019
-
v0.48.0 Changes
๐ This is the last release to support building with Swift 5.5.x and running on ๐ macOS < 12.
๐ฅ Breaking
- ๐ Deprecate the
--path
options forlint
/analyze
commands. Prefer the positional paths that can be added last to both commands.
SimplyDanny
Experimental
- None.
โจ Enhancements
๐ Support
iOSApplicationExtension
,macOSApplicationExtension
,watchOSApplicationExtension
, andtvOSApplicationExtension
identifiers in thedeployment_target
rule. To configure the rule for these identifiers, you need to use the keysiOSApplicationExtension_deployment_target
,macOSApplicationExtension_deployment_target
,watchOSApplicationExtension_deployment_target
, andtvOSApplicationExtension_deployment_target
. Extentions default to their counterparts unless they are explicitly defined.
tahabebek #4004Rewrite
operator_usage_whitespace
rule using SwiftSyntax, fixing false positives and false negatives.
Note that this rule doesn't catch violations around return arrows (->
) anymore - they are already handled byreturn_arrow_whitespace
.
Marcelo Fabri #3965 #3668 #2728๐ Support arrays for the
included
andexcluded
options when defining a custom rule.
Marcelo FabriAdd back
void_function_in_ternary
opt-in rule to warn against using a ternary operator to callVoid
functions.
Marcelo FabriSupport
UIEdgeInsets
type inprefer_zero_over_explicit_init
rule.
KokiHirokawa #3986
๐ Bug Fixes
Ignore array types in
syntactic_sugar
rule if their associatedIndex
is accessed.
SimplyDanny #3502Prevent crash for private types named
_
intype_name
rules. sinoru #3971๐ Make
for_where
rule implementation independent of order in structure dictionary. This fixes the rule in Xcode 13.3 where some violation were no longer reported.
SimplyDanny #3975โก๏ธ Update result builder methods in
unused_declaration
rule fixing some false-positives.
SimplyDannyLook for call expressions which are not wrapped into an argument when checking for nested (possibly multiline) arguments fixing some false-negatives in (at least) Xcode 13.2.
SimplyDanny #3975๐ Make sure that include paths prefixed with the name of the original path are included in the analysis.
SimplyDanny #3705Do not trigger
unavailable_condition
rule if other#(un)available
checks are involved.
SimplyDanny #3985โก๏ธ Update
nimble_operator
to support the operators forbeNil()
.
CraigSiemensAvoid false-positive in
let_var_whitespace
rule by allowing custom attributes on lines directly before let/var declarations.
SimplyDanny #2980
- ๐ Deprecate the
-
v0.47.1 Changes
๐ฅ Breaking
- None.
Experimental
- None.
โจ Enhancements
Add new option
only_enforce_before_trivial_lines
tovertical_whitespace_closing_braces
rule. It restricts the rule to apply only before trivial lines (containing only closing braces, brackets and parentheses). This allows empty lines before non-trivial lines of code (e.g. if-else-statements).
benjamin-kramer #3940โ Add type-checked analyzer rule version of
ArrayInitRule
namedTypesafeArrayInitRule
with identifiertypesafe_array_init
that avoids the false positives present in the lint rule.
SimplyDanny #3749โ Add the
--in-process-sourcekit
command line flag tolint
andanalyze
commands, which has the same effect as setting theIN_PROCESS_SOURCEKIT
environment variable.
Juozas Valanciusโ Add a new
artifactbundle
release asset containingswiftlint
binaries for x86 & arm64 macOS.
Juozas Valancius #3840Add back
return_value_from_void_function
opt-in rule to warn against usingreturn <expression>
in a function that returnsVoid
.
Marcelo Fabriโ Don't skip autocorrect on files that have parser warnings. Only files with errors reported by the Swift parser will be skipped.
Marcelo Fabri #3343Add
accessibility_label_for_image
rule to warn if a SwiftUI Image does not have an accessibility label and is not hidden from accessibility.
Ryan Coleโ Add
unavailable_condition
rule to prefer usingif #unavailable
instead ofif #available
with an empty body and anelse
condition when using Swift 5.6 or later.
Marcelo Fabri #3897โ Add
comma_inheritance
rule to validate that inheritance clauses use commas instead of&
.
Marcelo Fabri #3950
๐ Bug Fixes
Fix false positives in
unused_closure_parameter
when using parameters with backticks.
JP Simard #3628๐ Improved the
syntactic_sugar
rule's detection accuracy and fixed some corrections leading to invalid code.
Paul Taykalo #3866๐ Fix analyzer rules with Xcode 13.3 / Swift 5.6. Note that we've measured performance regressions compared to Swift 5.5 on the order of about 2x.
JP Simard #39200๏ธโฃ Error by default on bad expiring todo date formatting.
Christopher Hale #3636๐ Lint/analyze all files listed in the command even if the
--path
option is used.
coffmark
-
v0.47.0 Changes
๐ฅ Breaking
๐ SwiftLint now requires Swift 5.5 or higher to build.
JP Simard๐ The
SwiftLintFramework
podspec has been removed. To our knowledge, this was completely unused by other projects and was not worth the complexity needed to justify its continued maintenance, especially in light of the integration of SwiftSyntax. TheSwiftLint
podspec is still supported.
JP Simard๐ SwiftLint now requires at least Swift 5.0 installed in order to lint files.
Marcelo Fabri
Experimental
- ๐ The
force_cast
rule and the comment command parsing mechanism have been updated to use SwiftSyntax instead of SourceKit. Please report any problems you encounter by opening a GitHub issue. If this is successful, more rules may use Swift Syntax in the future.
JP Simard
โจ Enhancements
Empty files no longer trigger any violations.
JP Simard #38540๏ธโฃ The
legacy_random
rule is now enabled by default.
Marcelo Fabri๐ The
deployment_target
rule now supports the#unavailable
syntax added in Swift 5.6.
Marcelo Fabri #3896๐จ Set the
IN_PROCESS_SOURCEKIT
environment variable, which will use the in-process version of sourcekitd on macOS when Xcode 13 or later is selected. This avoids the use of XPC, which is prohibited in some sandboxed environments, such as in Swift Package Manager plugins.
Juozas Valanciusโ Add ability to run only one (focused) example.
PaulTaykalo #3911
๐ Bug Fixes
Extend
class_delegate_protocol
to correctly identify cases with the protocol body opening brace on a new line.
Tobisaninfo๐ Fix SwiftLint.pkg installer installing multiple copies of SwiftLint.
JP Simard #3815 #3887
-
v0.46.5 Changes
๐ฅ Breaking
- None.
Experimental
- None.
โจ Enhancements
- None.
๐ Bug Fixes
Fix
empty_parentheses_with_trailing_closure
rule when using Swift 5.6.
Marcelo Fabri #3846Fix false negatives in
closure_parameter_position
rule with Swift 5.6.
Marcelo Fabri #3845๐ Fix regression in
last_where
rule when using Swift 5.6.
Marcelo Fabri #3847๐ Fix regression in
unused_import
rule when using Swift 5.6.
JP Simard #3849๐ Fix regression in
trailing_closure
rule when using Swift 5.6.
Marcelo Fabri #3848
-
v0.46.4 Changes
๐ฅ Breaking
- None.
Experimental
- None.
โจ Enhancements
- None.
๐ Bug Fixes
Ignore meta class types in
prefer_self_in_static_references
rule.
SimplyDanny #3804Ignore MARK in multiline comment, fixing cases that would previously crash or produce invalid results when correcting.
goranche #1749 #3841๐ Fix false positive in
EmptyEnumArgumentsRule
rule when using Swift 5.6.
Marcelo Fabri #3850
-
v0.46.3 Changes
๐ฅ Breaking
- None.
Experimental
- None.
โจ Enhancements
- ๐ Change fingerprint generation in
CodeClimateReporter.swift
to use the relative file path to better support CI/CD on multiple machines.
HA Pors
๐ Bug Fixes
Fix crash in the
closure_end_indentation
rule when linting with Swift 5.6.
JP Simard #3830๐ Fix default rules section in documentation.
Natan Rolnik #3857