Skip to content

no-else-after-return

Default severity: warning

Configuration: severity and path excludes

Reports an else when the final direct statement of the corresponding if body is a return. Since control flow cannot continue past that return, the else body can be moved out one indentation level.

if err != nil {
return err
} else {
use(value)
}
if err != nil {
return err
}
use(value)

The current rule checks for a direct final return. It does not treat panic, continue, break, or a helper that never returns as equivalent terminals.

//strider:ignore no-else-after-return
if err != nil {
return err
} else {
// Deliberately mirrors a two-column protocol specification.
use(value)
}