Skip to content

0.55.0: Universal Washing Powder

Compare
Choose a tag to compare
@SimplyDanny SimplyDanny released this 11 May 21:13
· 197 commits to main since this release

Breaking

  • Rewrite SwiftLintBuildToolPlugin using BUILD_WORKSPACE_DIRECTORY without relying
    on the --config option.
    Garric Nahapetian

  • Introduce SwiftLintCommandPlugin.
    Rename SwiftLintBuildToolPlugin.
    Add Swift Package Manager installation instructions.
    garricn

  • Fix Code Climate reporter output by having lower case severity
    values to comply with the Code Climate specification.
    waitButY

  • The superfluous_disable_command rule will now be enabled for the analyze
    command, unless it has been disabled, and will warn about superfluous
    disablement of analyzer rules.
    Martin Redington
    #4792

  • With the introduction of the consider_default_literal_types_redundant
    option to the redundant_type_annotation rule, Bool literals will no
    longer be considered redundant by default. Set this option to true to
    preserve the previous behavior.
    Garric Nahapetian

Experimental

  • Add two new options to the lint and analyze commands: --write-baseline
    to save a baseline to disk, and --baseline to read a saved baseline and
    use it to filter out detected pre-existing violations. A new baseline
    command uses the reporters to print the violations in a baseline.
    Martin Redington
    #5475
    #3421

Enhancements

  • Add a reporter that outputs violations in the Static
    Analysis Results Interchange Format (SARIF).
    waitButY

  • Ignore absence of a non-initial local config instead of
    falling back to default.
    kohtenko

  • Add new option ignore_typealiases_and_associatedtypes to
    nesting rule. It excludes typealias and associatedtype
    declarations from the analysis.
    marunomi
    #3183

  • Prevent from compiling SwiftLint target when only using SwiftLintPlugin on macOS.
    Julien Baillon
    #5372

  • Allow to set the severity of rules (if they have one) in the short form
    rule_name: warning|error provided that no other attributes need to be
    configured.
    SimplyDanny

  • Add new ignore_one_liners option to switch_case_alignment
    rule to ignore switch statements written in a single line.
    tonell-m
    #5373

  • Add new shorthand_argument rule that triggers on shorthand arguments
    like $0, $1, etc. in closures if they are too far away from the
    beginning of the closure. Options allow further cases to always trigger.
    SimplyDanny
    #70

  • Warn when --fix comes together with --strict or --lenient as only --fix
    takes effect then.
    SimplyDanny
    #5387

  • Add new one_declaration_per_file rule that allows only a
    single class/struct/enum/protocol declaration per file.
    Extensions are an exception; more than one is allowed.
    Muhammad Zeeshan
    #2802

  • Add new ignore_attributes option to redundant_type_annotation rule
    that allows disabling the rule for properties that are marked with at least
    one of the configured attributes.
    tonell-m
    #5366

  • Rewrite the following rules with SwiftSyntax:

    • explicit_acl
    • extension_access_modifier
    • identifier_name
    • let_var_whitespace
    • mark
    • multiline_literal_brackets
    • nesting
    • nimble_operator
    • opening_brace
    • orphaned_doc_comment
    • redundant_type_annotation
    • trailing_closure
    • void_return

    SimplyDanny
    kishikawakatsumi
    Marcelo Fabri
    swiftty
    KS1019
    tonell-m

  • Print invalid keys when configuration parsing fails.
    SimplyDanny
    #5347

  • Add new final_test_case rule that triggers on non-final test classes.
    SimplyDanny

  • Make superfluous_else rule auto-correctable.
    SimplyDanny

  • Support other scope-exiting statements continue, break and throw in
    superfluous_else rule.
    SimplyDanny

  • Trigger on -> () return signatures in return_value_from_void_function
    rule. Moreover, support automatic fixes for obvious cases.
    SimplyDanny

  • Refine violation position of trailing_closure rule.
    SimplyDanny

  • Trigger on the declaration keyword (i.e. let, var, func, subscript)
    instead of the static or class keywords in the explicit_acl rule.
    SimplyDanny

  • Allow to configure more operators in identifier_name rule. The new option
    is named additional_operators. Use it to add more operators to the list
    of default operators known to the rule.
    SimplyDanny
    #1762

  • Stop triggering no_magic_numbers rule on literals used in range
    expressions assigned to variables.
    SimplyDanny
    #5430

  • Add affect_initializers option to allow unneeded_override rule
    to affect initializers.
    leonardosrodrigues0
    #5265

  • Respect scattered disable commands in auto-correction of duplicate_imports
    rule.
    SimplyDanny
    #5418

  • Add new non_optional_string_data_conversion rule to enforce
    non-failable conversions of UTF-8 String <-> Data.
    Ben P
    #5263

  • Refine violation position of superfluous_else rule.
    SimplyDanny

  • Make sorted_enum_cases rule's comparison case-insensitive to
    avoid unexpected ordering.
    Oleg Kokhtenko

  • Add excluded_lines_patterns to line_length to avoid linting lines
    that contain one of the patterns.
    kasrababaei

  • Make empty_count auto-correctable.
    KS1019

  • Make private_swiftui_state auto-correctable.
    mt00chikin

  • Make trailing_closure correctable.
    KS1019

  • Add new static_over_final_class rule to prefer static over
    final class declaration.
    phlippieb
    #5471

  • Extends unused_enumerated rule to cover closure parameters, to
    detect cases like list.enumerated().map { idx, _ in idx } and
    list.enumerated().map { $1 }.
    Martin Redington
    #5470

  • Include Double, Int and String to the exiting redundant type validation
    check of Bool in the redundant_type_annotation rule. Add
    consider_default_literal_types_redundant option supporting Bool,
    Double, Int and String. Setting this option to true lets the rule
    consider said types in declarations like let i: Int = 1 or
    let s: String = "" as redundant.
    Garric Nahapetian

Bug Fixes

  • Invalid keys in a configuration don't lead to the default configuration being
    used anymore. The invalid key will just be reported but otherwise ignored.
    SimplyDanny
    #5565

  • Fix version comparison algorithm which caused some version-dependent rules to
    misbehave with Swift 5.10.
    chandlerwall
    #5517

  • Silence discarded_notification_center_observer rule in closures. Furthermore,
    handle get and set accessors correctly and consider implicit returns.
    SimplyDanny
    #4801

  • Fix some false positives in let_var_whitespace rule that would happen
    when attributes attached to declarations were spread over multiple lines.
    SimplyDanny
    #4801

  • Support private_over_fileprivate rule for actors.
    SimplyDanny
    #5489

  • Ensure that declarations referenced only as extended types do not count as
    used by means of the unused_declaration rule.
    SimplyDanny
    #5550

  • Fix some false positives in multiline_literal_brackets rule that would
    happen when comments are present.
    Marcelo Fabri

  • Fix some false positives in the opening_brace rule.
    kishikawakatsumi
    SimplyDanny
    #4610
    #5114
    #3470
    #3574
    #2632
    #3476
    #3756
    #3690

  • Ignore overridden functions with default parameters in the unneeded_override
    rule as they might change behavior.
    SimplyDanny
    #5355

  • Trigger nsobject_prefer_isequal and redundant_self_in_closure even in case
    the surrounding declaration is nested in an extension.
    SimplyDanny

  • Fixed false positives for the no_magic_numbers rule, when they
    are defined in a tuple like let (a, b) = (5, 10) or let a = (2, 3).
    Martin Redington
    #5305

  • Take array and nested types into account in redundant_type_annotation rule.
    SimplyDanny
    #3141
    #3146

  • Silence pattern_matching_keywords rule when an identifier is referenced
    in the argument list of a matching enum case.
    SimplyDanny
    #3852

  • Don't trigger the return_value_from_void_function warning from initializers.
    mrbkap

  • Fixes superfluous warnings about configurations for rules that were not
    enabled, when the rules were enabled in a parent configuration.
    Martin Redington
    #4858

  • Add all pseudo-rule for analyzer_rules - enables all analyzer rules
    that are not listed in disabled_rules.
    woxtu
    Martin Redington
    #4999

  • Updates the reasons provided by violations of the blanket_disable_command
    to omit language about the end of the file, and to direct users to
    re-enable the rule as soon as possible.
    Martin Redington
    #5450


Using Bazel

With bzlmod:

// Pending BCR update
bazel_dep(name = "swiftlint", version = "0.55.0", repo_name = "SwiftLint")

Without bzlmod, put this in your WORKSPACE:

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

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

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

apple_rules_dependencies()

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

swift_rules_dependencies()

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

swift_rules_extra_dependencies()

http_archive(
    name = "SwiftLint",
    sha256 = "e69564e8a0e0b9f0695d398f076f125af86666223c1dd6a88ae213e5334ebffc",
    url = "https://github.com/realm/SwiftLint/releases/download/0.55.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