I'm trying to do something like this in my .swiftlint.yml file:
force_cast:
severity: warning # explicitly
excluded:
- Dog.swift
I have this code and I don't like the force_try warning I'm getting for it:
let cell = tableView.dequeueReusableCellWithIdentifier(Constants.dogViewCellReuseIdentifier,
forIndexPath: indexPath) as! DogViewCell
I want to suppress the warning for this file by excluding this file from the rule.
Is there a way to do that ?
Well, if you don't want some specific rules to be applied to a specific file you can use the technique mentioned by @Benno Kress. For that you need to add a comment in your swift file as given below.
The rules will be disabled until the end of the file or until the linter sees a matching enable comment:
// swiftlint:disable <rule1>
YOUR CODE WHERE NO rule1 is applied
// swiftlint:enable <rule1>
It is also possible to skip some files by configuring swiftlint. add a ".swiftlint.yml" file in the directory where you'll run SwiftLint.
Add the following content to exclude some files. Lets say file1, file2 ... etc
excluded:
- file1
- file2
- folder1
- folder1/ExcludedFile.swift
To disable some rules completely add the following to the same ".swiftlint.yml" file.
disabled_rules: # rule identifiers to exclude from running
- colon
- comma
- control_statement
for more information, refer the following links.