mirror of
https://github.com/mgechev/revive.git
synced 2024-11-24 08:32:22 +02:00
fix issue 556 (#557)
This commit is contained in:
parent
c582d6221f
commit
28559501d3
@ -41,6 +41,11 @@ func (w *lintUselessBreak) Visit(node ast.Node) ast.Visitor {
|
||||
ast.Walk(w, v.Body)
|
||||
w.inLoopBody = false
|
||||
return nil
|
||||
case *ast.RangeStmt:
|
||||
w.inLoopBody = true
|
||||
ast.Walk(w, v.Body)
|
||||
w.inLoopBody = false
|
||||
return nil
|
||||
case *ast.CommClause:
|
||||
for _, n := range v.Body {
|
||||
w.inspectCaseStatement(n)
|
||||
|
9
testdata/useless-break.go
vendored
9
testdata/useless-break.go
vendored
@ -1,6 +1,9 @@
|
||||
package fixtures
|
||||
|
||||
import "reflect"
|
||||
import (
|
||||
ast "go/ast"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
func UselessBreaks() {
|
||||
|
||||
@ -28,7 +31,7 @@ func UselessBreaks() {
|
||||
for {
|
||||
switch {
|
||||
case c1:
|
||||
break // MATCH /useless break in case clause (WARN: this break statement affects the switch or select statement and not the loop enclosing it)/
|
||||
break // MATCH /useless break in case clause (WARN: this break statement affects this switch or select statement and not the loop enclosing it)/
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,7 +40,7 @@ func UselessBreaks() {
|
||||
case *ast.FuncLit:
|
||||
found = true
|
||||
funcLit = node
|
||||
break // MATCH /useless break in case clause (WARN: this break statement affects the switch or select statement and not the loop enclosing it)/
|
||||
break // MATCH /useless break in case clause (WARN: this break statement affects this switch or select statement and not the loop enclosing it)/
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user