class SomeClass {
func update(badges: Any?) {
func process(badges: [String: Any]?) {
struct LastValues {
static var activities: Int?
static var chats: Int?
}
I need static variables in this function and the only way that I know is to use struct. But I get warning Nesting Violation: Types should be nested at most 1 level deep (nesting)
So is there a way how to use static variables and avoid this warning?
iMO you shouldn't change your code to please SwiftLint if you think this nesting is needed. You can disable a rule in code to ignore this warning as shown in the README.
The nesting rule exists for two reasons:
I don't think that either of these situations apply here.
Ideally we would adapt the rule to not trigger when types are defined in functions since those are only available within the scope of that function.
Since that is already tracked in #1151, I'm closing this.
Most helpful comment
The nesting rule exists for two reasons:
I don't think that either of these situations apply here.
Ideally we would adapt the rule to not trigger when types are defined in functions since those are only available within the scope of that function.