Skip to content

0.51.0: bzllint

Compare
Choose a tag to compare
@jpsim jpsim released this 27 Mar 15:45
· 639 commits to main since this release
eb85125

0.51.0: bzllint

Breaking

  • Deprecate the unused_capture_list rule in favor of the Swift compiler
    warning. At the same time, make it an opt-in rule.
    Cyberbeni
    #4656

  • Deprecate the inert_defer rule in favor of the Swift compiler warning.
    At the same time, make it an opt-in rule.
    SimplyDanny
    #4615

Experimental

  • None.

Enhancements

  • Add duplicate_conditions rule which warns when a condition is duplicated
    in separate branches of the same branching statement (if-else, or switch).
    1in1
    #4666

  • Add local links to rule descriptions to every rule listed
    in Rule Directory.md.
    kattouf

  • Make forceExclude work with directly specified files.
    jimmya
    #4609

  • Adds all pseudo-rule for opt_in_rules - enables all opt in rules
    that are not listed in disabled_rules
    Martin Redington
    #4540

  • Separate analyzer rules as an independent section in the rule directory of
    the reference.
    Ethan Wong
    #4664

  • Add rule identifier to output of Emoji reporter.
    SimplyDanny
    #4707

  • Interpret strings in excluded option of identifier_name,
    type_name and generic_type_name rules as regex.
    Moly
    #4655

  • Add new direct_return rule that triggers on return statements returning
    variables that have been declared in the statement before only.
    SimplyDanny

  • Add period_spacing opt-in rule that checks periods are not followed
    by 2 or more spaces in comments.
    Julioacarrettoni
    #4624

  • Allow to pass a rule identifier to the swiftlint docs command to open its
    specific documentation website, e.g. swiftlint docs for_where.
    SimplyDanny
    #4707

  • Allow new Quick APIs aroundEach and justBeforeEach for
    quick_discouraged_call.
    David Steinacher
    #4626

  • Add relative-path reporter to generate reports with relative file paths.
    Roya1v
    #4660

  • Let number_separator rule trigger on misplaced separators, e.g. 10_00.
    SimplyDanny
    #4637

  • Rewrite multiline_arguments rule using SwiftSyntax, ignoring trailing
    closures.
    Marcelo Fabri
    #3399
    #3605

  • Speed up linting by up to 6% updating to use a newer version of
    SwiftSyntax.
    JP Simard

  • Catch more valid legacy_multiple violations.
    JP Simard

  • Catch more valid no_magic_numbers violations.
    JP Simard

  • Add blanket_disable_command rule that checks whether
    rules are re-enabled after being disabled.
    Martin Redington
    #4731

  • Add invalid_swiftlint_command rule that validates
    // swiftlint:enable and disable commands.
    Martin Redington
    #4546

  • Improve identifier_name documentation.
    Martin Redington
    #4767

  • Adds include_multiline_strings option to indentation_width rule.
    Martin Redington
    #4248

  • Adds a new summary reporter, that displays the number of violations
    of each rule in a text table.
    Martin Redington

Bug Fixes

  • Report violations in all <scope>_length rules when the error threshold is
    smaller than the warning threshold.
    SimplyDanny
    #4645

  • Consider custom attributes in attributes rule.
    SimplyDanny
    #4599

  • Fix whitespaces issue in auto-fix of redundant_optional_initialization
    rule when multiple variable declaration are involved.
    SimplyDanny
    #4794

  • Stop triggering strict_fileprivate rule on symbols implementing a protocol
    in the same file.
    SimplyDanny
    #4692

  • Fix false positives on private_subject rule when using
    subjects inside functions.
    Marcelo Fabri
    #4643

  • Fix for compiler directives masking subsequent opening_brace
    violations.
    Martin Redington
    #3712

  • Rewrite explicit_type_interface rule with SwiftSyntax fixing a
    false-positive in if-case-let statements.
    SimplyDanny
    #4548

  • Stop triggering unused_capture_list on captured variable that is only
    referenced by a shorthand optional binding (if let capturedVar { ... }).
    SimplyDanny
    #4804

  • Ensure that negative literals in initializers do not trigger
    no_magic_numbers rule.
    SimplyDanny
    #4677

  • Fix caching of indentation_width rule.
    SimplyDanny
    #4121

  • Updated JUnit reporter to output error count and warning count.
    patricks
    #4725

  • Fix correction on lower_acl_than_parent rule for open declarations.
    Marcelo Fabri
    #4753

  • Fix void_return rule to support async and async throws functions.
    Mathias Schreck
    #4772

  • Fix false positives in attributes rule when using property wrappers
    with keypath arguments.
    JP Simard

  • Fix for superfluous_disable_command not being completely disabled
    by disable commands.
    Martin Redington
    #4788

  • Fixed correction for trailing_comma rule wrongly removing trailing
    comments.
    Martin Redington
    #4814


Using Bazel

With bzlmod:

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