SwiftLint
SwiftLint copied to clipboard
"no_empty_block" causes default functions in protocols to be detected
trafficstars
New Issue Checklist
- [x] Updated SwiftLint to the latest version 0.56.1
- [x] I searched for existing GitHub issues
- yes
The rule "no_empty_block" causes default functions in protocols to be detected. It should specifically exclude functions in protocols from this detection.
for example
protocol Animal {
func run()
}
extension Animal {
func run() {}
}
The thing is that SwiftLint doesn't know that extension Animal is an extension of a protocol as it works only on the syntax level.
I wonder, though, why you think the rule shouldn't trigger in this case. The fact that the default behavior of a method is to do nothing, doesn't seem obvious and could be worth a comment. This would already silence the rule.