There are several reasons for a function or closure not to have a body:
- It is an unintentional omission, and should be fixed to prevent unexpected behavior in production.
- It is not yet, or never will be, supported. In this case an exception should be thrown.
- The function is an intentionally-blank override. In this case a nested comment should explain the reason for the blank override.
Noncompliant Code Example
func fun(p1:Int) {
}
Compliant Solution
func fun(p1:Int) {
var a = doSomething(p1)
var threshold = 42
if a > threshold {
// ...
}
}
or
func fun(p1:Int) {
// Intentionally unimplemented...
}