0.52.1: Crisp Clear Pleats
Bug Fixes
-
Let the
validates_start_with_lowercase
option in name configurations
expect a severity (warning or error). Not setting it disables the check.
Boolean values are now deprecated. Atrue
value enables the check as an
error for the time being to keep the previous behavior.
SimplyDanny
#2180 -
Fixed a false positive in
unhandled_throwing_task
.
kylebshr
#4984 -
Fix Bazel release tarball for compiling on macOS.
JP Simard
#4985
0.52.0: Crisp Clear Pleats
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 settingattributes_with_arguments_always_on_line_above
to `false.
SimplyDanny
#4843 -
The internal module structure for SwiftLint has changed to split the
monolithicSwiftLintFramework
into newSwiftLintCore
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 onif
-statements when an
attachedelse
-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 usedself
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
- Strongly captured
-
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
justone-argument-asserts
ortwo-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 theno_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()
, andtearDownWithError()
inXCTestCase
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 istrue
by default.
Setting it tofalse
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
onreduce
methods with a first named
argument that is different frominto
.
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.1", 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 = "22973f004310a1e5611ae6d08077e907be4883929d10c049cc0b9846463b3d9a",
url = "https://github.com/realm/SwiftLint/releases/download/0.52.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