Description
New Issue Checklist
- Updated SwiftLint to the latest version
- I searched for existing GitHub issues
New rule request
This is more of an edit to an existing rule than a new rule, so apologies if this is the wrong format... Add a boolean option to the Nesting rule. When this option is enabled, enum's conforming to CodingKey
won't count as violations of nesting.
My main argument for this is that CodingKey's are less of a nested "type" and more of an annotation of the current type for Codable
If you have types that have custom CodingKey
types, you basically lose a
Triggering
struct Wrapper: Codable {
struct Inner: Codable {
struct WayInner: Codable {
}
}
}
struct Wrapper: Codable {
enum CodingKeys: String, CodingKey {
case id = "identifier"
struct TechnicallyOkayButBad {
struct Violation {}
}
}
}
Non Triggering
struct Wrapper: Codable {
struct Inner: Codable {
let id: Int
enum CodingKeys: String, CodingKey {
case id = "identifier
}
}
}
I think I would propose this be an opt-in setting on the nesting rule.
Looking at the criteria in the README
A rule that can have many false positives
I think this change would actually reduce false positives
A rule that is too slow
I don't think this would be an issue
A rule that is not general consensus or is only useful in some cases
I'm not sure if there's consensus here. And it's a very specific case...