SwiftLint icon indicating copy to clipboard operation
SwiftLint copied to clipboard

"no_empty_block" causes default functions in protocols to be detected

Open inotetw opened this issue 1 year ago • 1 comments
trafficstars

New Issue Checklist

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() {}
}

inotetw avatar Aug 12 '24 02:08 inotetw

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.

SimplyDanny avatar Aug 12 '24 18:08 SimplyDanny