Type Body Length
Type bodies should not span too many lines
- Identifier:
type_body_length
- Enabled by default: Yes
- Supports autocorrection: No
- Kind: metrics
- Analyzer rule: No
- Minimum Swift compiler version: 5.0.0
- Default configuration:
Key Value warning 250 error 350 excluded_types [extension, protocol]
Non Triggering Examples
//
// warning: 2
//
actor A {}
//
// warning: 2
//
class C {}
//
// warning: 2
//
enum E {}
//
// warning: 2
// excluded_types: []
//
extension E {}
//
// warning: 2
// excluded_types: []
//
protocol P {}
//
// warning: 2
//
struct S {}
//
// warning: 2
//
actor A {
let x = 0
}
//
// warning: 2
//
class C {
let x = 0
// comments
// will
// be
// ignored
}
//
// warning: 2
//
enum E {
let x = 0
// empty lines will be ignored
}
//
// warning: 2
//
protocol P {
let x = 0
let y = 1
let z = 2
}
Triggering Examples
//
// warning: 2
//
↓actor A {
let x = 0
let y = 1
let z = 2
}
//
// warning: 2
//
↓class C {
let x = 0
let y = 1
let z = 2
}
//
// warning: 2
//
↓enum E {
let x = 0
let y = 1
let z = 2
}
//
// warning: 2
// excluded_types: []
//
↓extension E {
let x = 0
let y = 1
let z = 2
}
//
// warning: 2
// excluded_types: []
//
↓protocol P {
let x = 0
let y = 1
let z = 2
}
//
// warning: 2
//
↓struct S {
let x = 0
let y = 1
let z = 2
}