The markdown parsing is broken/disabled for release notes. Sorry about that, I'm chasing the source of a crash that's been bringing this website down for the last couple of days.
0.51.0: bzllint
8 hours ago
## 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](https://github.com/Cyberbeni)
[#4656](https://github.com/realm/SwiftLint/issues/4656)
* Deprecate the `inert_defer` rule in favor of the Swift compiler warning.
At the same time, make it an opt-in rule.
[SimplyDanny](https://github.com/SimplyDanny)
[#4615](https://github.com/realm/SwiftLint/issues/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](https://github.com/1in1)
[#4666](https://github.com/realm/SwiftLint/issues/4666)
* Add local links to rule descriptions to every rule listed
in `Rule Directory.md`.
[kattouf](https://github.com/kattouf)
* Make forceExclude work with directly specified files.
[jimmya](https://github.com/jimmya)
[#4609](https://github.com/realm/SwiftLint/issues/4609)
* Adds `all` pseudo-rule for `opt_in_rules` - enables all opt in rules
that are not listed in `disabled_rules`
[Martin Redington](https://github.com/mildm8nnered)
[#4540](https://github.com/realm/SwiftLint/issues/4540)
* Separate analyzer rules as an independent section in the rule directory of
the reference.
[Ethan Wong](https://github.com/GetToSet)
[#4664](https://github.com/realm/SwiftLint/pull/4664)
* Add rule identifier to output of Emoji reporter.
[SimplyDanny](https://github.com/SimplyDanny)
[#4707](https://github.com/realm/SwiftLint/issues/4707)
* Interpret strings in `excluded` option of `identifier_name`,
`type_name` and `generic_type_name` rules as regex.
[Moly](https://github.com/kyounh12)
[#4655](https://github.com/realm/SwiftLint/pull/4655)
* Add new `direct_return` rule that triggers on `return` statements returning
variables that have been declared in the statement before only.
[SimplyDanny](https://github.com/SimplyDanny)
* Add `period_spacing` opt-in rule that checks periods are not followed
by 2 or more spaces in comments.
[Julioacarrettoni](https://github.com/Julioacarrettoni)
[#4624](https://github.com/realm/SwiftLint/pull/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](https://github.com/SimplyDanny)
[#4707](https://github.com/realm/SwiftLint/issues/4707)
* Allow new Quick APIs `aroundEach` and `justBeforeEach` for
`quick_discouraged_call`.
[David Steinacher](https://github.com/stonko1994)
[#4626](https://github.com/realm/SwiftLint/issues/4626)
* Add `relative-path` reporter to generate reports with relative file paths.
[Roya1v](https://github.com/roya1v)
[#4660](https://github.com/realm/SwiftLint/issues/4660)
* Let `number_separator` rule trigger on misplaced separators, e.g. `10_00`.
[SimplyDanny](https://github.com/SimplyDanny)
[#4637](https://github.com/realm/SwiftLint/issues/4637)
* Rewrite `multiline_arguments` rule using SwiftSyntax, ignoring trailing
closures.
[Marcelo Fabri](https://github.com/marcelofabri)
[#3399](https://github.com/realm/SwiftLint/issues/3399)
[#3605](https://github.com/realm/SwiftLint/issues/3605)
* Speed up linting by up to 6% updating to use a newer version of
`SwiftSyntax`.
[JP Simard](https://github.com/jpsim)
* Catch more valid `legacy_multiple` violations.
[JP Simard](https://github.com/jpsim)
* Catch more valid `no_magic_numbers` violations.
[JP Simard](https://github.com/jpsim)
* Add `blanket_disable_command` rule that checks whether
rules are re-enabled after being disabled.
[Martin Redington](https://github.com/mildm8nnered)
[#4731](https://github.com/realm/SwiftLint/pull/4731)
* Add `invalid_swiftlint_command` rule that validates
`// swiftlint:enable` and `disable` commands.
[Martin Redington](https://github.com/mildm8nnered)
[#4546](https://github.com/realm/SwiftLint/pull/4546)
* Improve `identifier_name` documentation.
[Martin Redington](https://github.com/mildm8nnered)
[#4767](https://github.com/realm/SwiftLint/issues/4767)
* Adds `include_multiline_strings` option to `indentation_width` rule.
[Martin Redington](https://github.com/mildm8nnered)
[#4248](https://github.com/realm/SwiftLint/issues/4248)
* Adds a new `summary` reporter, that displays the number of violations
of each rule in a text table.
[Martin Redington](https://github.com/mildm8nnered)
#### Bug Fixes
* Report violations in all `<scope>_length` rules when the error threshold is
smaller than the warning threshold.
[SimplyDanny](https://github.com/SimplyDanny)
[#4645](https://github.com/realm/SwiftLint/issues/4645)
* Consider custom attributes in `attributes` rule.
[SimplyDanny](https://github.com/SimplyDanny)
[#4599](https://github.com/realm/SwiftLint/issues/4599)
* Fix whitespaces issue in auto-fix of `redundant_optional_initialization`
rule when multiple variable declaration are involved.
[SimplyDanny](https://github.com/SimplyDanny)
[#4794](https://github.com/realm/SwiftLint/issues/4794)
* Stop triggering `strict_fileprivate` rule on symbols implementing a protocol
in the same file.
[SimplyDanny](https://github.com/SimplyDanny)
[#4692](https://github.com/realm/SwiftLint/issues/4692)
* Fix false positives on `private_subject` rule when using
subjects inside functions.
[Marcelo Fabri](https://github.com/marcelofabri)
[#4643](https://github.com/realm/SwiftLint/issues/4643)
* Fix for compiler directives masking subsequent `opening_brace`
violations.
[Martin Redington](https://github.com/mildm8nnered)
[#3712](https://github.com/realm/SwiftLint/issues/3712)
* Rewrite `explicit_type_interface` rule with SwiftSyntax fixing a
false-positive in if-case-let statements.
[SimplyDanny](https://github.com/SimplyDanny)
[#4548](https://github.com/realm/SwiftLint/issues/4548)
* Stop triggering `unused_capture_list` on captured variable that is only
referenced by a shorthand optional binding (`if let capturedVar { ... }`).
[SimplyDanny](https://github.com/SimplyDanny)
[#4804](https://github.com/realm/SwiftLint/issues/4804)
* Ensure that negative literals in initializers do not trigger
`no_magic_numbers` rule.
[SimplyDanny](https://github.com/SimplyDanny)
[#4677](https://github.com/realm/SwiftLint/issues/4677)
* Fix caching of `indentation_width` rule.
[SimplyDanny](https://github.com/SimplyDanny)
[#4121](https://github.com/realm/SwiftLint/issues/4121)
* Updated JUnit reporter to output error count and warning count.
[patricks](https://github.com/patricks)
[#4725](https://github.com/realm/SwiftLint/pull/4725)
* Fix correction on `lower_acl_than_parent` rule for `open` declarations.
[Marcelo Fabri](https://github.com/marcelofabri)
[#4753](https://github.com/realm/SwiftLint/issues/4753)
* Fix `void_return` rule to support async and async throws functions.
[Mathias Schreck](https://github.com/lo1tuma)
[#4772](https://github.com/realm/SwiftLint/issues/4772)
* Fix false positives in `attributes` rule when using property wrappers
with keypath arguments.
[JP Simard](https://github.com/jpsim)
* Fix for `superfluous_disable_command` not being completely disabled
by `disable` commands.
[Martin Redington](https://github.com/mildm8nnered)
[#4788](https://github.com/realm/SwiftLint/issues/4788)
* Fixed correction for `trailing_comma` rule wrongly removing trailing
comments.
[Martin Redington](https://github.com/mildm8nnered)
[#4814](https://github.com/realm/SwiftLint/issues/4814)
---
### Using Bazel
With bzlmod:
```
TODO...
```
Without bzlmod, put this in your `WORKSPACE`:
<details>
<summary>WORKSPACE</summary>
```python
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()
```
</details>
Then you can run SwiftLint in the current directory with this command:
```console
bazel run @SwiftLint//:swiftlint -- --help
```
0.51.0-rc.2: bzllint
5 weeks ago
This is a prerelease version. It won't be published to Homebrew, CocoaPods or bzlmod. But there are many other ways to install:
* Downloading the attached `SwiftLint.pkg` installer and launching it
* Downloading the attached `portable_swiftlint.zip` archive, extracting it and moving the binary from `portable_swiftlint/swiftlint` to `/usr/local/bin` or elsewhere in your `PATH`
* Using [Mint](https://github.com/yonaskolb/Mint): `mint install realm/
[email protected]`
* Cloning and building from source: `git clone https://github.com/realm/SwiftLint.git && cd SwiftLint && git checkout 0.51.0-rc.2 && make install`
* Docker: ```docker run -it -v `pwd`:`pwd` -w `pwd` ghcr.io/realm/swiftlint:0.51.0-rc.2```
* Bazel: See instructions at the bottom
Changes from 0.50.3: https://github.com/realm/SwiftLint/compare/0.50.3...0.51.0-rc.2
Changes from 0.51.0-rc.1: https://github.com/realm/SwiftLint/compare/0.51.0-rc.1...0.51.0-rc.2
---
#### 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](https://github.com/Cyberbeni)
[#4656](https://github.com/realm/SwiftLint/issues/4656)
* Deprecate the `inert_defer` rule in favor of the Swift compiler warning.
At the same time, make it an opt-in rule.
[SimplyDanny](https://github.com/SimplyDanny)
[#4615](https://github.com/realm/SwiftLint/issues/4615)
#### Experimental
* None.
#### Enhancements
* Add local links to rule descriptions to every rule listed
in `Rule Directory.md`.
[kattouf](https://github.com/kattouf)
* Make forceExclude work with directly specified files.
[jimmya](https://github.com/jimmya)
[#issue_number](https://github.com/realm/SwiftLint/issues/4609)
* Separate analyzer rules as an independent section in the rule directory of
the reference.
[Ethan Wong](https://github.com/GetToSet)
[#4664](https://github.com/realm/SwiftLint/pull/4664)
* Add rule identifier to output of Emoji reporter.
[SimplyDanny](https://github.com/SimplyDanny)
[#4707](https://github.com/realm/SwiftLint/issues/4707)
* Interpret strings in `excluded` option of `identifier_name`,
`type_name` and `generic_type_name` rules as regex.
[Moly](https://github.com/kyounh12)
[#4655](https://github.com/realm/SwiftLint/pull/4655)
* Add new `direct_return` rule that triggers on `return` statements returning
variables that have been declared in the statement before only.
[SimplyDanny](https://github.com/SimplyDanny)
* Add `period_spacing` opt-in rule that checks periods are not followed
by 2 or more spaces in comments.
[Julioacarrettoni](https://github.com/Julioacarrettoni)
[#4624](https://github.com/realm/SwiftLint/pull/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](https://github.com/SimplyDanny)
[#4707](https://github.com/realm/SwiftLint/issues/4707)
* Allow new Quick APIs `aroundEach` and `justBeforeEach` for
`quick_discouraged_call`.
[David Steinacher](https://github.com/stonko1994)
[#4626](https://github.com/realm/SwiftLint/issues/4626)
* Add `relative-path` reporter to generate reports with relative file paths.
[Roya1v](https://github.com/roya1v)
[#4660](https://github.com/realm/SwiftLint/issues/4660)
* Let `number_separator` rule trigger on misplaced separators, e.g. `10_00`.
[SimplyDanny](https://github.com/SimplyDanny)
[#4637](https://github.com/realm/SwiftLint/issues/4637)
* Rewrite `multiline_arguments` rule using SwiftSyntax, ignoring trailing
closures.
[Marcelo Fabri](https://github.com/marcelofabri)
[#3399](https://github.com/realm/SwiftLint/issues/3399)
[#3605](https://github.com/realm/SwiftLint/issues/3605)
* Speed up linting by up to 6% updating to use a newer version of
`SwiftSyntax`.
[JP Simard](https://github.com/jpsim)
* Catch more valid `legacy_multiple` violations.
[JP Simard](https://github.com/jpsim)
* Catch more valid `no_magic_numbers` violations.
[JP Simard](https://github.com/jpsim)
#### Bug Fixes
* Report violations in all `<scope>_length` rules when the error threshold is
smaller than the warning threshold.
[SimplyDanny](https://github.com/SimplyDanny)
[#4645](https://github.com/realm/SwiftLint/issues/4645)
* Consider custom attributes in `attributes` rule.
[SimplyDanny](https://github.com/SimplyDanny)
[#4599](https://github.com/realm/SwiftLint/issues/4599)
* Stop triggering `strict_fileprivate` rule on symbols implementing a protocol
in the same file.
[SimplyDanny](https://github.com/SimplyDanny)
[#4692](https://github.com/realm/SwiftLint/issues/4692)
* Fix false positives on `private_subject` rule when using
subjects inside functions.
[Marcelo Fabri](https://github.com/marcelofabri)
[#4643](https://github.com/realm/SwiftLint/issues/4643)
* Fix for compiler directives masking subsequent `opening_brace`
violations.
[Martin Redington](https://github.com/mildm8nnered)
[#3712](https://github.com/realm/SwiftLint/issues/3712)
* Rewrite `explicit_type_interface` rule with SwiftSyntax fixing a
false-positive in if-case-let statements.
[SimplyDanny](https://github.com/SimplyDanny)
[#4548](https://github.com/realm/SwiftLint/issues/4548)
* Ensure that negative literals in initializers do not trigger
`no_magic_numbers` rule.
[SimplyDanny](https://github.com/SimplyDanny)
[#4677](https://github.com/realm/SwiftLint/issues/4677)
* Fix caching of `indentation_width` rule.
[SimplyDanny](https://github.com/SimplyDanny)
[#4121](https://github.com/realm/SwiftLint/issues/4121)
* Updated JUnit reporter to output error count and warning count.
[patricks](https://github.com/patricks)
[#4725](https://github.com/realm/SwiftLint/pull/4725)
* Fix correction on `lower_acl_than_parent` rule for `open` declarations.
[Marcelo Fabri](https://github.com/marcelofabri)
[#4753](https://github.com/realm/SwiftLint/issues/4753)
* Fix `void_return` rule to support async and async throws functions.
[Mathias Schreck](https://github.com/lo1tuma)
[#4772](https://github.com/realm/SwiftLint/issues/4772)
* Fix false positives in `attributes` rule when using property wrappers
with keypath arguments.
[JP Simard](https://github.com/jpsim)
---
### Using Bazel
Put this in your `WORKSPACE`:
<details>
<summary>WORKSPACE</summary>
```python
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "build_bazel_rules_apple",
sha256 = "43737f28a578d8d8d7ab7df2fb80225a6b23b9af9655fcdc66ae38eb2abcf2ed",
url = "https://github.com/bazelbuild/rules_apple/releases/download/2.0.0/rules_apple.2.0.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 = "f0e37c2ca277ef8c50d865cbdb75326592bcba11b786caf1fccc3111e9925e01",
url = "https://github.com/realm/SwiftLint/releases/download/0.51.0-rc.2/bazel.tar.gz",
)
load("@SwiftLint//bazel:repos.bzl", "swiftlint_repos")
swiftlint_repos()
load("@SwiftLint//bazel:deps.bzl", "swiftlint_deps")
swiftlint_deps()
```
</details>
Then you can run SwiftLint in the current directory with this command:
```console
bazel run @SwiftLint//:swiftlint -- --help
```
0.51.0-rc.1: bzllint
5 weeks ago
This is a prerelease version. It won't be published to Homebrew, CocoaPods or bzlmod. But there are many other ways to install:
* Downloading the attached `SwiftLint.pkg` installer and launching it
* Downloading the attached `portable_swiftlint.zip` archive, extracting it and moving the binary from `portable_swiftlint/swiftlint` to `/usr/local/bin` or elsewhere in your `PATH`
* Using [Mint](https://github.com/yonaskolb/Mint): `mint install realm/
[email protected]`
* Cloning and building from source: `git clone https://github.com/realm/SwiftLint.git && cd SwiftLint && git checkout 0.51.0-rc.1 && make install`
* Docker: ```docker run -it -v `pwd`:`pwd` -w `pwd` ghcr.io/realm/swiftlint:0.51.0-rc.1```
* Bazel: See instructions at the bottom
Changes from 0.50.3: https://github.com/realm/SwiftLint/compare/0.50.3...0.51.0-rc.1
---
#### 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](https://github.com/Cyberbeni)
[#4656](https://github.com/realm/SwiftLint/issues/4656)
* Deprecate the `inert_defer` rule in favor of the Swift compiler warning.
At the same time, make it an opt-in rule.
[SimplyDanny](https://github.com/SimplyDanny)
[#4615](https://github.com/realm/SwiftLint/issues/4615)
#### Experimental
* None.
#### Enhancements
* Add local links to rule descriptions to every rule listed
in `Rule Directory.md`.
[kattouf](https://github.com/kattouf)
* Make forceExclude work with directly specified files.
[jimmya](https://github.com/jimmya)
[#issue_number](https://github.com/realm/SwiftLint/issues/4609)
* Separate analyzer rules as an independent section in the rule directory of
the reference.
[Ethan Wong](https://github.com/GetToSet)
[#4664](https://github.com/realm/SwiftLint/pull/4664)
* Add rule identifier to output of Emoji reporter.
[SimplyDanny](https://github.com/SimplyDanny)
[#4707](https://github.com/realm/SwiftLint/issues/4707)
* Interpret strings in `excluded` option of `identifier_name`,
`type_name` and `generic_type_name` rules as regex.
[Moly](https://github.com/kyounh12)
[#4655](https://github.com/realm/SwiftLint/pull/4655)
* Add new `direct_return` rule that triggers on `return` statements returning
variables that have been declared in the statement before only.
[SimplyDanny](https://github.com/SimplyDanny)
* Add `period_spacing` opt-in rule that checks periods are not followed
by 2 or more spaces in comments.
[Julioacarrettoni](https://github.com/Julioacarrettoni)
[#4624](https://github.com/realm/SwiftLint/pull/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](https://github.com/SimplyDanny)
[#4707](https://github.com/realm/SwiftLint/issues/4707)
* Allow new Quick APIs `aroundEach` and `justBeforeEach` for
`quick_discouraged_call`.
[David Steinacher](https://github.com/stonko1994)
[#4626](https://github.com/realm/SwiftLint/issues/4626)
* Add `relative-path` reporter to generate reports with relative file paths.
[Roya1v](https://github.com/roya1v)
[#4660](https://github.com/realm/SwiftLint/issues/4660)
* Let `number_separator` rule trigger on misplaced separators, e.g. `10_00`.
[SimplyDanny](https://github.com/SimplyDanny)
[#4637](https://github.com/realm/SwiftLint/issues/4637)
* Rewrite `multiline_arguments` rule using SwiftSyntax, ignoring trailing
closures.
[Marcelo Fabri](https://github.com/marcelofabri)
[#3399](https://github.com/realm/SwiftLint/issues/3399)
[#3605](https://github.com/realm/SwiftLint/issues/3605)
* Speed up linting by up to 6% updating to use a newer version of
`SwiftSyntax`.
[JP Simard](https://github.com/jpsim)
* Catch more valid `legacy_multiple` violations.
[JP Simard](https://github.com/jpsim)
* Catch more valid `no_magic_numbers` violations.
[JP Simard](https://github.com/jpsim)
#### Bug Fixes
* Report violations in all `<scope>_length` rules when the error threshold is
smaller than the warning threshold.
[SimplyDanny](https://github.com/SimplyDanny)
[#4645](https://github.com/realm/SwiftLint/issues/4645)
* Consider custom attributes in `attributes` rule.
[SimplyDanny](https://github.com/SimplyDanny)
[#4599](https://github.com/realm/SwiftLint/issues/4599)
* Stop triggering `strict_fileprivate` rule on symbols implementing a protocol
in the same file.
[SimplyDanny](https://github.com/SimplyDanny)
[#4692](https://github.com/realm/SwiftLint/issues/4692)
* Fix false positives on `private_subject` rule when using
subjects inside functions.
[Marcelo Fabri](https://github.com/marcelofabri)
[#4643](https://github.com/realm/SwiftLint/issues/4643)
* Fix for compiler directives masking subsequent `opening_brace`
violations.
[Martin Redington](https://github.com/mildm8nnered)
[#3712](https://github.com/realm/SwiftLint/issues/3712)
* Rewrite `explicit_type_interface` rule with SwiftSyntax fixing a
false-positive in if-case-let statements.
[SimplyDanny](https://github.com/SimplyDanny)
[#4548](https://github.com/realm/SwiftLint/issues/4548)
* Ensure that negative literals in initializers do not trigger
`no_magic_numbers` rule.
[SimplyDanny](https://github.com/SimplyDanny)
[#4677](https://github.com/realm/SwiftLint/issues/4677)
* Fix caching of `indentation_width` rule.
[SimplyDanny](https://github.com/SimplyDanny)
[#4121](https://github.com/realm/SwiftLint/issues/4121)
* Updated JUnit reporter to output error count and warning count.
[patricks](https://github.com/patricks)
[#4725](https://github.com/realm/SwiftLint/pull/4725)
* Fix correction on `lower_acl_than_parent` rule for `open` declarations.
[Marcelo Fabri](https://github.com/marcelofabri)
[#4753](https://github.com/realm/SwiftLint/issues/4753)
* Fix `void_return` rule to support async and async throws functions.
[Mathias Schreck](https://github.com/lo1tuma)
[#4772](https://github.com/realm/SwiftLint/issues/4772)
* Fix false positives in `attributes` rule when using property wrappers
with keypath arguments.
[JP Simard](https://github.com/jpsim)
---
### Using Bazel
Put this in your `WORKSPACE`:
<details>
<summary>WORKSPACE</summary>
```python
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "build_bazel_rules_apple",
sha256 = "43737f28a578d8d8d7ab7df2fb80225a6b23b9af9655fcdc66ae38eb2abcf2ed",
url = "https://github.com/bazelbuild/rules_apple/releases/download/2.0.0/rules_apple.2.0.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 = "f44b1e1c9aac0b4febbfae8479fc4e60df099066076fb10dfc0f42fd83731170",
url = "https://github.com/realm/SwiftLint/releases/download/0.51.0-rc.1/bazel.tar.gz",
)
load("@SwiftLint//bazel:repos.bzl", "swiftlint_repos")
swiftlint_repos()
load("@SwiftLint//bazel:deps.bzl", "swiftlint_deps")
swiftlint_deps()
```
</details>
Then you can run SwiftLint in the current directory with this command:
```console
bazel run @SwiftLint//:swiftlint -- --help
```
0.50.3: Bundle of Towels
15 weeks ago
#### Breaking
* None.
#### Experimental
* None.
#### Enhancements
* The `SwiftLintPlugin` SwiftPM plugin now uses a prebuilt binary on
macOS.
[Tony Arnold](https://github.com/tonyarnold)
[JP Simard](https://github.com/jpsim)
[#4558](https://github.com/realm/SwiftLint/issues/4558)
* Don't trigger `shorthand_operator` violations inside a shorthand
operator function declaration.
[Marcelo Fabri](https://github.com/marcelofabri)
[#4611](https://github.com/realm/SwiftLint/issues/4611)
* The `balanced_xctest_lifecycle`, `single_test_class`,
`empty_xctest_method` and `test_case_accessibility` rules will now be
applied to subclasses of `QuickSpec`, as well as `XCTestCase`, by
default.
[Martin Redington](https://github.com/mildm8nnered)
* Add `test_parent_classes` option to `balanced_xctest_lifecycle`,
`single_test_class` and `empty_xctest_method` rules.
[Martin Redington](https://github.com/mildm8nnered)
[#4200](https://github.com/realm/SwiftLint/issues/4200)
* Show warnings in the console for Analyzer rules that are listed in the
`opt_in_rules` configuration section.
[SimplyDanny](https://github.com/SimplyDanny)
[#4612](https://github.com/realm/SwiftLint/issues/4612)
#### Bug Fixes
* Fix configuration parsing error in `unused_declaration` rule.
[SimplyDanny](https://github.com/SimplyDanny)
[#4612](https://github.com/realm/SwiftLint/issues/4612)
* Skip `defer` statements being last in an `#if` block if the `#if`
statement is not itself the last statement in a block.
[SimplyDanny](https://github.com/SimplyDanny)
[#4615](https://github.com/realm/SwiftLint/issues/4615)
* Fix false positives in `empty_enum_arguments` when the called
expression is an identifier or an init call.
[Steffen Matthischke](https://github.com/heeaad)
[#4597](https://github.com/realm/SwiftLint/issues/4597)
* Fix correction issue in `comma` when there was too much whitespace
following the comma.
[JP Simard](https://github.com/jpsim)
---
### Using Bazel
Put this in your `WORKSPACE`:
<details>
<summary>WORKSPACE</summary>
```python
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "build_bazel_rules_apple",
sha256 = "f94e6dddf74739ef5cb30f000e13a2a613f6ebfa5e63588305a71fce8a8a9911",
url = "https://github.com/bazelbuild/rules_apple/releases/download/1.1.3/rules_apple.1.1.3.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 = "b8c4d765bcd8b533fcc2e15f32482a1a17572f143b65af388f7d5ac99994a99a",
url = "https://github.com/realm/SwiftLint/releases/download/0.50.3/bazel.tar.gz",
)
load("@SwiftLint//bazel:repos.bzl", "swiftlint_repos")
swiftlint_repos()
load("@SwiftLint//bazel:deps.bzl", "swiftlint_deps")
swiftlint_deps()
```
</details>
Then you can run SwiftLint in the current directory with this command:
```console
bazel run -c opt @SwiftLint//:swiftlint -- --help
```
0.50.1: Artisanal Clothes Pegs Fixup Edition
17 weeks ago
#### Breaking
* None.
#### Experimental
* None.
#### Enhancements
* Moved the validation of doc comments in local scopes out of
`orphaned_doc_comment` and into a new opt-in `local_doc_comment` rule.
[JP Simard](https://github.com/jpsim)
[#4573](https://github.com/realm/SwiftLint/issues/4573)
* SwiftLint's Swift Package Build Tool Plugin will now only scan files
in the target being built.
[Tony Arnold](https://github.com/tonyarnold)
[#4406](https://github.com/realm/SwiftLint/pull/4406)
#### Bug Fixes
* Fix building with `swift build -c release`.
[JP Simard](https://github.com/jpsim)
[#4559](https://github.com/realm/SwiftLint/issues/4559)
[#4560](https://github.com/realm/SwiftLint/issues/4560)
* Fix false positives in `lower_acl_than_parent` when the nominal parent
is an extension.
[Steffen Matthischke](https://github.com/heeaad)
[#4564](https://github.com/realm/SwiftLint/issues/4564)
* Fix `minimum_fraction_length` handling in `number_separator`.
[JP Simard](https://github.com/jpsim)
[#4576](https://github.com/realm/SwiftLint/issues/4576)
* Fix false positives in `closure_spacing`.
[JP Simard](https://github.com/jpsim)
[#4565](https://github.com/realm/SwiftLint/issues/4565)
[#4582](https://github.com/realm/SwiftLint/issues/4582)
* Fix line count calculation for multiline string literals.
[JP Simard](https://github.com/jpsim)
[#4585](https://github.com/realm/SwiftLint/issues/4585)
* Fix false positives in `unused_closure_parameter` when using
identifiers with backticks.
[JP Simard](https://github.com/jpsim)
[#4588](https://github.com/realm/SwiftLint/issues/4588)
* Fix `type_name` regression where names with backticks would trigger
violations.
[JP Simard](https://github.com/jpsim)
[#4571](https://github.com/realm/SwiftLint/issues/4571)
0.50.0: Artisanal Clothes Pegs
18 weeks ago
#### Breaking
* SwiftLint now requires Swift 5.7 or higher to build.
[JP Simard](https://github.com/jpsim)
* Exclude `weak_delegate` rule from autocorrection due to behavioral changes
leading to potential undefined behavior or bugs.
[SimplyDanny](https://github.com/SimplyDanny)
[#3577](https://github.com/realm/SwiftLint/issues/3577)
* The `anyobject_protocol` rule is now deprecated and will be completely removed
in a future release because it is now handled by the Swift compiler.
[JP Simard](https://github.com/jpsim)
* Built-in SwiftLint rules are no longer marked as `public` in
SwiftLintFramework. This only impacts the programmatic API for the
SwiftLintFramework module.
[JP Simard](https://github.com/jpsim)
#### Experimental
* None.
#### Enhancements
* SwiftSyntax libraries have been updated from the previous 5.6 release and now
use the new parser written in Swift.
Swift 5.7+ features should now be parsed more accurately.
We've also measured an improvement in lint times of up to 15%.
This should also fix some deployment issues where the exact version of the
internal SwiftSyntax parser needed to be available.
If you notice any unexpected changes to lint results, please file an issue on
the SwiftLint issue tracker. We can look into it and if it's a SwiftSyntax
parser regression we can re-file it upstream.
[JP Simard](https://github.com/jpsim)
[#4031](https://github.com/realm/SwiftLint/issues/4031)
* Rewrite some rules with SwiftSyntax, fixing some false positives and catching
more violations:
- `anonymous_argument_in_multiline_closure`
- `array_init`
- `attributes`
- `balanced_xctest_lifecycle`
- `block_based_kvo`
- `class_delegate_protocol`
- `closing_brace`
- `closure_body_length`
- `closure_parameter_position`
- `collection_alignment`
- `comment_spacing`
- `computed_accessors_order`
- `conditional_returns_on_newline`
- `contains_over_filter_count`
- `contains_over_filter_is_empty`
- `contains_over_first_not_nil`
- `contains_over_range_nil_comparison`
- `convenience_type`
- `deployment_target`
- `discarded_notification_center_observer`
- `discouraged_assert`
- `discouraged_direct_init`
- `discouraged_none_name`
- `discouraged_object_literal`
- `discouraged_optional_boolean`
- `duplicate_enum_cases`
- `duplicated_key_in_dictionary_literal`
- `dynamic_inline`
- `empty_collection_literal`
- `empty_count`
- `empty_enum_arguments`
- `empty_parameters`
- `empty_parentheses_with_trailing_closure`
- `empty_string`
- `enum_case_associated_values_count`
- `explicit_enum_raw_value`
- `explicit_init`
- `explicit_top_level_acl`
- `fallthrough`
- `file_name`
- `first_where`
- `flatmap_over_map_reduce`
- `for_where`
- `force_try`
- `force_unwrapping`
- `function_body_length`
- `function_default_parameter_at_end`
- `function_parameter_count`
- `generic_type_name`
- `ibinspectable_in_extension`
- `identical_operands`
- `implicit_getter`
- `implicitly_unwrapped_optional`
- `inclusive_language`
- `inert_defer`
- `is_disjoint`
- `joined_default_parameter`
- `large_tuple`
- `last_where`
- `legacy_cggeometry_functions`
- `legacy_constant`
- `legacy_constructor`
- `legacy_hashing`
- `legacy_multiple`
- `legacy_nsgeometry_functions`
- `legacy_objc_type`
- `legacy_random`
- `lower_acl_than_parent`
- `multiline_arguments_brackets`
- `multiline_parameters`
- `multiple_closures_with_trailing_closure`
- `no_extension_access_modifier`
- `no_fallthrough_only`
- `no_space_in_method_call`
- `notification_center_detachment`
- `nslocalizedstring_key`
- `nslocalizedstring_require_bundle`
- `nsobject_prefer_isequal`
- `number_separator`
- `object_literal`
- `operator_whitespace`
- `optional_enum_case_matching`
- `orphaned_doc_comment`
- `overridden_super_call`
- `override_in_extension`
- `pattern_matching_keywords`
- `prefer_nimble`
- `prefer_self_in_static_references`
- `prefer_self_type_over_type_of_self`
- `prefer_zero_over_explicit_init`
- `prefixed_toplevel_constant`
- `private_action`
- `private_outlet`
- `private_over_fileprivate`
- `private_subject`
- `private_unit_test`
- `prohibited_interface_builder`
- `prohibited_super_call`
- `protocol_property_accessors_order`
- `quick_discouraged_focused_test`
- `quick_discouraged_pending_test`
- `raw_value_for_camel_cased_codable_enum`
- `reduce_boolean`
- `reduce_into`
- `redundant_discardable_let`
- `redundant_nil_coalescing`
- `redundant_objc_attribute`
- `redundant_optional_initialization`
- `redundant_set_access_control`
- `redundant_string_enum_value`
- `required_deinit`
- `required_enum_case`
- `return_arrow_whitespace`
- `self_in_property_initialization`
- `shorthand_operator`
- `single_test_class`
- `sorted_first_last`
- `static_operator`
- `strict_fileprivate`
- `strong_iboutlet`
- `switch_case_alignment`
- `switch_case_on_newline`
- `test_case_accessibility`
- `toggle_bool`
- `trailing_comma`
- `trailing_semicolon`
- `type_body_length`
- `type_name`
- `unneeded_break_in_switch`
- `unneeded_parentheses_in_closure_argument`
- `unowned_variable_capture`
- `untyped_error_in_catch`
- `unused_capture_list`
- `unused_closure_parameter`
- `unused_control_flow_label`
- `unused_enumerated`
- `unused_optional_binding`
- `unused_setter_value`
- `valid_ibinspectable`
- `vertical_parameter_alignment`
- `weak_delegate`
- `xct_specific_matcher`
- `xctfail_message`
[Marcelo Fabri](https://github.com/marcelofabri)
[SimplyDanny](https://github.com/SimplyDanny)
[JP Simard](https://github.com/jpsim)
[#2915](https://github.com/realm/SwiftLint/issues/2915)
* The "body length" family of rules have changed how they calculate body
line count to be significantly more correct and intuitive. However,
this is likely to require adjustments to your configuration or disable
commands to account for the changes.
[JP Simard](https://github.com/jpsim)
* Add ability to filter rules for `generate-docs` subcommand.
[kattouf](https://github.com/kattouf)
* Add new `excludes_trivial_init` configuration for `missing_docs` rule
to exclude initializers without any parameters.
[Marcelo Fabri](https://github.com/marcelofabri)
[#4107](https://github.com/realm/SwiftLint/issues/4107)
* Add new `ns_number_init_as_function_reference` rule to catch `NSNumber.init`
and `NSDecimalNumber.init` being used as function references since it
can cause the wrong initializer to be used, causing crashes. See
https://github.com/apple/swift/issues/51036 for more info.
[Marcelo Fabri](https://github.com/marcelofabri)
* Add `accessibility_trait_for_button` rule to warn if a SwiftUI
View has a tap gesture added to it without having the button or
link accessibility trait.
[Ryan Cole](https://github.com/rcole34)
* Add methods from SE-0348 to `UnusedDeclarationRule`.
[JP Simard](https://github.com/jpsim)
* Include the configured `bind_identifier` in `self_binding` violation
messages.
[JP Simard](https://github.com/jpsim)
* The `self_binding` rule now catches shorthand optional bindings (for example
`if let self {}`) when using a `bind_identifier` different than `self`.
[Marcelo Fabri](https://github.com/marcelofabri)
* Add `library_content_provider` file type to `file_types_order` rule
to allow `LibraryContentProvider` to be ordered independent from `main_type`.
[dahlborn](https://github.com/dahlborn)
* Add `test_parent_classes` option to `test_case_accessibility` rule, which
allows detection in subclasses of XCTestCase.
[Martin Redington](https://github.com/mildm8nnered)
[#4200](https://github.com/realm/SwiftLint/issues/4200)
* Add a new `shorthand_optional_binding` opt-in rule that triggers in Swift 5.7
when a shadowing optional binding is created in an `if` or `guard` statement.
[SimplyDanny](https://github.com/SimplyDanny)
[#4202](https://github.com/realm/SwiftLint/issues/4202)
* Use SwiftSyntax instead of SourceKit to determine if a file has parser errors
before applying corrections. This speeds up corrections significantly when
none of the rules use SourceKit.
[JP Simard](https://github.com/jpsim)
* Add Swift Package Build Tool Plugin with support for Swift Packages
and Xcode projects.
[Johannes Ebeling](https://github.com/technocidal)
[#3679](https://github.com/realm/SwiftLint/issues/3679)
[#3840](https://github.com/realm/SwiftLint/issues/3840)
* Make `private_unit_test` rule correctable.
[SimplyDanny](https://github.com/SimplyDanny)
* Disregard whitespace differences in `identical_operands` rule. That is, the rule
now also triggers if the left-hand side and the right-hand side of an operation
only differ in trivia.
[SimplyDanny](https://github.com/SimplyDanny)
* Print violations in realtime if `--progress` and `--output` are both set.
[JP Simard](https://github.com/jpsim)
* Trigger `prefer_self_in_static_references` rule on more type references like:
* Key paths (e.g. `\MyType.myVar` -> `\Self.myVar`)
* Computed properties (e.g. `var i: Int { MyType.myVar )` -> `var i: Int { Self.myVar }`)
* Constructor calls (e.g. `MyType()` -> `Self()`)
[SimplyDanny](https://github.com/SimplyDanny)
* Update `for_where` rule, adding a new configuration
`allow_for_as_filter` to allow using `for in` with a single `if` inside
when there's a `return` statement inside the `if`'s body.
[Marcelo Fabri](https://github.com/marcelofabri)
[#4040](https://github.com/realm/SwiftLint/issues/4040)
* `quick_discouraged_call`, `quick_discouraged_focused_test` and
`quick_discouraged_pending_test` rules now trigger on subclasses of
`QuickSpec`.
[Marcelo Fabri](https://github.com/marcelofabri)
[#4420](https://github.com/realm/SwiftLint/issues/4420)
* The `type_name` rule now validates protocol declarations by default.
You can opt-out by using the `validate_protocols` key in your configuration:
```yml
type_name:
validate_protocols: false
```
[Marcelo Fabri](https://github.com/marcelofabri)
[#4430](https://github.com/realm/SwiftLint/issues/4430)
* Report how much memory was used when `--benchmark` is specified.
[JP Simard](https://github.com/jpsim)
* Adds `NSError` to the list of types in `discouraged_direct_init`.
[jszumski](https://github.com/jszumski)
[#4508](https://github.com/realm/SwiftLint/issues/4508)
* Fix SwiftLint support on Xcode Cloud.
[JagCesar](https://github.com/JagCesar)
[westerlund](https://github.com/westerlund)
[#4484](https://github.com/realm/SwiftLint/issues/4484)
* Add `no_magic_numbers` rule to avoid "Magic Numbers".
[Henrik Storch](https://github.com/thisisthefoxe)
[#4031](https://github.com/realm/SwiftLint/issues/4024)
* Add new option `only_enforce_before_trivial_lines` to
`vertical_whitespace_closing_braces` rule. It restricts
the rule to apply only before trivial lines (containing
only closing braces, brackets and parentheses). This
allows empty lines before non-trivial lines of code
(e.g. if-else-statements).
[benjamin-kramer](https://github.com/benjamin-kramer)
[#3940](https://github.com/realm/SwiftLint/issues/3940)
#### Bug Fixes
* Respect `validates_start_with_lowercase` option when linting function names.
[Chris Brakebill](https://github.com/braker1nine)
[#2708](https://github.com/realm/SwiftLint/issues/2708)
* Do not report variables annotated with `@NSApplicationDelegateAdaptor` and
`@WKExtensionDelegateAdaptor` in `weak_delegate` rule.
[Till Hainbach](https://github.com/tillhainbach)
[#3598](https://github.com/realm/SwiftLint/issues/3456)
[#3611](https://github.com/realm/SwiftLint/issues/3611)
* Fix false-positives related to the `willMove` lifecycle method in
`type_contents_order` rule.
[SimplyDanny](https://github.com/SimplyDanny)
[#3478](https://github.com/realm/SwiftLint/issues/3478)
* Do no longer autocorrect usage of `NSIntersectionRect` in `legacy_nsgeometry_functions`
rule.
[SimplyDanny](https://github.com/SimplyDanny)
[#3703](https://github.com/realm/SwiftLint/issues/3703)
* Fix Analyzer rules in Xcode 14.
[SimplyDanny](https://github.com/SimplyDanny)
[#4208](https://github.com/realm/SwiftLint/issues/4208)
* Add column for SourceKit usage to `rules` command.
[JP Simard](https://github.com/jpsim)
* Make `nsobject_prefer_isequal` rule work for nested `@objc` classes. Also consider
the `@objcMembers` annotation.
[SimplyDanny](https://github.com/SimplyDanny)
* Print fixed content at most once to STDOUT.
[SimplyDanny](https://github.com/SimplyDanny)
[#4211](https://github.com/realm/SwiftLint/issues/4211)
* Fix fatal error when content given via STDIN is corrected in the
`trailing_newline` rule.
[SimplyDanny](https://github.com/SimplyDanny)
[#4234](https://github.com/realm/SwiftLint/issues/4234)
* Fix false-positives from `multiline_arguments_brackets` when a function call has a
single line trailing closure.
[CraigSiemens](https://github.com/CraigSiemens)
[#4510](https://github.com/realm/SwiftLint/issues/4510)
---
### Using Bazel
Put this in your `WORKSPACE`:
<details>
<summary>WORKSPACE</summary>
```python
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "build_bazel_rules_apple",
sha256 = "f94e6dddf74739ef5cb30f000e13a2a613f6ebfa5e63588305a71fce8a8a9911",
url = "https://github.com/bazelbuild/rules_apple/releases/download/1.1.3/rules_apple.1.1.3.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 = "c99be76ea5efd6ff7e60b6df8a11b709d50c75dfdbd6fb429de9bbe9e45cdb1f",
url = "https://github.com/realm/SwiftLint/releases/download/0.50.0/bazel.tar.gz",
)
load("@SwiftLint//bazel:repos.bzl", "swiftlint_repos")
swiftlint_repos()
load("@SwiftLint//bazel:deps.bzl", "swiftlint_deps")
swiftlint_deps()
```
</details>
Then you can run SwiftLint in the current directory with this command:
```console
bazel run @SwiftLint//:swiftlint -- --help
```
0.50.0-rc.4: Artisanal Clothes Pegs
20 weeks ago
This is a prerelease version. It won't be published to Homebrew or CocoaPods. But there are many other ways to install:
* Downloading the attached `SwiftLint.pkg` installer and launching it
* Downloading the attached `portable_swiftlint.zip` archive, extracting it and moving the binary from `portable_swiftlint/swiftlint` to `/usr/local/bin` or elsewhere in your `PATH`
* Using [Mint](https://github.com/yonaskolb/Mint): `mint install realm/
[email protected]`
* Cloning and building from source: `git clone https://github.com/realm/SwiftLint.git && cd SwiftLint && git checkout 0.50.0-rc.4 && make install`
* Docker: ```docker run -it -v `pwd`:`pwd` -w `pwd` ghcr.io/realm/swiftlint:0.50.0-rc.4```
* Bazel: See instructions at the bottom
Changes from 0.49.1: https://github.com/realm/SwiftLint/compare/0.49.1...0.50.0-rc.4
Changes from 0.50.0-rc.3: https://github.com/realm/SwiftLint/compare/0.50.0-rc.3...0.50.0-rc.4
---
#### Breaking
* SwiftLint now requires Swift 5.7 or higher to build.
[JP Simard](https://github.com/jpsim)
* Exclude `weak_delegate` rule from autocorrection due to behavioral changes
leading to potential undefined behavior or bugs.
[SimplyDanny](https://github.com/SimplyDanny)
[#3577](https://github.com/realm/SwiftLint/issues/3577)
* The `anyobject_protocol` rule is now deprecated and will be completely removed
in a future release because it is now handled by the Swift compiler.
[JP Simard](https://github.com/jpsim)
#### Experimental
* None.
#### Enhancements
* Adds `NSError` to the list of types in `discouraged_direct_init`.
[jszumski](https://github.com/jszumski)
[#4508](https://github.com/realm/SwiftLint/issues/4508)
* Fix SwiftLint support on Xcode Cloud.
[JagCesar](https://github.com/JagCesar)
[westerlund](https://github.com/westerlund)
[#4484](https://github.com/realm/SwiftLint/issues/4484)
* Add `no_magic_numbers` rule to avoid "Magic Numbers".
[Henrik Storch](https://github.com/thisisthefoxe)
[#4031](https://github.com/realm/SwiftLint/issues/4024)
* SwiftSyntax libraries have been updated from the previous 5.6 release and now
use the new parser written in Swift.
Swift 5.7+ features should now be parsed more accurately.
We've also measured an improvement in lint times of up to 15%.
This should also fix some deployment issues where the exact version of the
internal SwiftSyntax parser needed to be available.
If you notice any unexpected changes to lint results, please file an issue on
the SwiftLint issue tracker. We can look into it and if it's a SwiftSyntax
parser regression we can re-file it upstream.
[JP Simard](https://github.com/jpsim)
[#4031](https://github.com/realm/SwiftLint/issues/4031)
* Add ability to filter rules for `generate-docs` subcommand.
[kattouf](https://github.com/kattouf)
* Add new `excludes_trivial_init` configuration for `missing_docs` rule
to exclude initializers without any parameters.
[Marcelo Fabri](https://github.com/marcelofabri)
[#4107](https://github.com/realm/SwiftLint/issues/4107)
* Add new `ns_number_init_as_function_reference` rule to catch `NSNumber.init`
and `NSDecimalNumber.init` being used as function references since it
can cause the wrong initializer to be used, causing crashes. See
https://github.com/apple/swift/issues/51036 for more info.
[Marcelo Fabri](https://github.com/marcelofabri)
* Rewrite some rules with SwiftSyntax, fixing some false positives and catching
more violations:
- `anonymous_argument_in_multiline_closure`
- `array_init`
- `attributes`
- `block_based_kvo`
- `class_delegate_protocol`
- `closing_brace`
- `closure_body_length`
- `closure_parameter_position`
- `collection_alignment`
- `comment_spacing`
- `computed_accessors_order`
- `conditional_returns_on_newline`
- `contains_over_filter_count`
- `contains_over_filter_is_empty`
- `contains_over_first_not_nil`
- `contains_over_range_nil_comparison`
- `convenience_type`
- `deployment_target`
- `discarded_notification_center_observer`
- `discouraged_assert`
- `discouraged_direct_init`
- `discouraged_none_name`
- `discouraged_object_literal`
- `discouraged_optional_boolean`
- `duplicate_enum_cases`
- `duplicated_key_in_dictionary_literal`
- `dynamic_inline`
- `empty_collection_literal`
- `empty_count`
- `empty_enum_arguments`
- `empty_parameters`
- `empty_parentheses_with_trailing_closure`
- `empty_string`
- `enum_case_associated_values_count`
- `explicit_enum_raw_value`
- `explicit_init`
- `explicit_top_level_acl`
- `fallthrough`
- `file_name`
- `first_where`
- `flatmap_over_map_reduce`
- `for_where`
- `force_try`
- `force_unwrapping`
- `function_body_length`
- `function_default_parameter_at_end`
- `function_parameter_count`
- `generic_type_name`
- `ibinspectable_in_extension`
- `identical_operands`
- `implicit_getter`
- `implicitly_unwrapped_optional`
- `inclusive_language`
- `inert_defer`
- `is_disjoint`
- `joined_default_parameter`
- `large_tuple`
- `last_where`
- `legacy_cggeometry_functions`
- `legacy_constant`
- `legacy_constructor`
- `legacy_hashing`
- `legacy_multiple`
- `legacy_nsgeometry_functions`
- `legacy_objc_type`
- `legacy_random`
- `lower_acl_than_parent`
- `multiline_arguments_brackets`
- `multiline_parameters`
- `multiple_closures_with_trailing_closure`
- `no_extension_access_modifier`
- `no_fallthrough_only`
- `no_space_in_method_call`
- `notification_center_detachment`
- `nslocalizedstring_require_bundle`
- `nsobject_prefer_isequal`
- `number_separator`
- `operator_whitespace`
- `optional_enum_case_matching`
- `orphaned_doc_comment`
- `overridden_super_call`
- `override_in_extension`
- `prefer_nimble`
- `prefer_self_type_over_type_of_self`
- `prefer_zero_over_explicit_init`
- `prefixed_toplevel_constant`
- `private_action`
- `private_outlet`
- `private_over_fileprivate`
- `private_subject`
- `private_unit_test`
- `prohibited_interface_builder`
- `prohibited_super_call`
- `protocol_property_accessors_order`
- `quick_discouraged_focused_test`
- `quick_discouraged_pending_test`
- `raw_value_for_camel_cased_codable_enum`
- `reduce_boolean`
- `reduce_into`
- `redundant_discardable_let`
- `redundant_nil_coalescing`
- `redundant_objc_attribute`
- `redundant_optional_initialization`
- `redundant_set_access_control`
- `redundant_string_enum_value`
- `required_deinit`
- `return_arrow_whitespace`
- `self_in_property_initialization`
- `shorthand_operator`
- `single_test_class`
- `sorted_first_last`
- `static_operator`
- `strict_fileprivate`
- `strong_iboutlet`
- `switch_case_alignment`
- `switch_case_on_newline`
- `test_case_accessibility`
- `toggle_bool`
- `trailing_comma`
- `trailing_semicolon`
- `type_body_length`
- `type_name`
- `unneeded_break_in_switch`
- `unneeded_parentheses_in_closure_argument`
- `unowned_variable_capture`
- `untyped_error_in_catch`
- `unused_capture_list`
- `unused_closure_parameter`
- `unused_control_flow_label`
- `unused_enumerated`
- `unused_optional_binding`
- `unused_setter_value`
- `valid_ibinspectable`
- `vertical_parameter_alignment`
- `weak_delegate`
- `xct_specific_matcher`
- `xctfail_message`
[Marcelo Fabri](https://github.com/marcelofabri)
[SimplyDanny](https://github.com/SimplyDanny)
[JP Simard](https://github.com/jpsim)
[#2915](https://github.com/realm/SwiftLint/issues/2915)
* The "body length" family of rules have changed how they calculate body
line count to be significantly more correct and intuitive. However,
this is likely to require adjustments to your configuration or disable
commands to account for the changes.
[JP Simard](https://github.com/jpsim)
* Add `accessibility_trait_for_button` rule to warn if a SwiftUI
View has a tap gesture added to it without having the button or
link accessibility trait.
[Ryan Cole](https://github.com/rcole34)
* Add methods from SE-0348 to `UnusedDeclarationRule`.
[JP Simard](https://github.com/jpsim)
* Include the configured `bind_identifier` in `self_binding` violation
messages.
[JP Simard](https://github.com/jpsim)
* Add `library_content_provider` file type to `file_types_order` rule
to allow `LibraryContentProvider` to be ordered independent from `main_type`.
[dahlborn](https://github.com/dahlborn)
* Add `test_parent_classes` option to `test_case_accessibility` rule, which
allows detection in subclasses of XCTestCase.
[Martin Redington](https://github.com/mildm8nnered)
[#4200](https://github.com/realm/SwiftLint/issues/4200)
* Add a new `shorthand_optional_binding` opt-in rule that triggers in Swift 5.7
when a shadowing optional binding is created in an `if` or `guard` statement.
[SimplyDanny](https://github.com/SimplyDanny)
[#4202](https://github.com/realm/SwiftLint/issues/4202)
* Use SwiftSyntax instead of SourceKit to determine if a file has parser errors
before applying corrections. This speeds up corrections significantly when
none of the rules use SourceKit.
[JP Simard](https://github.com/jpsim)
* Add Swift Package Build Tool Plugin with support for Swift Packages
and Xcode projects.
[Johannes Ebeling](https://github.com/technocidal)
[#3679](https://github.com/realm/SwiftLint/issues/3679)
[#3840](https://github.com/realm/SwiftLint/issues/3840)
* Make `private_unit_test` rule correctable.
[SimplyDanny](https://github.com/SimplyDanny)
* Disregard whitespace differences in `identical_operands` rule. That is, the rule
now also triggers if the left-hand side and the right-hand side of an operation
only differ in trivia.
[SimplyDanny](https://github.com/SimplyDanny)
* Print violations in realtime if `--progress` and `--output` are both set.
[JP Simard](https://github.com/jpsim)
* Update `for_where` rule, adding a new configuration
`allow_for_as_filter` to allow using `for in` with a single `if` inside
when there's a `return` statement inside the `if`'s body.
[Marcelo Fabri](https://github.com/marcelofabri)
[#4040](https://github.com/realm/SwiftLint/issues/4040)
* `quick_discouraged_call`, `quick_discouraged_focused_test` and
`quick_discouraged_pending_test` rules now trigger on subclasses of
`QuickSpec`.
[Marcelo Fabri](https://github.com/marcelofabri)
[#4420](https://github.com/realm/SwiftLint/issues/4420)
* The `type_name` rule now validates protocol declarations by default.
You can opt-out by using the `validate_protocols` key in your configuration:
```yml
type_name:
validate_protocols: false
```
[Marcelo Fabri](https://github.com/marcelofabri)
[#4430](https://github.com/realm/SwiftLint/issues/4430)
* Report how much memory was used when `--benchmark` is specified.
[JP Simard](https://github.com/jpsim)
#### Bug Fixes
* Respect `validates_start_with_lowercase` option when linting function names.
[Chris Brakebill](https://github.com/braker1nine)
[#2708](https://github.com/realm/SwiftLint/issues/2708)
* Do not report variables annotated with `@NSApplicationDelegateAdaptor` and
`@WKExtensionDelegateAdaptor` in `weak_delegate` rule.
[Till Hainbach](https://github.com/tillhainbach)
[#3598](https://github.com/realm/SwiftLint/issues/3456)
[#3611](https://github.com/realm/SwiftLint/issues/3611)
* Fix false-positives related to the `willMove` lifecycle method in
`type_contents_order` rule.
[SimplyDanny](https://github.com/SimplyDanny)
[#3478](https://github.com/realm/SwiftLint/issues/3478)
* Do no longer autocorrect usage of `NSIntersectionRect` in `legacy_nsgeometry_functions`
rule.
[SimplyDanny](https://github.com/SimplyDanny)
[#3703](https://github.com/realm/SwiftLint/issues/3703)
* Fix Analyzer rules in Xcode 14.
[SimplyDanny](https://github.com/SimplyDanny)
[#4208](https://github.com/realm/SwiftLint/issues/4208)
* Add column for SourceKit usage to `rules` command.
[JP Simard](https://github.com/jpsim)
* Make `nsobject_prefer_isequal` rule work for nested `@objc` classes. Also consider
the `@objcMembers` annotation.
[SimplyDanny](https://github.com/SimplyDanny)
* Print fixed content at most once to STDOUT.
[SimplyDanny](https://github.com/SimplyDanny)
[#4211](https://github.com/realm/SwiftLint/issues/4211)
* Fix fatal error when content given via STDIN is corrected in the
`trailing_newline` rule.
[SimplyDanny](https://github.com/SimplyDanny)
[#4234](https://github.com/realm/SwiftLint/issues/4234)
* Fix false-positives from `multiline_arguments_brackets` when a function call has a
single line trailing closure.
[CraigSiemens](https://github.com/CraigSiemens)
[#4510](https://github.com/realm/SwiftLint/issues/4510)
---
### Using Bazel
Put this in your `WORKSPACE`:
<details>
<summary>WORKSPACE</summary>
```python
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "build_bazel_rules_apple",
sha256 = "90e3b5e8ff942be134e64a83499974203ea64797fd620eddeb71b3a8e1bff681",
url = "https://github.com/bazelbuild/rules_apple/releases/download/1.1.2/rules_apple.1.1.2.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 = "ef49a8c0dcb70fb5befe549b016735deef72e1ac9f68562b288f23e496c164af",
url = "https://github.com/realm/SwiftLint/releases/download/0.50.0-rc.4/bazel.tar.gz",
)
load("@SwiftLint//bazel:repos.bzl", "swiftlint_repos")
swiftlint_repos()
load("@SwiftLint//bazel:deps.bzl", "swiftlint_deps")
swiftlint_deps()
```
</details>
Then you can run SwiftLint in the current directory with this command:
```console
bazel run @SwiftLint//:swiftlint -- --help
```
0.50.0-rc.3: Artisanal Clothes Pegs
21 weeks ago
This is a prerelease version. It won't be published to Homebrew or CocoaPods. But there are many other ways to install:
* Downloading the attached `SwiftLint.pkg` installer and launching it
* Downloading the attached `portable_swiftlint.zip` archive, extracting it and moving the binary from `portable_swiftlint/swiftlint` to `/usr/local/bin` or elsewhere in your `PATH`
* Using [Mint](https://github.com/yonaskolb/Mint): `mint install realm/
[email protected]`
* Cloning and building from source: `git clone https://github.com/realm/SwiftLint.git && cd SwiftLint && git checkout 0.50.0-rc.3 && make install`
* Docker: ```docker run -it -v `pwd`:`pwd` -w `pwd` ghcr.io/realm/swiftlint:0.50.0-rc.3```
* Bazel: See instructions at the bottom
Changes from 0.49.1: https://github.com/realm/SwiftLint/compare/0.49.1...0.50.0-rc.3
Changes from 0.50.0-rc.2: https://github.com/realm/SwiftLint/compare/0.50.0-rc.2...0.50.0-rc.3
---
#### Breaking
* SwiftLint now requires Swift 5.7 or higher to build.
[JP Simard](https://github.com/jpsim)
* Exclude `weak_delegate` rule from autocorrection due to behavioral changes
leading to potential undefined behavior or bugs.
[SimplyDanny](https://github.com/SimplyDanny)
[#3577](https://github.com/realm/SwiftLint/issues/3577)
* The `anyobject_protocol` rule is now deprecated and will be completely removed
in a future release because it is now handled by the Swift compiler.
[JP Simard](https://github.com/jpsim)
#### Experimental
* None.
#### Enhancements
* SwiftSyntax libraries have been updated from the previous 5.6 release and now
use the new parser written in Swift.
Swift 5.7+ features should now be parsed more accurately.
We've also measured an improvement in lint times of up to 15%.
This should also fix some deployment issues where the exact version of the
internal SwiftSyntax parser needed to be available.
If you notice any unexpected changes to lint results, please file an issue on
the SwiftLint issue tracker. We can look into it and if it's a SwiftSyntax
parser regression we can re-file it upstream.
[JP Simard](https://github.com/jpsim)
[#4031](https://github.com/realm/SwiftLint/issues/4031)
* Add ability to filter rules for `generate-docs` subcommand.
[kattouf](https://github.com/kattouf)
* Add new `excludes_trivial_init` configuration for `missing_docs` rule
to exclude initializers without any parameters.
[Marcelo Fabri](https://github.com/marcelofabri)
[#4107](https://github.com/realm/SwiftLint/issues/4107)
* Add new `ns_number_init_as_function_reference` rule to catch `NSNumber.init`
and `NSDecimalNumber.init` being used as function references since it
can cause the wrong initializer to be used, causing crashes. See
https://github.com/apple/swift/issues/51036 for more info.
[Marcelo Fabri](https://github.com/marcelofabri)
* Rewrite some rules with SwiftSyntax, fixing some false positives and catching
more violations:
- `anonymous_argument_in_multiline_closure`
- `array_init`
- `attributes`
- `block_based_kvo`
- `class_delegate_protocol`
- `closing_brace`
- `closure_body_length`
- `closure_parameter_position`
- `collection_alignment`
- `comment_spacing`
- `computed_accessors_order`
- `conditional_returns_on_newline`
- `contains_over_filter_count`
- `contains_over_filter_is_empty`
- `contains_over_first_not_nil`
- `contains_over_range_nil_comparison`
- `convenience_type`
- `deployment_target`
- `discarded_notification_center_observer`
- `discouraged_assert`
- `discouraged_direct_init`
- `discouraged_none_name`
- `discouraged_object_literal`
- `discouraged_optional_boolean`
- `duplicate_enum_cases`
- `duplicated_key_in_dictionary_literal`
- `dynamic_inline`
- `empty_collection_literal`
- `empty_count`
- `empty_enum_arguments`
- `empty_parameters`
- `empty_parentheses_with_trailing_closure`
- `empty_string`
- `enum_case_associated_values_count`
- `explicit_enum_raw_value`
- `explicit_init`
- `explicit_top_level_acl`
- `fallthrough`
- `file_name`
- `first_where`
- `flatmap_over_map_reduce`
- `for_where`
- `force_try`
- `force_unwrapping`
- `function_body_length`
- `function_default_parameter_at_end`
- `function_parameter_count`
- `generic_type_name`
- `ibinspectable_in_extension`
- `identical_operands`
- `implicit_getter`
- `implicitly_unwrapped_optional`
- `inclusive_language`
- `inert_defer`
- `is_disjoint`
- `joined_default_parameter`
- `large_tuple`
- `last_where`
- `legacy_cggeometry_functions`
- `legacy_constant`
- `legacy_constructor`
- `legacy_hashing`
- `legacy_multiple`
- `legacy_nsgeometry_functions`
- `legacy_objc_type`
- `legacy_random`
- `lower_acl_than_parent`
- `multiple_closures_with_trailing_closure`
- `multiline_parameters`
- `no_extension_access_modifier`
- `no_fallthrough_only`
- `no_space_in_method_call`
- `notification_center_detachment`
- `nslocalizedstring_require_bundle`
- `nsobject_prefer_isequal`
- `number_separator`
- `operator_whitespace`
- `override_in_extension`
- `nsobject_prefer_isequal`
- `prefer_nimble`
- `prefer_self_type_over_type_of_self`
- `prefer_zero_over_explicit_init`
- `prefixed_toplevel_constant`
- `private_action`
- `private_over_fileprivate`
- `private_outlet`
- `private_unit_test`
- `prohibited_interface_builder`
- `protocol_property_accessors_order`
- `quick_discouraged_focused_test`
- `quick_discouraged_pending_test`
- `raw_value_for_camel_cased_codable_enum`
- `reduce_boolean`
- `reduce_into`
- `redundant_discardable_let`
- `redundant_nil_coalescing`
- `redundant_objc_attribute`
- `redundant_set_access_control`
- `redundant_optional_initialization`
- `redundant_string_enum_value`
- `required_deinit`
- `return_arrow_whitespace`
- `self_in_property_initialization`
- `shorthand_operator`
- `single_test_class`
- `sorted_first_last`
- `static_operator`
- `strict_fileprivate`
- `strong_iboutlet`
- `switch_case_alignment`
- `switch_case_on_newline`
- `test_case_accessibility`
- `toggle_bool`
- `trailing_comma`
- `trailing_semicolon`
- `type_body_length`
- `type_name`
- `unneeded_break_in_switch`
- `unneeded_parentheses_in_closure_argument`
- `unowned_variable_capture`
- `untyped_error_in_catch`
- `unused_capture_list`
- `unused_closure_parameter`
- `unused_control_flow_label`
- `unused_enumerated`
- `unused_optional_binding`
- `unused_setter_value`
- `valid_ibinspectable`
- `vertical_parameter_alignment`
- `weak_delegate`
- `xct_specific_matcher`
- `xctfail_message`
[Marcelo Fabri](https://github.com/marcelofabri)
[SimplyDanny](https://github.com/SimplyDanny)
[JP Simard](https://github.com/jpsim)
[#2915](https://github.com/realm/SwiftLint/issues/2915)
* The "body length" family of rules have changed how they calculate body
line count to be significantly more correct and intuitive. However,
this is likely to require adjustments to your configuration or disable
commands to account for the changes.
[JP Simard](https://github.com/jpsim)
* Add `accessibility_trait_for_button` rule to warn if a SwiftUI
View has a tap gesture added to it without having the button or
link accessibility trait.
[Ryan Cole](https://github.com/rcole34)
* Add methods from SE-0348 to `UnusedDeclarationRule`.
[JP Simard](https://github.com/jpsim)
* Include the configured `bind_identifier` in `self_binding` violation
messages.
[JP Simard](https://github.com/jpsim)
* Add `library_content_provider` file type to `file_types_order` rule
to allow `LibraryContentProvider` to be ordered independent from `main_type`.
[dahlborn](https://github.com/dahlborn)
* Add `test_parent_classes` option to `test_case_accessibility` rule, which
allows detection in subclasses of XCTestCase.
[Martin Redington](https://github.com/mildm8nnered)
[#4200](https://github.com/realm/SwiftLint/issues/4200)
* Add a new `shorthand_optional_binding` opt-in rule that triggers in Swift 5.7
when a shadowing optional binding is created in an `if` or `guard` statement.
[SimplyDanny](https://github.com/SimplyDanny)
[#4202](https://github.com/realm/SwiftLint/issues/4202)
* Use SwiftSyntax instead of SourceKit to determine if a file has parser errors
before applying corrections. This speeds up corrections significantly when
none of the rules use SourceKit.
[JP Simard](https://github.com/jpsim)
* Add Swift Package Build Tool Plugin with support for Swift Packages
and Xcode projects.
[Johannes Ebeling](https://github.com/technocidal)
[#3679](https://github.com/realm/SwiftLint/issues/3679)
[#3840](https://github.com/realm/SwiftLint/issues/3840)
* Make `private_unit_test` rule correctable.
[SimplyDanny](https://github.com/SimplyDanny)
* Disregard whitespace differences in `identical_operands` rule. That is, the rule
now also triggers if the left-hand side and the right-hand side of an operation
only differ in trivia.
[SimplyDanny](https://github.com/SimplyDanny)
* Print violations in realtime if `--progress` and `--output` are both set.
[JP Simard](https://github.com/jpsim)
* Update `for_where` rule, adding a new configuration
`allow_for_as_filter` to allow using `for in` with a single `if` inside
when there's a `return` statement inside the `if`'s body.
[Marcelo Fabri](https://github.com/marcelofabri)
[#4040](https://github.com/realm/SwiftLint/issues/4040)
* `quick_discouraged_call`, `quick_discouraged_focused_test` and
`quick_discouraged_pending_test` rules now trigger on subclasses of
`QuickSpec`.
[Marcelo Fabri](https://github.com/marcelofabri)
[#4420](https://github.com/realm/SwiftLint/issues/4420)
* The `type_name` rule now validates protocol declarations by default.
You can opt-out by using the `validate_protocols` key in your configuration:
```yml
type_name:
validate_protocols: false
```
[Marcelo Fabri](https://github.com/marcelofabri)
[#4430](https://github.com/realm/SwiftLint/issues/4430)
* Report how much memory was used when `--benchmark` is specified.
[JP Simard](https://github.com/jpsim)
#### Bug Fixes
* Respect `validates_start_with_lowercase` option when linting function names.
[Chris Brakebill](https://github.com/braker1nine)
[#2708](https://github.com/realm/SwiftLint/issues/2708)
* Do not report variables annotated with `@NSApplicationDelegateAdaptor` and
`@WKExtensionDelegateAdaptor` in `weak_delegate` rule.
[Till Hainbach](https://github.com/tillhainbach)
[#3598](https://github.com/realm/SwiftLint/issues/3456)
[#3611](https://github.com/realm/SwiftLint/issues/3611)
* Fix false-positives related to the `willMove` lifecycle method in
`type_contents_order` rule.
[SimplyDanny](https://github.com/SimplyDanny)
[#3478](https://github.com/realm/SwiftLint/issues/3478)
* Do no longer autocorrect usage of `NSIntersectionRect` in `legacy_nsgeometry_functions`
rule.
[SimplyDanny](https://github.com/SimplyDanny)
[#3703](https://github.com/realm/SwiftLint/issues/3703)
* Fix Analyzer rules in Xcode 14.
[SimplyDanny](https://github.com/SimplyDanny)
[#4208](https://github.com/realm/SwiftLint/issues/4208)
* Add column for SourceKit usage to `rules` command.
[JP Simard](https://github.com/jpsim)
* Make `nsobject_prefer_isequal` rule work for nested `@objc` classes. Also consider
the `@objcMembers` annotation.
[SimplyDanny](https://github.com/SimplyDanny)
* Print fixed content at most once to STDOUT.
[SimplyDanny](https://github.com/SimplyDanny)
[#4211](https://github.com/realm/SwiftLint/issues/4211)
* Fix fatal error when content given via STDIN is corrected in the
`trailing_newline` rule.
[SimplyDanny](https://github.com/SimplyDanny)
[#4234](https://github.com/realm/SwiftLint/issues/4234)
---
### Using Bazel
Put this in your `WORKSPACE`:
<details>
<summary>WORKSPACE</summary>
```python
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "build_bazel_rules_apple",
sha256 = "90e3b5e8ff942be134e64a83499974203ea64797fd620eddeb71b3a8e1bff681",
url = "https://github.com/bazelbuild/rules_apple/releases/download/1.1.2/rules_apple.1.1.2.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 = "0cc64b76c801242ba440f83a85d4d54aa11303f1f48094555ddc3a818fbc9858",
url = "https://github.com/realm/SwiftLint/releases/download/0.50.0-rc.3/bazel.tar.gz",
)
load("@SwiftLint//bazel:repos.bzl", "swiftlint_repos")
swiftlint_repos()
load("@SwiftLint//bazel:deps.bzl", "swiftlint_deps")
swiftlint_deps()
```
</details>
Then you can run SwiftLint in the current directory with this command:
```console
bazel run @SwiftLint//:swiftlint -- --help
```
0.50.0-rc.2: Artisanal Clothes Pegs
23 weeks ago
This is a prerelease version. It won't be published to Homebrew or CocoaPods. But there are many other ways to install:
* Downloading the attached `SwiftLint.pkg` installer and launching it
* Downloading the attached `portable_swiftlint.zip` archive, extracting it and moving the binary from `portable_swiftlint/swiftlint` to `/usr/local/bin` or elsewhere in your `PATH`
* Using [Mint](https://github.com/yonaskolb/Mint): `mint install realm/
[email protected]`
* Cloning and building from source: `git clone https://github.com/realm/SwiftLint.git && cd SwiftLint && git checkout 0.50.0-rc.2 && make install`
* Docker: ```docker run -it -v `pwd`:`pwd` -w `pwd` ghcr.io/realm/swiftlint:0.50.0-rc.2```
* Bazel: See instructions at the bottom
Changes from 0.49.1: https://github.com/realm/SwiftLint/compare/0.49.1...0.50.0-rc.2
Changes from 0.50.0-rc.1: https://github.com/realm/SwiftLint/compare/0.50.0-rc.1...0.50.0-rc.2
---
#### Breaking
* SwiftLint now requires Swift 5.7 or higher to build.
[JP Simard](https://github.com/jpsim)
* Exclude `weak_delegate` rule from autocorrection due to behavioral changes
leading to potential undefined behavior or bugs.
[SimplyDanny](https://github.com/SimplyDanny)
[#3577](https://github.com/realm/SwiftLint/issues/3577)
* The `anyobject_protocol` rule is now deprecated and will be completely removed
in a future release because it is now handled by the Swift compiler.
[JP Simard](https://github.com/jpsim)
#### Experimental
* None.
#### Enhancements
* SwiftSyntax libraries have been updated from the previous 5.6 release and now
use the new parser written in Swift.
Swift 5.7+ features should now be parsed more accurately.
We've also measured an improvement in lint times of up to 15%.
This should also fix some deployment issues where the exact version of the
internal SwiftSyntax parser needed to be available.
If you notice any unexpected changes to lint results, please file an issue on
the SwiftLint issue tracker. We can look into it and if it's a SwiftSyntax
parser regression we can re-file it upstream.
[JP Simard](https://github.com/jpsim)
[#4031](https://github.com/realm/SwiftLint/issues/4031)
* Add ability to filter rules for `generate-docs` subcommand.
[kattouf](https://github.com/kattouf)
* Add new `excludes_trivial_init` configuration for `missing_docs` rule
to exclude initializers without any parameters.
[Marcelo Fabri](https://github.com/marcelofabri)
[#4107](https://github.com/realm/SwiftLint/issues/4107)
* Rewrite some rules with SwiftSyntax, fixing some false positives and catching
more violations:
- `anonymous_argument_in_multiline_closure`
- `array_init`
- `attributes`
- `block_based_kvo`
- `class_delegate_protocol`
- `closing_brace`
- `closure_body_length`
- `closure_parameter_position`
- `computed_accessors_order`
- `conditional_returns_on_newline`
- `contains_over_filter_count`
- `contains_over_filter_is_empty`
- `contains_over_first_not_nil`
- `contains_over_range_nil_comparison`
- `deployment_target`
- `discouraged_assert`
- `discouraged_direct_init`
- `discouraged_none_name`
- `discouraged_object_literal`
- `discouraged_optional_boolean`
- `duplicate_enum_cases`
- `dynamic_inline`
- `empty_collection_literal`
- `empty_enum_arguments`
- `empty_parameters`
- `empty_parentheses_with_trailing_closure`
- `empty_string`
- `enum_case_associated_values_count`
- `explicit_enum_raw_value`
- `explicit_init`
- `fallthrough`
- `first_where`
- `flatmap_over_map_reduce`
- `force_try`
- `force_unwrapping`
- `function_body_length`
- `function_default_parameter_at_end`
- `function_parameter_count`
- `generic_type_name`
- `ibinspectable_in_extension`
- `identical_operands`
- `implicit_getter`
- `implicitly_unwrapped_optional`
- `inert_defer`
- `is_disjoint`
- `large_tuple`
- `last_where`
- `legacy_cggeometry_functions`
- `legacy_constant`
- `legacy_constructor`
- `legacy_hashing`
- `legacy_multiple`
- `legacy_nsgeometry_functions`
- `legacy_random`
- `multiple_closures_with_trailing_closure`
- `no_extension_access_modifier`
- `no_fallthrough_only`
- `no_space_in_method_call`
- `nslocalizedstring_require_bundle`
- `nsobject_prefer_isequal`
- `number_separator`
- `operator_whitespace`
- `nsobject_prefer_isequal`
- `private_action`
- `private_over_fileprivate`
- `private_outlet`
- `private_unit_test`
- `prohibited_interface_builder`
- `protocol_property_accessors_order`
- `quick_discouraged_focused_test`
- `quick_discouraged_pending_test`
- `reduce_boolean`
- `redundant_discardable_let`
- `redundant_nil_coalescing`
- `redundant_string_enum_value`
- `self_in_property_initialization`
- `shorthand_operator`
- `sorted_first_last`
- `static_operator`
- `strict_fileprivate`
- `strong_iboutlet`
- `switch_case_alignment`
- `switch_case_on_newline`
- `toggle_bool`
- `trailing_comma`
- `trailing_semicolon`
- `type_body_length`
- `unneeded_break_in_switch`
- `unneeded_parentheses_in_closure_argument`
- `unowned_variable_capture`
- `untyped_error_in_catch`
- `unused_closure_parameter`
- `unused_control_flow_label`
- `unused_enumerated`
- `unused_setter_value`
- `valid_ibinspectable`
- `weak_delegate`
- `xctfail_message`
[Marcelo Fabri](https://github.com/marcelofabri)
[SimplyDanny](https://github.com/SimplyDanny)
[JP Simard](https://github.com/jpsim)
[#2915](https://github.com/realm/SwiftLint/issues/2915)
* The "body length" family of rules have changed how they calculate body
line count to be significantly more correct and intuitive. However,
this is likely to require adjustments to your configuration or disable
commands to account for the changes.
[JP Simard](https://github.com/jpsim)
* Add `accessibility_trait_for_button` rule to warn if a SwiftUI
View has a tap gesture added to it without having the button or
link accessibility trait.
[Ryan Cole](https://github.com/rcole34)
* Add methods from SE-0348 to `UnusedDeclarationRule`.
[JP Simard](https://github.com/jpsim)
* Include the configured `bind_identifier` in `self_binding` violation
messages.
[JP Simard](https://github.com/jpsim)
* Add `library_content_provider` file type to `file_types_order` rule
to allow `LibraryContentProvider` to be ordered independent from `main_type`.
[dahlborn](https://github.com/dahlborn)
* Add `test_parent_classes` option to `test_case_accessibility` rule, which
allows detection in subclasses of XCTestCase.
[Martin Redington](https://github.com/mildm8nnered)
[#4200](https://github.com/realm/SwiftLint/issues/4200)
* Add a new `shorthand_optional_binding` opt-in rule that triggers in Swift 5.7
when a shadowing optional binding is created in an `if` or `guard` statement.
[SimplyDanny](https://github.com/SimplyDanny)
[#4202](https://github.com/realm/SwiftLint/issues/4202)
* Use SwiftSyntax instead of SourceKit to determine if a file has parser errors
before applying corrections. This speeds up corrections significantly when
none of the rules use SourceKit.
[JP Simard](https://github.com/jpsim)
* Add Swift Package Build Tool Plugin with support for Swift Packages
and Xcode projects.
[Johannes Ebeling](https://github.com/technocidal)
[#3679](https://github.com/realm/SwiftLint/issues/3679)
[#3840](https://github.com/realm/SwiftLint/issues/3840)
* Make `private_unit_test` rule correctable.
[SimplyDanny](https://github.com/SimplyDanny)
* Disregard whitespace differences in `identical_operands` rule. That is, the rule
now also triggers if the left-hand side and the right-hand side of an operation
only differ in trivia.
[SimplyDanny](https://github.com/SimplyDanny)
* Print violations in realtime if `--progress` and `--output` are both set.
[JP Simard](https://github.com/jpsim)
#### Bug Fixes
* Respect `validates_start_with_lowercase` option when linting function names.
[Chris Brakebill](https://github.com/braker1nine)
[#2708](https://github.com/realm/SwiftLint/issues/2708)
* Do not report variables annotated with `@NSApplicationDelegateAdaptor` and
`@WKExtensionDelegateAdaptor` in `weak_delegate` rule.
[Till Hainbach](https://github.com/tillhainbach)
[#3598](https://github.com/realm/SwiftLint/issues/3456)
[#3611](https://github.com/realm/SwiftLint/issues/3611)
* Fix false-positives related to the `willMove` lifecycle method in
`type_contents_order` rule.
[SimplyDanny](https://github.com/SimplyDanny)
[#3478](https://github.com/realm/SwiftLint/issues/3478)
* Do no longer autocorrect usage of `NSIntersectionRect` in `legacy_nsgeometry_functions`
rule.
[SimplyDanny](https://github.com/SimplyDanny)
[#3703](https://github.com/realm/SwiftLint/issues/3703)
* Fix Analyzer rules in Xcode 14.
[SimplyDanny](https://github.com/SimplyDanny)
[#4208](https://github.com/realm/SwiftLint/issues/4208)
* Add column for SourceKit usage to `rules` command.
[JP Simard](https://github.com/jpsim)
* Make `nsobject_prefer_isequal` rule work for nested `@objc` classes. Also consider
the `@objcMembers` annotation.
[SimplyDanny](https://github.com/SimplyDanny)
* Print fixed content at most once to STDOUT.
[SimplyDanny](https://github.com/SimplyDanny)
[#4211](https://github.com/realm/SwiftLint/issues/4211)
* Fix fatal error when content given via STDIN is corrected in the
`trailing_newline` rule.
[SimplyDanny](https://github.com/SimplyDanny)
[#4234](https://github.com/realm/SwiftLint/issues/4234)
---
### Using Bazel
Put this in your `WORKSPACE`:
<details>
<summary>WORKSPACE</summary>
```python
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "build_bazel_rules_apple",
sha256 = "90e3b5e8ff942be134e64a83499974203ea64797fd620eddeb71b3a8e1bff681",
url = "https://github.com/bazelbuild/rules_apple/releases/download/1.1.2/rules_apple.1.1.2.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 = "973587995aab45ac56b963c1768a830a6a66580ccea4d5bf81617106b22bfa3f",
url = "https://github.com/realm/SwiftLint/releases/download/0.50.0-rc.2/bazel.tar.gz",
)
load("@SwiftLint//bazel:repos.bzl", "swiftlint_repos")
swiftlint_repos()
load("@SwiftLint//bazel:deps.bzl", "swiftlint_deps")
swiftlint_deps()
```
</details>
Then you can run SwiftLint in the current directory with this command:
```console
bazel run @SwiftLint//:swiftlint -- --help
```
0.50.0-rc.1: Artisanal Clothes Pegs
24 weeks ago
This is a prerelease version. It won't be published to Homebrew or CocoaPods. But there are many other ways to install:
* Downloading the attached `SwiftLint.pkg` installer and launching it
* Downloading the attached `portable_swiftlint.zip` archive, extracting it and moving the binary from `portable_swiftlint/swiftlint` to `/usr/local/bin` or elsewhere in your `PATH`
* Using [Mint](https://github.com/yonaskolb/Mint): `mint install realm/
[email protected]`
* Cloning and building from source: `git clone https://github.com/realm/SwiftLint.git && cd SwiftLint && git checkout 0.50.0-rc.1 && make install`
* Docker: ```docker run -it -v `pwd`:`pwd` -w `pwd` ghcr.io/realm/swiftlint:0.50.0-rc.1```
* Bazel: See instructions at the bottom
Changes from 0.49.1: https://github.com/realm/SwiftLint/compare/0.49.1...0.50.0-rc.1
---
#### Breaking
* SwiftLint now requires Swift 5.7 or higher to build.
[JP Simard](https://github.com/jpsim)
* Exclude `weak_delegate` rule from autocorrection due to behavioral changes
leading to potential undefined behavior or bugs.
[SimplyDanny](https://github.com/SimplyDanny)
[#3577](https://github.com/realm/SwiftLint/issues/3577)
* The `anyobject_protocol` rule is now deprecated and will be completely removed
in a future release because it is now handled by the Swift compiler.
[JP Simard](https://github.com/jpsim)
#### Experimental
* None.
#### Enhancements
* SwiftSyntax libraries have been updated from the previous 5.6 release and now
use the new parser written in Swift.
Swift 5.7+ features should now be parsed more accurately.
We've also measured an improvement in lint times of up to 15%.
This should also fix some deployment issues where the exact version of the
internal SwiftSyntax parser needed to be available.
If you notice any unexpected changes to lint results, please file an issue on
the SwiftLint issue tracker. We can look into it and if it's a SwiftSyntax
parser regression we can re-file it upstream.
[JP Simard](https://github.com/jpsim)
[#4031](https://github.com/realm/SwiftLint/issues/4031)
* Add ability to filter rules for `generate-docs` subcommand.
[kattouf](https://github.com/kattouf)
* Add new `excludes_trivial_init` configuration for `missing_docs` rule
to exclude initializers without any parameters.
[Marcelo Fabri](https://github.com/marcelofabri)
[#4107](https://github.com/realm/SwiftLint/issues/4107)
* Rewrite some rules with SwiftSyntax, fixing some false positives and catching
more violations:
- `anonymous_argument_in_multiline_closure`
- `array_init`
- `block_based_kvo`
- `class_delegate_protocol`
- `closing_brace`
- `closure_parameter_position`
- `computed_accessors_order`
- `contains_over_filter_count`
- `contains_over_range_nil_comparison`
- `deployment_target`
- `discouraged_object_literal`
- `discouraged_optional_boolean`
- `duplicate_enum_cases`
- `dynamic_inline`
- `empty_collection_literal`
- `empty_enum_arguments`
- `empty_parameters`
- `empty_parentheses_with_trailing_closure`
- `empty_string`
- `explicit_init`
- `fallthrough`
- `flatmap_over_map_reduce`
- `force_try`
- `force_unwrapping`
- `generic_type_name`
- `ibinspectable_in_extension`
- `implicit_getter`
- `inert_defer`
- `large_tuple`
- `legacy_cggeometry_functions`
- `legacy_constant`
- `legacy_nsgeometry_functions`
- `multiple_closures_with_trailing_closure`
- `no_extension_access_modifier`
- `no_fallthrough_only`
- `no_space_in_method_call`
- `nsobject_prefer_isequal`
- `private_action`
- `private_outlet`
- `private_unit_test`
- `protocol_property_accessors_order`
- `redundant_nil_coalescing`
- `redundant_string_enum_value`
- `strong_iboutlet`
- `switch_case_on_newline`
- `toggle_bool`
- `trailing_semicolon`
- `unneeded_break_in_switch`
- `unneeded_parentheses_in_closure_argument`
- `unowned_variable_capture`
- `untyped_error_in_catch`
- `xctfail_message`
[Marcelo Fabri](https://github.com/marcelofabri)
[SimplyDanny](https://github.com/SimplyDanny)
[JP Simard](https://github.com/jpsim)
[#2915](https://github.com/realm/SwiftLint/issues/2915)
* Add `accessibility_trait_for_button` rule to warn if a SwiftUI
View has a tap gesture added to it without having the button or
link accessibility trait.
[Ryan Cole](https://github.com/rcole34)
* Add methods from SE-0348 to `UnusedDeclarationRule`.
[JP Simard](https://github.com/jpsim)
* Include the configured `bind_identifier` in `self_binding` violation
messages.
[JP Simard](https://github.com/jpsim)
* Add `library_content_provider` file type to `file_types_order` rule
to allow `LibraryContentProvider` to be ordered independent from `main_type`.
[dahlborn](https://github.com/dahlborn)
* Add `test_parent_classes` option to `test_case_accessibility` rule, which
allows detection in subclasses of XCTestCase.
[Martin Redington](https://github.com/mildm8nnered)
[#4200](https://github.com/realm/SwiftLint/issues/4200)
* Add a new `if_let_shadowing` opt-in rule that triggers in Swift 5.7 when a
shadowing optional binding is created in an if- or guard-statement.
[SimplyDanny](https://github.com/SimplyDanny)
[#4202](https://github.com/realm/SwiftLint/issues/4202)
* Use SwiftSyntax instead of SourceKit to determine if a file has parser errors
before applying corrections. This speeds up corrections significantly when
none of the rules use SourceKit.
[JP Simard](https://github.com/jpsim)
* Add Swift Package Build Tool Plugin with support for Swift Packages
and Xcode projects.
[Johannes Ebeling](https://github.com/technocidal)
[#3679](https://github.com/realm/SwiftLint/issues/3679)
[#3840](https://github.com/realm/SwiftLint/issues/3840)
* Make `private_unit_test` rule correctable.
[SimplyDanny](https://github.com/SimplyDanny)
#### Bug Fixes
* Respect `validates_start_with_lowercase` option when linting function names.
[Chris Brakebill](https://github.com/braker1nine)
[#2708](https://github.com/realm/SwiftLint/issues/2708)
* Do not report variables annotated with `@NSApplicationDelegateAdaptor` and
`@WKExtensionDelegateAdaptor` in `weak_delegate` rule.
[Till Hainbach](https://github.com/tillhainbach)
[#3598](https://github.com/realm/SwiftLint/issues/3456)
[#3611](https://github.com/realm/SwiftLint/issues/3611)
* Fix false-positives related to the `willMove` lifecycle method in
`type_contents_order` rule.
[SimplyDanny](https://github.com/SimplyDanny)
[#3478](https://github.com/realm/SwiftLint/issues/3478)
* Do no longer autocorrect usage of `NSIntersectionRect` in `legacy_nsgeometry_functions`
rule.
[SimplyDanny](https://github.com/SimplyDanny)
[#3703](https://github.com/realm/SwiftLint/issues/3703)
* Fix Analyzer rules in Xcode 14.
[SimplyDanny](https://github.com/SimplyDanny)
[#4208](https://github.com/realm/SwiftLint/issues/4208)
* Add column for SourceKit usage to `rules` command.
[JP Simard](https://github.com/jpsim)
---
### Using Bazel
Put this in your `WORKSPACE`:
<details>
<summary>WORKSPACE</summary>
```python
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "build_bazel_rules_apple",
sha256 = "90e3b5e8ff942be134e64a83499974203ea64797fd620eddeb71b3a8e1bff681",
url = "https://github.com/bazelbuild/rules_apple/releases/download/1.1.2/rules_apple.1.1.2.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 = "ee13554c48ca7845513ae307863525afbb5b8f22d4c3b34b5b2e87311c3d5e26",
url = "https://github.com/realm/SwiftLint/releases/download/0.50.0-rc.1/bazel.tar.gz",
)
load("@SwiftLint//bazel:repos.bzl", "swiftlint_repos")
swiftlint_repos()
load("@SwiftLint//bazel:deps.bzl", "swiftlint_deps")
swiftlint_deps()
```
</details>
Then you can run SwiftLint in the current directory with this command:
```console
bazel run @SwiftLint//:swiftlint -- --help
```