github realm/SwiftLint 0.64.0
0.64.0: All Windows Opened

5 hours ago

Breaking

  • The ignored_literal_argument_functions option of the force_unwrapping rule now
    uses the configured value as-is instead of always merging in the five built-in defaults
    (URL(string:), NSURL(string:), UIImage(named:), NSImage(named:), Data(hexString:)).
    Those five functions remain the default when the option is not configured, but setting
    ignored_literal_argument_functions to any explicit list — including [] — now fully
    replaces the defaults. Configurations that add functions on top of the defaults must now
    explicitly include the five previously-default functions in their list.
    SimplyDanny
    #6675

Experimental

  • None.

Enhancements

  • SwiftLint can now be built and run on Windows. It is expected to work in the same way as
    on other platforms. The only restrictions are missing support for ?[] glob patterns in
    include/exclude patterns and the requirement for \n as line ending in all linted files.
    compnerd
    roman-bcny
    SimplyDanny
    #6351
    #6352

  • Rename allow_implicit_init to include_implicit_init for the
    optional_data_string_conversion rule to convey its purpose more clearly.
    SimplyDanny
    #6670

  • Improve linting performance by 10-15%, especially when running with many
    threads, by optimizing cache locking and reducing contention. Depending on
    the project and level of concurrency, the performance improvement can be even
    higher (3-4x).
    SimplyDanny

  • Rewrite the following rules with SwiftSyntax:

    • file_types_order

    SimplyDanny

  • Fix false positive in accessibility_label_for_image rule for images inside
    SwiftUI Label's icon: closure, which are inherently labeled by the
    Label's text content.
    sutheesh
    #6420

Bug Fixes

  • Fix literal_expression_end_indentation autocorrection deleting source code
    when the closing bracket of a multiline literal shares a line with the end of
    a multiline last element (e.g. ...))]). The corrector assumed everything
    before the bracket on that line was indentation and replaced it; it now moves
    only the bracket to its own line at the expected indentation.
    Luan Câmara
    #2823

  • Don't rewrite the type operand of an is / as? / as! cast (such as
    x is A) to Self in prefer_self_in_static_references when inside a
    class-like scope. Self is the dynamic type, so the rewrite silently changed
    runtime behavior for non-final classes (x is Self is not equivalent to
    x is A). Mirrors the rule's existing X.self skip; static member references
    such as A.f() are still corrected.
    Brett-Best
    #6764

  • Avoid false positives in vertical_parameter_alignment when a parameter is
    preceded by multi-byte characters, such as a function name containing
    non-ASCII letters. Alignment is now compared by visible column rather than by
    UTF-8 byte offset.
    systemBlue
    #5037

  • Treat macro declarations like function declarations for line_length when
    ignores_function_declarations is enabled.
    leno23
    #5648

  • Make Glob.expandGlobstar tolerant of unreadable directory entries on
    large trees. subpathsOfDirectory(atPath:) aborted the entire glob
    expansion on the first unreadable entry (permission denied, dangling
    symlink, file removed mid-scan), causing most files in large projects to
    be silently ignored. Replace the directory walk with a lazy URL
    enumerator that has a per-item error handler so unreadable items are
    skipped individually.
    Chupik

  • Avoid false positives in prefer_self_in_static_references for generic
    constraints and generic parameter bounds such as where A: P and <A: P>
    in classes and extensions.
    SimplyDanny
    #6674

  • Don't rewrite a type reference to Self in prefer_self_in_static_references
    when it appears in a protocol composition (such as any A & B), as the
    constraint of an existential or opaque type (such as any A or some A), or
    as the base of an existential metatype (such as A.Protocol), since the named
    type is not interchangeable with Self in those positions.
    Brett-Best
    #6748


Using Bazel

With bzlmod:

// Pending BCR update
bazel_dep(name = "swiftlint", version = "0.64.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 = "803d94e159f64c3a75a4ee5271496911139cd6b64e362b73ae859c965cafbf34",
    url = "https://github.com/realm/SwiftLint/releases/download/0.64.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

Don't miss a new SwiftLint release

NewReleases is sending notifications on new releases.