I am looking to disable a couple of SwiftLint rules for the unit tests within my application.
For example I am wanting to disable the weak_delegate
rule for my unit tests.
Having looked at the SwiftLint docs I think it may be possible by defining a custom weak_delegate rule and excluding the path to my unit tests.
https://github.com/realm/SwiftLint#defining-custom-rules
Option 2: Disable Rules at Source Level:let noWarning :String = "" // No warning about colons immediately after variable names! let noWarning :String = "" // No warning about colons immediately after variable names!
Personally, I fire up Terminal, cd into the root directory of my project, and type touch . swiftlint. yml to create a blank file. Then go to your text editor of choice and add whatever rules you want (see the README for some examples, perhaps copy-and-paste some examples into your file).
One of the quickest ways to disable a unit test is to simply rename its name. Xcode will execute only those test methods that start with a prefix “test”. If a method name does not start with a test prefix, it will not be executed.
swiftlint. yml file to your project directory. Note that this file should be added alongside your Xcode project and your Xcode workspace. It should not be placed inside of your project files directory.
You can disable them at a local level using:
//swiftlint:disable weak_delegate
let someDelete: someDelegate?
//swiftlint:enable weak_delegate
or at target level, by modifying your .swiftlint.yml file (hidden)
weak_delegate:
excluded: ".*Test\\.swift" //regex path to your tests folder
or at project level, by modifying your .swiftlint.yml file (hidden)
disabled_rules:
- weak_delegate
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With