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 ?
You can disable rule in code by using comment.
https://github.com/realm/SwiftLint#disable-a-rule-in-code
// swiftlint:disable force_cast
I'm also in favor of composable features like this, rather than implementing a more complex configuration scheme. Closing.
@norio-nomura what if I want to disable for just specific target?
Like I have two targets: TargetA, TargetATests
And I only want swiftlint to apply to TargetA.
force_cast:
excluded:
- TargetATests
Second_rule:
excluded:
- TargetATests
@lyc2345 SwiftLint doesn't know anything about targets or anything Xcode-related really.
Your use case seems to be related to disabling some rules in a test target. In that case, I'd use nested configurations to disable them on the directory where the unit tests are.
nested configurations could solve my question, Thanks!
How to exclude Swift package manager from linting?
Most helpful comment
You can disable rule in code by using comment.
https://github.com/realm/SwiftLint#disable-a-rule-in-code