Breaking
- The
ignored_literal_argument_functionsoption of theforce_unwrappingrule 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_functionsto 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\nas line ending in all linted files.
compnerd
roman-bcny
SimplyDanny
#6351
#6352 -
Rename
allow_implicit_inittoinclude_implicit_initfor the
optional_data_string_conversionrule 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
-
Fix false positive in
accessibility_label_for_imagerule for images inside
SwiftUILabel'sicon:closure, which are inherently labeled by the
Label's text content.
sutheesh
#6420
Bug Fixes
-
Fix
literal_expression_end_indentationautocorrection 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) toSelfinprefer_self_in_static_referenceswhen inside a
class-like scope.Selfis the dynamic type, so the rewrite silently changed
runtime behavior for non-final classes (x is Selfis not equivalent to
x is A). Mirrors the rule's existingX.selfskip; static member references
such asA.f()are still corrected.
Brett-Best
#6764 -
Avoid false positives in
vertical_parameter_alignmentwhen 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_lengthwhen
ignores_function_declarationsis enabled.
leno23
#5648 -
Make
Glob.expandGlobstartolerant 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 lazyURL
enumerator that has a per-item error handler so unreadable items are
skipped individually.
Chupik -
Avoid false positives in
prefer_self_in_static_referencesfor generic
constraints and generic parameter bounds such aswhere A: Pand<A: P>
in classes and extensions.
SimplyDanny
#6674 -
Don't rewrite a type reference to
Selfinprefer_self_in_static_references
when it appears in a protocol composition (such asany A & B), as the
constraint of an existential or opaque type (such asany Aorsome A), or
as the base of an existential metatype (such asA.Protocol), since the named
type is not interchangeable withSelfin 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