Skip to content

Releases: realm/SwiftLint

0.51.0-rc.2: bzllint

20 Feb 23:55
527e2c4
Compare
Choose a tag to compare
0.51.0-rc.2: bzllint Pre-release
Pre-release

This is a prerelease version. It won't be published to Homebrew, CocoaPods or bzlmod. But there are many other ways to install:

  • Downloading the attached SwiftLint.pkg installer and launching it
  • Downloading the attached portable_swiftlint.zip archive, extracting it and moving the binary from portable_swiftlint/swiftlint to /usr/local/bin or elsewhere in your PATH
  • Using Mint: mint install realm/SwiftLint@0.51.0-rc.2
  • Cloning and building from source: git clone https://github.com/realm/SwiftLint.git && cd SwiftLint && git checkout 0.51.0-rc.2 && make install
  • Docker: docker run -it -v `pwd`:`pwd` -w `pwd` ghcr.io/realm/swiftlint:0.51.0-rc.2
  • Bazel: See instructions at the bottom

Changes from 0.50.3: 0.50.3...0.51.0-rc.2
Changes from 0.51.0-rc.1: 0.51.0-rc.1...0.51.0-rc.2


Breaking

  • Deprecate the unused_capture_list rule in favor of the Swift compiler
    warning. At the same time, make it an opt-in rule.
    Cyberbeni
    #4656

  • Deprecate the inert_defer rule in favor of the Swift compiler warning.
    At the same time, make it an opt-in rule.
    SimplyDanny
    #4615

Experimental

  • None.

Enhancements

  • Add local links to rule descriptions to every rule listed
    in Rule Directory.md.
    kattouf

  • Make forceExclude work with directly specified files.
    jimmya
    #issue_number

  • Separate analyzer rules as an independent section in the rule directory of
    the reference.
    Ethan Wong
    #4664

  • Add rule identifier to output of Emoji reporter.
    SimplyDanny
    #4707

  • Interpret strings in excluded option of identifier_name,
    type_name and generic_type_name rules as regex.
    Moly
    #4655

  • Add new direct_return rule that triggers on return 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 and justBeforeEach for
    quick_discouraged_call.
    David Steinacher
    #4626

  • Add relative-path reporter to generate reports with relative file paths.
    Roya1v
    #4660

  • Let number_separator rule trigger on misplaced separators, e.g. 10_00.
    SimplyDanny
    #4637

  • Rewrite multiline_arguments rule using SwiftSyntax, ignoring trailing
    closures.
    Marcelo Fabri
    #3399
    #3605

  • Speed up linting by up to 6% updating to use a newer version of
    SwiftSyntax.
    JP Simard

  • Catch more valid legacy_multiple violations.
    JP Simard

  • Catch more valid no_magic_numbers violations.
    JP Simard

Bug Fixes

  • Report violations in all <scope>_length rules when the error threshold is
    smaller than the warning threshold.
    SimplyDanny
    #4645

  • Consider custom attributes in attributes rule.
    SimplyDanny
    #4599

  • Stop triggering strict_fileprivate rule on symbols implementing a protocol
    in the same file.
    SimplyDanny
    #4692

  • Fix false positives on private_subject rule when using
    subjects inside functions.
    Marcelo Fabri
    #4643

  • Fix for compiler directives masking subsequent opening_brace
    violations.
    Martin Redington
    #3712

  • Rewrite explicit_type_interface rule with SwiftSyntax fixing a
    false-positive in if-case-let statements.
    SimplyDanny
    #4548

  • Ensure that negative literals in initializers do not trigger
    no_magic_numbers rule.
    SimplyDanny
    #4677

  • Fix caching of indentation_width rule.
    SimplyDanny
    #4121

  • Updated JUnit reporter to output error count and warning count.
    patricks
    #4725

  • Fix correction on lower_acl_than_parent rule for open declarations.
    Marcelo Fabri
    #4753

  • Fix void_return rule to support async and async throws functions.
    Mathias Schreck
    #4772

  • Fix false positives in attributes rule when using property wrappers
    with keypath arguments.
    JP Simard


Using Bazel

Put this in your WORKSPACE:

WORKSPACE
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "build_bazel_rules_apple",
    sha256 = "43737f28a578d8d8d7ab7df2fb80225a6b23b9af9655fcdc66ae38eb2abcf2ed",
    url = "https://github.com/bazelbuild/rules_apple/releases/download/2.0.0/rules_apple.2.0.0.tar.gz",
)

load(
    "@build_bazel_rules_apple//apple:repositories.bzl",
    "apple_rules_dependencies",
)

apple_rules_dependencies()

load(
    "@build_bazel_rules_swift//swift:repositories.bzl",
    "swift_rules_dependencies",
)

swift_rules_dependencies()

load(
    "@build_bazel_rules_swift//swift:extras.bzl",
    "swift_rules_extra_dependencies",
)

swift_rules_extra_dependencies()

http_archive(
    name = "SwiftLint",
    sha256 = "f0e37c2ca277ef8c50d865cbdb75326592bcba11b786caf1fccc3111e9925e01",
    url = "https://github.com/realm/SwiftLint/releases/download/0.51.0-rc.2/bazel.tar.gz",
)

load("@SwiftLint//bazel:repos.bzl", "swiftlint_repos")

swiftlint_repos()

load("@SwiftLint//bazel:deps.bzl", "swiftlint_deps")

swiftlint_deps()

Then you can run SwiftLint in the current directory with this command:

bazel run @SwiftLint//:swiftlint -- --help

0.51.0-rc.1: bzllint

20 Feb 21:47
b652231
Compare
Choose a tag to compare
0.51.0-rc.1: bzllint Pre-release
Pre-release

This is a prerelease version. It won't be published to Homebrew, CocoaPods or bzlmod. But there are many other ways to install:

  • Downloading the attached SwiftLint.pkg installer and launching it
  • Downloading the attached portable_swiftlint.zip archive, extracting it and moving the binary from portable_swiftlint/swiftlint to /usr/local/bin or elsewhere in your PATH
  • Using Mint: mint install realm/SwiftLint@0.51.0-rc.1
  • Cloning and building from source: git clone https://github.com/realm/SwiftLint.git && cd SwiftLint && git checkout 0.51.0-rc.1 && make install
  • Docker: docker run -it -v `pwd`:`pwd` -w `pwd` ghcr.io/realm/swiftlint:0.51.0-rc.1
  • Bazel: See instructions at the bottom

Changes from 0.50.3: 0.50.3...0.51.0-rc.1


Breaking

  • Deprecate the unused_capture_list rule in favor of the Swift compiler
    warning. At the same time, make it an opt-in rule.
    Cyberbeni
    #4656

  • Deprecate the inert_defer rule in favor of the Swift compiler warning.
    At the same time, make it an opt-in rule.
    SimplyDanny
    #4615

Experimental

  • None.

Enhancements

  • Add local links to rule descriptions to every rule listed
    in Rule Directory.md.
    kattouf

  • Make forceExclude work with directly specified files.
    jimmya
    #issue_number

  • Separate analyzer rules as an independent section in the rule directory of
    the reference.
    Ethan Wong
    #4664

  • Add rule identifier to output of Emoji reporter.
    SimplyDanny
    #4707

  • Interpret strings in excluded option of identifier_name,
    type_name and generic_type_name rules as regex.
    Moly
    #4655

  • Add new direct_return rule that triggers on return 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 and justBeforeEach for
    quick_discouraged_call.
    David Steinacher
    #4626

  • Add relative-path reporter to generate reports with relative file paths.
    Roya1v
    #4660

  • Let number_separator rule trigger on misplaced separators, e.g. 10_00.
    SimplyDanny
    #4637

  • Rewrite multiline_arguments rule using SwiftSyntax, ignoring trailing
    closures.
    Marcelo Fabri
    #3399
    #3605

  • Speed up linting by up to 6% updating to use a newer version of
    SwiftSyntax.
    JP Simard

  • Catch more valid legacy_multiple violations.
    JP Simard

  • Catch more valid no_magic_numbers violations.
    JP Simard

Bug Fixes

  • Report violations in all <scope>_length rules when the error threshold is
    smaller than the warning threshold.
    SimplyDanny
    #4645

  • Consider custom attributes in attributes rule.
    SimplyDanny
    #4599

  • Stop triggering strict_fileprivate rule on symbols implementing a protocol
    in the same file.
    SimplyDanny
    #4692

  • Fix false positives on private_subject rule when using
    subjects inside functions.
    Marcelo Fabri
    #4643

  • Fix for compiler directives masking subsequent opening_brace
    violations.
    Martin Redington
    #3712

  • Rewrite explicit_type_interface rule with SwiftSyntax fixing a
    false-positive in if-case-let statements.
    SimplyDanny
    #4548

  • Ensure that negative literals in initializers do not trigger
    no_magic_numbers rule.
    SimplyDanny
    #4677

  • Fix caching of indentation_width rule.
    SimplyDanny
    #4121

  • Updated JUnit reporter to output error count and warning count.
    patricks
    #4725

  • Fix correction on lower_acl_than_parent rule for open declarations.
    Marcelo Fabri
    #4753

  • Fix void_return rule to support async and async throws functions.
    Mathias Schreck
    #4772

  • Fix false positives in attributes rule when using property wrappers
    with keypath arguments.
    JP Simard


Using Bazel

Put this in your WORKSPACE:

WORKSPACE
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "build_bazel_rules_apple",
    sha256 = "43737f28a578d8d8d7ab7df2fb80225a6b23b9af9655fcdc66ae38eb2abcf2ed",
    url = "https://github.com/bazelbuild/rules_apple/releases/download/2.0.0/rules_apple.2.0.0.tar.gz",
)

load(
    "@build_bazel_rules_apple//apple:repositories.bzl",
    "apple_rules_dependencies",
)

apple_rules_dependencies()

load(
    "@build_bazel_rules_swift//swift:repositories.bzl",
    "swift_rules_dependencies",
)

swift_rules_dependencies()

load(
    "@build_bazel_rules_swift//swift:extras.bzl",
    "swift_rules_extra_dependencies",
)

swift_rules_extra_dependencies()

http_archive(
    name = "SwiftLint",
    sha256 = "f44b1e1c9aac0b4febbfae8479fc4e60df099066076fb10dfc0f42fd83731170",
    url = "https://github.com/realm/SwiftLint/releases/download/0.51.0-rc.1/bazel.tar.gz",
)

load("@SwiftLint//bazel:repos.bzl", "swiftlint_repos")

swiftlint_repos()

load("@SwiftLint//bazel:deps.bzl", "swiftlint_deps")

swiftlint_deps()

Then you can run SwiftLint in the current directory with this command:

bazel run @SwiftLint//:swiftlint -- --help

0.50.3: Bundle of Towels

09 Dec 19:15
a876e86
Compare
Choose a tag to compare

Breaking

  • None.

Experimental

  • None.

Enhancements

  • The SwiftLintPlugin SwiftPM plugin now uses a prebuilt binary on
    macOS.
    Tony Arnold
    JP Simard
    #4558

  • Don't trigger shorthand_operator violations inside a shorthand
    operator function declaration.
    Marcelo Fabri
    #4611

  • The balanced_xctest_lifecycle, single_test_class,
    empty_xctest_method and test_case_accessibility rules will now be
    applied to subclasses of QuickSpec, as well as XCTestCase, by
    default.
    Martin Redington

  • Add test_parent_classes option to balanced_xctest_lifecycle,
    single_test_class and empty_xctest_method rules.
    Martin Redington
    #4200

  • Show warnings in the console for Analyzer rules that are listed in the
    opt_in_rules configuration section.
    SimplyDanny
    #4612

Bug Fixes

  • Fix configuration parsing error in unused_declaration rule.
    SimplyDanny
    #4612

  • Skip defer statements being last in an #if block if the #if
    statement is not itself the last statement in a block.
    SimplyDanny
    #4615

  • Fix false positives in empty_enum_arguments when the called
    expression is an identifier or an init call.
    Steffen Matthischke
    #4597

  • Fix correction issue in comma when there was too much whitespace
    following the comma.
    JP Simard


Using Bazel

Put this in your WORKSPACE:

WORKSPACE
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "build_bazel_rules_apple",
    sha256 = "f94e6dddf74739ef5cb30f000e13a2a613f6ebfa5e63588305a71fce8a8a9911",
    url = "https://github.com/bazelbuild/rules_apple/releases/download/1.1.3/rules_apple.1.1.3.tar.gz",
)

load(
    "@build_bazel_rules_apple//apple:repositories.bzl",
    "apple_rules_dependencies",
)

apple_rules_dependencies()

load(
    "@build_bazel_rules_swift//swift:repositories.bzl",
    "swift_rules_dependencies",
)

swift_rules_dependencies()

load(
    "@build_bazel_rules_swift//swift:extras.bzl",
    "swift_rules_extra_dependencies",
)

swift_rules_extra_dependencies()

http_archive(
    name = "SwiftLint",
    sha256 = "b8c4d765bcd8b533fcc2e15f32482a1a17572f143b65af388f7d5ac99994a99a",
    url = "https://github.com/realm/SwiftLint/releases/download/0.50.3/bazel.tar.gz",
)

load("@SwiftLint//bazel:repos.bzl", "swiftlint_repos")

swiftlint_repos()

load("@SwiftLint//bazel:deps.bzl", "swiftlint_deps")

swiftlint_deps()

Then you can run SwiftLint in the current directory with this command:

bazel run -c opt @SwiftLint//:swiftlint -- --help

0.50.1: Artisanal Clothes Pegs Fixup Edition

25 Nov 16:38
28a4aa2
Compare
Choose a tag to compare

Breaking

  • None.

Experimental

  • None.

Enhancements

  • Moved the validation of doc comments in local scopes out of
    orphaned_doc_comment and into a new opt-in local_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

0.50.0: Artisanal Clothes Pegs

18 Nov 19:46
cdd891a
Compare
Choose a tag to compare

Breaking

  • SwiftLint now requires Swift 5.7 or higher to build.
    JP Simard

  • Exclude weak_delegate rule from autocorrection due to behavioral changes
    leading to potential undefined behavior or bugs.
    SimplyDanny
    #3577

  • The anyobject_protocol rule is now deprecated and will be completely removed
    in a future release because it is now handled by the Swift compiler.
    JP Simard

  • Built-in SwiftLint rules are no longer marked as public in
    SwiftLintFramework. This only impacts the programmatic API for the
    SwiftLintFramework module.
    JP Simard

Experimental

  • None.

Enhancements

  • SwiftSyntax libraries have been updated from the previous 5.6 release and now
    use the new parser written in Swift.
    Swift 5.7+ features should now be parsed more accurately.
    We've also measured an improvement in lint times of up to 15%.
    This should also fix some deployment issues where the exact version of the
    internal SwiftSyntax parser needed to be available.
    If you notice any unexpected changes to lint results, please file an issue on
    the SwiftLint issue tracker. We can look into it and if it's a SwiftSyntax
    parser regression we can re-file it upstream.
    JP Simard
    #4031

  • Rewrite some rules with SwiftSyntax, fixing some false positives and catching
    more violations:

    • anonymous_argument_in_multiline_closure
    • array_init
    • attributes
    • balanced_xctest_lifecycle
    • block_based_kvo
    • class_delegate_protocol
    • closing_brace
    • closure_body_length
    • closure_parameter_position
    • collection_alignment
    • comment_spacing
    • computed_accessors_order
    • conditional_returns_on_newline
    • contains_over_filter_count
    • contains_over_filter_is_empty
    • contains_over_first_not_nil
    • contains_over_range_nil_comparison
    • convenience_type
    • deployment_target
    • discarded_notification_center_observer
    • discouraged_assert
    • discouraged_direct_init
    • discouraged_none_name
    • discouraged_object_literal
    • discouraged_optional_boolean
    • duplicate_enum_cases
    • duplicated_key_in_dictionary_literal
    • dynamic_inline
    • empty_collection_literal
    • empty_count
    • empty_enum_arguments
    • empty_parameters
    • empty_parentheses_with_trailing_closure
    • empty_string
    • enum_case_associated_values_count
    • explicit_enum_raw_value
    • explicit_init
    • explicit_top_level_acl
    • fallthrough
    • file_name
    • first_where
    • flatmap_over_map_reduce
    • for_where
    • force_try
    • force_unwrapping
    • function_body_length
    • function_default_parameter_at_end
    • function_parameter_count
    • generic_type_name
    • ibinspectable_in_extension
    • identical_operands
    • implicit_getter
    • implicitly_unwrapped_optional
    • inclusive_language
    • inert_defer
    • is_disjoint
    • joined_default_parameter
    • large_tuple
    • last_where
    • legacy_cggeometry_functions
    • legacy_constant
    • legacy_constructor
    • legacy_hashing
    • legacy_multiple
    • legacy_nsgeometry_functions
    • legacy_objc_type
    • legacy_random
    • lower_acl_than_parent
    • multiline_arguments_brackets
    • multiline_parameters
    • multiple_closures_with_trailing_closure
    • no_extension_access_modifier
    • no_fallthrough_only
    • no_space_in_method_call
    • notification_center_detachment
    • nslocalizedstring_key
    • nslocalizedstring_require_bundle
    • nsobject_prefer_isequal
    • number_separator
    • object_literal
    • operator_whitespace
    • optional_enum_case_matching
    • orphaned_doc_comment
    • overridden_super_call
    • override_in_extension
    • pattern_matching_keywords
    • prefer_nimble
    • prefer_self_in_static_references
    • prefer_self_type_over_type_of_self
    • prefer_zero_over_explicit_init
    • prefixed_toplevel_constant
    • private_action
    • private_outlet
    • private_over_fileprivate
    • private_subject
    • private_unit_test
    • prohibited_interface_builder
    • prohibited_super_call
    • protocol_property_accessors_order
    • quick_discouraged_focused_test
    • quick_discouraged_pending_test
    • raw_value_for_camel_cased_codable_enum
    • reduce_boolean
    • reduce_into
    • redundant_discardable_let
    • redundant_nil_coalescing
    • redundant_objc_attribute
    • redundant_optional_initialization
    • redundant_set_access_control
    • redundant_string_enum_value
    • required_deinit
    • required_enum_case
    • return_arrow_whitespace
    • self_in_property_initialization
    • shorthand_operator
    • single_test_class
    • sorted_first_last
    • static_operator
    • strict_fileprivate
    • strong_iboutlet
    • switch_case_alignment
    • switch_case_on_newline
    • test_case_accessibility
    • toggle_bool
    • trailing_comma
    • trailing_semicolon
    • type_body_length
    • type_name
    • unneeded_break_in_switch
    • unneeded_parentheses_in_closure_argument
    • unowned_variable_capture
    • untyped_error_in_catch
    • unused_capture_list
    • unused_closure_parameter
    • unused_control_flow_label
    • unused_enumerated
    • unused_optional_binding
    • unused_setter_value
    • valid_ibinspectable
    • vertical_parameter_alignment
    • weak_delegate
    • xct_specific_matcher
    • xctfail_message
      Marcelo Fabri
      SimplyDanny
      JP Simard
      #2915
  • The "body length" family of rules have changed how they calculate body
    line count to be significantly more correct and intuitive. However,
    this is likely to require adjustments to your configuration or disable
    commands to account for the changes.
    JP Simard

  • Add ability to filter rules for generate-docs subcommand.
    kattouf

  • Add new excludes_trivial_init configuration for missing_docs rule
    to exclude initializers without any parameters.
    Marcelo Fabri
    #4107

  • Add new ns_number_init_as_function_reference rule to catch NSNumber.init
    and NSDecimalNumber.init being used as function references since it
    can cause the wrong initializer to be used, causing crashes. See
    apple/swift#51036 for more info.
    Marcelo Fabri

  • Add accessibility_trait_for_button rule to warn if a SwiftUI
    View has a tap gesture added to it without having the button or
    link accessibility trait.
    Ryan Cole

  • Add methods from SE-0348 to UnusedDeclarationRule.
    JP Simard

  • Include the configured bind_identifier in self_binding violation
    messages.
    JP Simard

  • The self_binding rule now catches shorthand optional bindings (for example
    if let self {}) when using a bind_identifier different than self.
    Marcelo Fabri

  • Add library_content_provider file type to file_types_order rule
    to allow LibraryContentProvider to be ordered independent from main_type.
    dahlborn

  • Add test_parent_classes option to test_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 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

  • Disregard whitespace differences in identical_operands rule. That is, the rule
    now also triggers if the left-hand side and the right-hand side of an operation
    only differ in trivia.
    SimplyDanny

  • Print violations in realtime if --progress and --output are both set.
    JP Simard

  • Trigger prefer_self_in_static_references rule on more type references like:

    • Key paths (e.g. \MyType.myVar -> \Self.myVar)
    • Computed properties (e.g. var i: Int { MyType.myVar ) -> var i: Int { Self.myVar })
    • Constructor calls (e.g. MyType() -> Self())

    SimplyDanny

  • Update for_where rule, adding a new configuration
    allow_for_as_filter to allow using for in with a single if inside
    when there's a return statement inside the if's body.
    Marcelo Fabri
    #4040

  • `quick_disco...

Read more

0.50.0-rc.4: Artisanal Clothes Pegs

04 Nov 13:26
0e6d19b
Compare
Choose a tag to compare
Pre-release

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 from portable_swiftlint/swiftlint to /usr/local/bin or elsewhere in your PATH
  • Using Mint: mint install realm/SwiftLint@0.50.0-rc.4
  • Cloning and building from source: git clone https://github.com/realm/SwiftLint.git && cd SwiftLint && git checkout 0.50.0-rc.4 && make install
  • Docker: docker run -it -v `pwd`:`pwd` -w `pwd` ghcr.io/realm/swiftlint:0.50.0-rc.4
  • Bazel: See instructions at the bottom

Changes from 0.49.1: 0.49.1...0.50.0-rc.4
Changes from 0.50.0-rc.3: 0.50.0-rc.3...0.50.0-rc.4


Breaking

  • SwiftLint now requires Swift 5.7 or higher to build.
    JP Simard

  • Exclude weak_delegate rule from autocorrection due to behavioral changes
    leading to potential undefined behavior or bugs.
    SimplyDanny
    #3577

  • The anyobject_protocol rule is now deprecated and will be completely removed
    in a future release because it is now handled by the Swift compiler.
    JP Simard

Experimental

  • None.

Enhancements

  • Adds NSError to the list of types in discouraged_direct_init.
    jszumski
    #4508

  • Fix SwiftLint support on Xcode Cloud.
    JagCesar
    westerlund
    #4484

  • Add no_magic_numbers rule to avoid "Magic Numbers".
    Henrik Storch
    #4031

  • SwiftSyntax libraries have been updated from the previous 5.6 release and now
    use the new parser written in Swift.
    Swift 5.7+ features should now be parsed more accurately.
    We've also measured an improvement in lint times of up to 15%.
    This should also fix some deployment issues where the exact version of the
    internal SwiftSyntax parser needed to be available.
    If you notice any unexpected changes to lint results, please file an issue on
    the SwiftLint issue tracker. We can look into it and if it's a SwiftSyntax
    parser regression we can re-file it upstream.
    JP Simard
    #4031

  • Add ability to filter rules for generate-docs subcommand.
    kattouf

  • Add new excludes_trivial_init configuration for missing_docs rule
    to exclude initializers without any parameters.
    Marcelo Fabri
    #4107

  • Add new ns_number_init_as_function_reference rule to catch NSNumber.init
    and NSDecimalNumber.init being used as function references since it
    can cause the wrong initializer to be used, causing crashes. See
    apple/swift#51036 for more info.
    Marcelo Fabri

  • Rewrite some rules with SwiftSyntax, fixing some false positives and catching
    more violations:

    • anonymous_argument_in_multiline_closure
    • array_init
    • attributes
    • block_based_kvo
    • class_delegate_protocol
    • closing_brace
    • closure_body_length
    • closure_parameter_position
    • collection_alignment
    • comment_spacing
    • computed_accessors_order
    • conditional_returns_on_newline
    • contains_over_filter_count
    • contains_over_filter_is_empty
    • contains_over_first_not_nil
    • contains_over_range_nil_comparison
    • convenience_type
    • deployment_target
    • discarded_notification_center_observer
    • discouraged_assert
    • discouraged_direct_init
    • discouraged_none_name
    • discouraged_object_literal
    • discouraged_optional_boolean
    • duplicate_enum_cases
    • duplicated_key_in_dictionary_literal
    • dynamic_inline
    • empty_collection_literal
    • empty_count
    • empty_enum_arguments
    • empty_parameters
    • empty_parentheses_with_trailing_closure
    • empty_string
    • enum_case_associated_values_count
    • explicit_enum_raw_value
    • explicit_init
    • explicit_top_level_acl
    • fallthrough
    • file_name
    • first_where
    • flatmap_over_map_reduce
    • for_where
    • force_try
    • force_unwrapping
    • function_body_length
    • function_default_parameter_at_end
    • function_parameter_count
    • generic_type_name
    • ibinspectable_in_extension
    • identical_operands
    • implicit_getter
    • implicitly_unwrapped_optional
    • inclusive_language
    • inert_defer
    • is_disjoint
    • joined_default_parameter
    • large_tuple
    • last_where
    • legacy_cggeometry_functions
    • legacy_constant
    • legacy_constructor
    • legacy_hashing
    • legacy_multiple
    • legacy_nsgeometry_functions
    • legacy_objc_type
    • legacy_random
    • lower_acl_than_parent
    • multiline_arguments_brackets
    • multiline_parameters
    • multiple_closures_with_trailing_closure
    • no_extension_access_modifier
    • no_fallthrough_only
    • no_space_in_method_call
    • notification_center_detachment
    • nslocalizedstring_require_bundle
    • nsobject_prefer_isequal
    • number_separator
    • operator_whitespace
    • optional_enum_case_matching
    • orphaned_doc_comment
    • overridden_super_call
    • override_in_extension
    • prefer_nimble
    • prefer_self_type_over_type_of_self
    • prefer_zero_over_explicit_init
    • prefixed_toplevel_constant
    • private_action
    • private_outlet
    • private_over_fileprivate
    • private_subject
    • private_unit_test
    • prohibited_interface_builder
    • prohibited_super_call
    • protocol_property_accessors_order
    • quick_discouraged_focused_test
    • quick_discouraged_pending_test
    • raw_value_for_camel_cased_codable_enum
    • reduce_boolean
    • reduce_into
    • redundant_discardable_let
    • redundant_nil_coalescing
    • redundant_objc_attribute
    • redundant_optional_initialization
    • redundant_set_access_control
    • redundant_string_enum_value
    • required_deinit
    • return_arrow_whitespace
    • self_in_property_initialization
    • shorthand_operator
    • single_test_class
    • sorted_first_last
    • static_operator
    • strict_fileprivate
    • strong_iboutlet
    • switch_case_alignment
    • switch_case_on_newline
    • test_case_accessibility
    • toggle_bool
    • trailing_comma
    • trailing_semicolon
    • type_body_length
    • type_name
    • unneeded_break_in_switch
    • unneeded_parentheses_in_closure_argument
    • unowned_variable_capture
    • untyped_error_in_catch
    • unused_capture_list
    • unused_closure_parameter
    • unused_control_flow_label
    • unused_enumerated
    • unused_optional_binding
    • unused_setter_value
    • valid_ibinspectable
    • vertical_parameter_alignment
    • weak_delegate
    • xct_specific_matcher
    • xctfail_message
      Marcelo Fabri
      SimplyDanny
      JP Simard
      #2915
  • The "body length" family of rules have changed how they calculate body
    line count to be significantly more correct and intuitive. However,
    this is likely to require adjustments to your configuration or disable
    commands to account for the changes.
    JP Simard

  • Add accessibility_trait_for_button rule to warn if a SwiftUI
    View has a tap gesture added to it without having the button or
    link accessibility trait.
    Ryan Cole

  • Add methods from SE-0348 to UnusedDeclarationRule.
    JP Simard

  • Include the configured bind_identifier in self_binding violation
    messages.
    JP Simard

  • Add library_content_provider file type to file_types_order rule
    to allow LibraryContentProvider to be ordered independent from main_type.
    dahlborn

  • Add test_parent_classes option to test_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 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

  • Disregard whitespace differences in identical_operands rule. That is, the rule
    now also triggers if the left-hand side and the right-h...

Read more

0.50.0-rc.3: Artisanal Clothes Pegs

27 Oct 13:48
c0b3206
Compare
Choose a tag to compare
Pre-release

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 from portable_swiftlint/swiftlint to /usr/local/bin or elsewhere in your PATH
  • Using Mint: mint install realm/SwiftLint@0.50.0-rc.3
  • 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 for missing_docs rule
    to exclude initializers without any parameters.
    Marcelo Fabri
    #4107

  • Add new ns_number_init_as_function_reference rule to catch NSNumber.init
    and NSDecimalNumber.init being used as function references since it
    can cause the wrong initializer to be used, causing crashes. See
    apple/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 in self_binding violation
    messages.
    JP Simard

  • Add library_content_provider file type to file_types_order rule
    to allow LibraryContentProvider to be ordered independent from main_type.
    dahlborn

  • Add test_parent_classes option to test_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 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

  • 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 using for in with a single if inside
    when there's a return statement inside the if'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...

Read more

0.50.0-rc.2: Artisanal Clothes Pegs

17 Oct 18:54
8d4ebcc
Compare
Choose a tag to compare
Pre-release

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 from portable_swiftlint/swiftlint to /usr/local/bin or elsewhere in your PATH
  • Using Mint: mint install realm/SwiftLint@0.50.0-rc.2
  • 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 for missing_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 in self_binding violation
    messages.
    JP Simard

  • Add library_content_provider file type to file_types_order rule
    to allow LibraryContentProvider to be ordered independent from main_type.
    dahlborn

  • Add test_parent_classes option to test_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 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

  • 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 in weak_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 in legacy_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:

...
Read more

0.50.0-rc.1: Artisanal Clothes Pegs

07 Oct 15:00
4f1ee6f
Compare
Choose a tag to compare
Pre-release

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 from portable_swiftlint/swiftlint to /usr/local/bin or elsewhere in your PATH
  • Using Mint: mint install realm/SwiftLint@0.50.0-rc.1
  • 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 for missing_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 in self_binding violation
    messages.
    JP Simard

  • Add library_content_provider file type to file_types_order rule
    to allow LibraryContentProvider to be ordered independent from main_type.
    dahlborn

  • Add test_parent_classes option to test_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 in weak_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 in legacy_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

01 Sep 16:32
57dc1c9
Compare
Choose a tag to compare

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 that self identifiers are
    consistently re-bound to a common identifier name. Configure bind_identifier
    to the name you want to use. Defaults to self.
    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