1
0
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:
SalvadorC 2021-08-16 12:15:17 +02:00 committed by GitHub
parent c582d6221f
commit 28559501d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -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)

View File

@ -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)/
}
}