What is the nesting rules supposed to do? I think it doesn't work.
For example, with the nesting rule enabled, I get a warning, Nesting Violation: Types should be nested at most 1 level deep (nesting):
class View: UIView {
enum State {
case Ready, Executing, Finished
}
}
But the nesting is correct.
The nesting rule will throw a violation when types are nested more than 1 level, or statements more than 5 levels. For example:
OK
class Class0 {
class Class1 {
}
}
Done linting! Found 0 violations, 0 serious in 1 file.
Style Violation
class Class0 {
class Class1 {
class Class2 {
}
}
}
file.swift:3:9: warning: Nesting Violation: Types should be nested at most 1 level deep (nesting)
Done linting! Found 1 violation, 0 serious in 1 file.
What you're found is a bug which treated enum cases as a type declaration, which meant that enum _cases_ could also only be nested one level deep, which is not the intention. I just fixed in 2131613166b12677a09c6b2d1b48d9ce4cb7093f. Thanks for reporting this!
I still have this issue
@eaigner based on this and the several other bug reports you've filed, you need to update your version of SwiftLint version to the latest (0.9.1), which has all these features.
You can tell which version of SwiftLint you're using by running swiftlint version.
Yep. Totally my fault. Sorry. (was 0.3.0)
Can I change settings for this rule? I mean, what if I want to have this rule but I want to have level for type = 3 or something like this
You can't change the thresholds for nesting_rule at the moment, but the rule could easily be modified to allow such configuration.
The issue still persists on 0.18.1
I get the warning with following setup
struct A {
func Foo {
enum Boo {
// Warning is caused because of this
}
}
Is it because of the enum inside a func in a struct, or am I missing out something here.
I am using 0.24.0 and still facing this
struct S
{
enum Value: String {
//Warning caused
case a, b
}
}
Still facing this issue "nesting: 3" does not do anything in the config file
@sbrighiu try this (assuming you want 3 for nesting)
nesting:
type_level: 3
Most helpful comment
@sbrighiu try this (assuming you want
3for nesting)