mirror of
https://github.com/mgechev/revive.git
synced 2025-01-10 03:17:11 +02:00
Fix issue19 (#20)
* Adds rule superfluous-else (an extension of indent-error-flow) * Fix superfluous-else rule struct namming. * Adds superfuous-else rule to the rules table * fix issue 19
This commit is contained in:
parent
c9bde6c503
commit
4e19174270
@ -21,3 +21,20 @@ func g(f func() bool) string {
|
||||
return "it's NOT okay!"
|
||||
}
|
||||
}
|
||||
|
||||
func h(f func() bool, x int) string {
|
||||
if err == author.ErrCourseNotFound {
|
||||
return
|
||||
} else if err == author.ErrCourseAccess {
|
||||
// side effect
|
||||
} else if err == author.AnotherError {
|
||||
return "okay"
|
||||
} else {
|
||||
if ok := f(); ok {
|
||||
return "it's okay"
|
||||
} else { // MATCH /if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)/
|
||||
return "it's NOT okay!"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,9 @@ func (w lintElse) Visit(node ast.Node) ast.Visitor {
|
||||
return w
|
||||
}
|
||||
if w.ignore[ifStmt] {
|
||||
if elseif, ok := ifStmt.Else.(*ast.IfStmt); ok {
|
||||
w.ignore[elseif] = true
|
||||
}
|
||||
return w
|
||||
}
|
||||
if elseif, ok := ifStmt.Else.(*ast.IfStmt); ok {
|
||||
@ -74,3 +77,4 @@ func (w lintElse) Visit(node ast.Node) ast.Visitor {
|
||||
}
|
||||
return w
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user