Skip to content

Commit

Permalink
Ignore 100 in no_magic_numbers rule (realm#5215)
Browse files Browse the repository at this point in the history
  • Loading branch information
mildm8nnered authored and KS1019 committed Oct 2, 2023
1 parent 62391a7 commit 17d17e8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@
[Martin Redington](https://github.com/mildm8nnered)
[#5204](https://github.com/realm/SwiftLint/issues/5204)

* 100 is no longer considered to be a magic number by the `no_magic_numbers`
rule.
[Martin Redington](https://github.com/mildm8nnered)
[#5215](https://github.com/realm/SwiftLint/issues/5215)

#### Bug Fixes

* Respect grapheme clusters in counting the number of characters in the `collection_alignment` rule.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ struct NoMagicNumbersRule: SwiftSyntaxRule, OptInRule, ConfigurationProviderRule
Example("let foo = 1 << 2"),
Example("let foo = 1 >> 2"),
Example("let foo = 2 >> 2"),
Example("let foo = 2 << 2")
Example("let foo = 2 << 2"),
Example("let a = b / 100.0")
],
triggeringExamples: [
Example("foo(↓321)"),
Expand Down Expand Up @@ -167,7 +168,7 @@ private extension TokenSyntax {
guard let number = Double(text.replacingOccurrences(of: "_", with: "")) else {
return false
}
if [0, 1].contains(number) {
if [0, 1, 100].contains(number) {
return false
}
guard let grandparent = parent?.parent else {
Expand Down

0 comments on commit 17d17e8

Please sign in to comment.