Why is SwiftLint whitelist_rules not working on my project?

1.2k views Asked by At

I'm trying to configure swiftlint in my project and white_list is not working.

Here is what I'm trying to do:

my .swiftlint.yml:

whitelist_rules:
  - force_cast: warning

my code:

let forceCast: Int = "hue" as! Int

which gives me the error:

Force Cast Violation: Force casts should be avoided. (force_cast)

when I expect it to give me only a warning, not an error. Beyond this example, no other rule is working when on whitelist.

I know swiftlint is reading my .swiftlint.yml because I tested it with disabled_rules and it seemed to be working fine, so it's not a matter with the path of my .swiftlint.yml file.

Also, for the record,

  • I have configured correctly the Run Script Phase
  • I am not using whitelist_rules along with disabled_rules and opt_in_rules, I'm using only whitelist_rules.
  • I'm using swiftlint version 0.40.3, xcode 11.3, ios 13.2 and swift 5

What am I missing? Why isn't it working?

1

There are 1 answers

0
caperonce On

In case anyone had recent issues with whilelist_rules configuration key, notice that it was renamed to only_rules in version 0.41.0

https://github.com/realm/SwiftLint/releases/tag/0.41.0