Skip to content

0.52.0: Crisp Clear Pleats

Compare
Choose a tag to compare
@jpsim jpsim released this 10 May 19:16
· 384 commits to main since this release
97259e2

Breaking

  • The attributes rule now expects attributes with arguments to be placed
    on their own line above the declaration they are supposed to influence.
    This applies to attributes with any kinds of arguments including single
    key path arguments which were previously handled in a different way. This
    behavior can be turned off by setting attributes_with_arguments_always_on_line_above
    to `false.
    SimplyDanny
    #4843

  • The internal module structure for SwiftLint has changed to split the
    monolithic SwiftLintFramework into new SwiftLintCore for core linter
    infrastructure, SwiftLintBuiltInRules for built-in rules and
    SwiftLintExtraRules to add your own native rules to SwiftLint.
    JP Simard

Experimental

  • None.

Enhancements

  • Add new superfluous_else rule that triggers on if-statements when an
    attached else-block can be removed, because all branches of the previous
    if-block(s) would certainly exit the current scope already.
    SimplyDanny

  • Add sorted_enum_cases rule which warns when enum cases are not sorted.
    kimdv

  • Add new redundant_self_in_closure rule that triggers in closures on
    explicitly used self when it's actually not needed due to:

    • Strongly captured self ({ [self] in ... })
    • Closure used in a struct declaration (self can always be omitted)
    • Anonymous closures that are directly called ({ ... }()) as they are
      definitly not escaping
    • Weakly captured self with explicit unwrapping

    SimplyDanny
    #59

  • Extend xct_specific_matcher rule to check for boolean asserts on (un)equal
    comparisons. The rule can be configured with the matchers that should trigger
    rule violations. By default, all matchers trigger, but that can be limited to
    just one-argument-asserts or two-argument-asserts.
    SimplyDanny
    JP Simard
    #3726

  • Trigger prefer_self_in_static_references rule on more type references.
    SimplyDanny

  • Adds a new reporters command, to improve discoverability of reporters.
    Martin Redington
    #4819

  • Adds test_parent_classes option to the no_magic_numbers rule.
    Violations within test classes will now be ignored by default.
    Martin Redington
    #4896

  • Stop enforcing calls to super from the override functions setUp(),
    tearDown(), setUpWithError(), and tearDownWithError() in XCTestCase
    subclasses.
    AndrewDMontgomery
    #4875

  • Prepend warning: to error messages so that they show in Xcode.
    whiteio
    #4923

  • The attributes rule received a new boolean option
    attributes_with_arguments_always_on_line_above which is true by default.
    Setting it to false ensures that attributes with arguments like
    @Persisted(primaryKey: true) don't violate the rule if they are on the same
    line with the variable declaration.
    SimplyDanny
    #4843

  • Add new unhandled_throwing_task rule that triggers when a Task with an
    implicit error type has unhandled trys or errors thrown inside its body.
    This results in errors being silently discarded, which may be unexpected.
    See this forum thread for more details: https://forums.swift.org/t/56066
    kylebshr

Bug Fixes

  • Fix lower_acl_than_parent rule rewriter by preserving leading whitespace.
    SimplyDanny
    #4860

  • Ignore block comments in let_var_whitespace rule.
    SimplyDanny
    #4871

  • Fix false positives in indentation_width rule.
    Sven Münnich

  • Do not trigger reduce_boolean on reduce methods with a first named
    argument that is different from into.
    SimplyDanny
    #4894

  • Work around dyld warning about duplicate SwiftSyntax classes.
    keith
    #4782

  • Improve lint times of SwiftLintPlugin by moving the
    excludedPaths(fileManager:) operation out of the linting iterations.
    andyyhope
    #4844


Using Bazel

With bzlmod:

bazel_dep(name = "swiftlint", version = "0.52.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 = "c5021aff12fd0e0cbf17c232d8f0e28a27ccf886d5a871681cb78f7b30a20faa",
    url = "https://github.com/realm/SwiftLint/releases/download/0.52.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