Releases: realm/SwiftLint
0.50.0-rc.3: 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.3 && make install
- Docker:
docker run -it -v `pwd`:`pwd` -w `pwd` ghcr.io/realm/swiftlint:0.50.0-rc.3
- Bazel: See instructions at the bottom
Changes from 0.49.1: 0.49.1...0.50.0-rc.3
Changes from 0.50.0-rc.2: 0.50.0-rc.2...0.50.0-rc.3
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
-
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
multiple_closures_with_trailing_closure
multiline_parameters
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
override_in_extension
nsobject_prefer_isequal
prefer_nimble
prefer_self_type_over_type_of_self
prefer_zero_over_explicit_init
prefixed_toplevel_constant
private_action
private_over_fileprivate
private_outlet
private_unit_test
prohibited_interface_builder
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_set_access_control
redundant_optional_initialization
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-hand side of an operation
only differ in trivia.
SimplyDanny -
Print violations in realtime if
--progress
and--output
are both set.
JP Simard -
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_discouraged_call
,quick_discouraged_focused_test
and
quick_discouraged_pending_test
rules now trigger on subclasses of
QuickSpec
.
[Ma...
0.50.0-rc.2: 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.2 && make install
- Docker:
docker run -it -v `pwd`:`pwd` -w `pwd` ghcr.io/realm/swiftlint:0.50.0-rc.2
- Bazel: See instructions at the bottom
Changes from 0.49.1: 0.49.1...0.50.0-rc.2
Changes from 0.50.0-rc.1: 0.50.0-rc.1...0.50.0-rc.2
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
-
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 -
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
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
deployment_target
discouraged_assert
discouraged_direct_init
discouraged_none_name
discouraged_object_literal
discouraged_optional_boolean
duplicate_enum_cases
dynamic_inline
empty_collection_literal
empty_enum_arguments
empty_parameters
empty_parentheses_with_trailing_closure
empty_string
enum_case_associated_values_count
explicit_enum_raw_value
explicit_init
fallthrough
first_where
flatmap_over_map_reduce
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
inert_defer
is_disjoint
large_tuple
last_where
legacy_cggeometry_functions
legacy_constant
legacy_constructor
legacy_hashing
legacy_multiple
legacy_nsgeometry_functions
legacy_random
multiple_closures_with_trailing_closure
no_extension_access_modifier
no_fallthrough_only
no_space_in_method_call
nslocalizedstring_require_bundle
nsobject_prefer_isequal
number_separator
operator_whitespace
nsobject_prefer_isequal
private_action
private_over_fileprivate
private_outlet
private_unit_test
prohibited_interface_builder
protocol_property_accessors_order
quick_discouraged_focused_test
quick_discouraged_pending_test
reduce_boolean
redundant_discardable_let
redundant_nil_coalescing
redundant_string_enum_value
self_in_property_initialization
shorthand_operator
sorted_first_last
static_operator
strict_fileprivate
strong_iboutlet
switch_case_alignment
switch_case_on_newline
toggle_bool
trailing_comma
trailing_semicolon
type_body_length
unneeded_break_in_switch
unneeded_parentheses_in_closure_argument
unowned_variable_capture
untyped_error_in_catch
unused_closure_parameter
unused_control_flow_label
unused_enumerated
unused_setter_value
valid_ibinspectable
weak_delegate
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-hand side of an operation
only differ in trivia.
SimplyDanny -
Print violations in realtime if
--progress
and--output
are both set.
JP Simard
Bug Fixes
-
Respect
validates_start_with_lowercase
option when linting function names.
Chris Brakebill
#2708 -
Do not report variables annotated with
@NSApplicationDelegateAdaptor
and
@WKExtensionDelegateAdaptor
inweak_delegate
rule.
Till Hainbach
#3598
#3611 -
Fix false-positives related to the
willMove
lifecycle method in
type_contents_order
rule.
SimplyDanny
#3478 -
Do 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 Simard -
Make
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
#4234
Using Bazel
Put this in your WORKSPACE
:
...
0.50.0-rc.1: 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.1 && make install
- Docker:
docker run -it -v `pwd`:`pwd` -w `pwd` ghcr.io/realm/swiftlint:0.50.0-rc.1
- Bazel: See instructions at the bottom
Changes from 0.49.1: 0.49.1...0.50.0-rc.1
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
-
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 -
Rewrite some rules with SwiftSyntax, fixing some false positives and catching
more violations:anonymous_argument_in_multiline_closure
array_init
block_based_kvo
class_delegate_protocol
closing_brace
closure_parameter_position
computed_accessors_order
contains_over_filter_count
contains_over_range_nil_comparison
deployment_target
discouraged_object_literal
discouraged_optional_boolean
duplicate_enum_cases
dynamic_inline
empty_collection_literal
empty_enum_arguments
empty_parameters
empty_parentheses_with_trailing_closure
empty_string
explicit_init
fallthrough
flatmap_over_map_reduce
force_try
force_unwrapping
generic_type_name
ibinspectable_in_extension
implicit_getter
inert_defer
large_tuple
legacy_cggeometry_functions
legacy_constant
legacy_nsgeometry_functions
multiple_closures_with_trailing_closure
no_extension_access_modifier
no_fallthrough_only
no_space_in_method_call
nsobject_prefer_isequal
private_action
private_outlet
private_unit_test
protocol_property_accessors_order
redundant_nil_coalescing
redundant_string_enum_value
strong_iboutlet
switch_case_on_newline
toggle_bool
trailing_semicolon
unneeded_break_in_switch
unneeded_parentheses_in_closure_argument
unowned_variable_capture
untyped_error_in_catch
xctfail_message
Marcelo Fabri
SimplyDanny
JP Simard
#2915
-
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
if_let_shadowing
opt-in rule that triggers in Swift 5.7 when a
shadowing optional binding is created in an if- or guard-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
Bug Fixes
-
Respect
validates_start_with_lowercase
option when linting function names.
Chris Brakebill
#2708 -
Do not report variables annotated with
@NSApplicationDelegateAdaptor
and
@WKExtensionDelegateAdaptor
inweak_delegate
rule.
Till Hainbach
#3598
#3611 -
Fix false-positives related to the
willMove
lifecycle method in
type_contents_order
rule.
SimplyDanny
#3478 -
Do 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 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 = "90e3b5e8ff942be134e64a83499974203ea64797fd620eddeb71b3a8e1bff681",
url = "https://github.com/bazelbuild/rules_apple/releases/download/1.1.2/rules_apple.1.1.2.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 = "ee13554c48ca7845513ae307863525afbb5b8f22d4c3b34b5b2e87311c3d5e26",
url = "https://github.com/realm/SwiftLint/releases/download/0.50.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.49.1: Buanderie Principale
Note: The default branch for the SwiftLint git repository was renamed from
master
to main
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
#3691 -
Fix false positives in
redundant_discardable_let
when using
async 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
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 = "f003875c248544009c8e8ae03906bbdacb970bc3e5931b40cd76cadeded99632",
url = "https://github.com/bazelbuild/rules_apple/releases/download/1.1.0/rules_apple.1.1.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 = "7c454ff4abeeecdd9513f6293238a6d9f803b587eb93de147f9aa1be0d8337c4",
url = "https://github.com/realm/SwiftLint/releases/download/0.49.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.49.0: Asynchronous Defuzzer
Note: The default branch for the SwiftLint git repository will be renamed from
master
to main
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
#4090 -
Introduce 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
#4030 -
Enable (recursive) globs in
included
file paths.
sarastro-nl -
Custom 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 two
swiftlint
executables are identical.
JP Simard -
Update documentation for
multiline_arguments_brackets
and
multiline_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 Simard -
Add new configuration option
allowed_no_space_operators
to
operator_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
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 = "f003875c248544009c8e8ae03906bbdacb970bc3e5931b40cd76cadeded99632",
url = "https://github.com/bazelbuild/rules_apple/releases/download/1.1.0/rules_apple.1.1.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 = "ec566314e9220ff681ddb639d3a0532834f66f7e733f5a59c7390469dcb5bd3e",
url = "https://github.com/realm/SwiftLint/releases/download/0.49.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.49.0-rc.2: Asynchronous Defuzzer
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.49.0-rc.2 && make install
- Docker:
docker run -it -v `pwd`:`pwd` -w `pwd` ghcr.io/realm/swiftlint:0.49.0-rc.2
- Bazel: See instructions at the bottom
Changes from 0.48.0: 0.48.0...0.49.0-rc.2
Changes from 0.49.0-rc.1: 0.49.0-rc.1...0.49.0-rc.2
Note: The default branch for the SwiftLint git repository will be renamed from
master
to main
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
#4090 -
Introduce 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
#4030 -
Enable (recursive) globs in
included
file paths.
sarastro-nl -
Custom 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 two
swiftlint
executables are identical.
JP Simard -
Update documentation for
multiline_arguments_brackets
and
multiline_literal_brackets
to make it immediately obvious that common
examples will trigger.
chrisjf
#4060
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
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 = "36072d4f3614d309d6a703da0dfe48684ec4c65a89611aeb9590b45af7a3e592",
url = "https://github.com/bazelbuild/rules_apple/releases/download/1.0.1/rules_apple.1.0.1.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 = "d34bf123e6380a7527ee78c5f6ec7ede5e00e8c39a9c3b394f590374f566c57d",
url = "https://github.com/realm/SwiftLint/releases/download/0.49.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.49.0-rc.1: Asynchronous Defuzzer
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.49.0-rc.1 && make install
- Docker:
docker run -it -v `pwd`:`pwd` -w `pwd` ghcr.io/realm/swiftlint:0.49.0-rc.1
- Bazel: See instructions at the bottom
Changes from 0.48.0: 0.48.0...0.49.0-rc.1
Note: The default branch for the SwiftLint git repository will be renamed from
master
to main
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 -
Introduce 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
#4030
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
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 = "36072d4f3614d309d6a703da0dfe48684ec4c65a89611aeb9590b45af7a3e592",
url = "https://github.com/bazelbuild/rules_apple/releases/download/1.0.1/rules_apple.1.0.1.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 = "e954f4483f7f4cf523896693ee3505585f6beb0f791e362b42d9bdbb615f051a",
url = "https://github.com/realm/SwiftLint/releases/download/0.49.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.48.0: Rechargeable Defuzzer
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
, and
tvOSApplicationExtension_deployment_target
. Extentions default to
their counterparts unless they are explicitly defined.
tahabebek
#4004 -
Rewrite
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 Fabri -
Add back
void_function_in_ternary
opt-in rule to warn against using
a ternary operator to callVoid
functions.
Marcelo Fabri -
Support
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
#3502 -
Prevent 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.
SimplyDanny -
Look 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
#3705 -
Do not trigger
unavailable_condition
rule if other#(un)available
checks are involved.
SimplyDanny
#3985 -
Update
nimble_operator
to support the operators forbeNil()
.
CraigSiemens -
Avoid false-positive in
let_var_whitespace
rule by allowing custom
attributes on lines directly before let/var declarations.
SimplyDanny
#2980
0.47.1: Smarter Appliance
Breaking
- None.
Experimental
- None.
Enhancements
-
Add type-checked analyzer rule version of
ArrayInitRule
named
TypesafeArrayInitRule
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
#3840 -
Add back
return_value_from_void_function
opt-in rule to warn against using
return <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
#3343 -
Add
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 of
if #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
#3920 -
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
0.47.0: Smart Appliance
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
#3854 -
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