File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,11 @@ func (w *lintUselessBreak) Visit(node ast.Node) ast.Visitor {
41
41
ast .Walk (w , v .Body )
42
42
w .inLoopBody = false
43
43
return nil
44
+ case * ast.RangeStmt :
45
+ w .inLoopBody = true
46
+ ast .Walk (w , v .Body )
47
+ w .inLoopBody = false
48
+ return nil
44
49
case * ast.CommClause :
45
50
for _ , n := range v .Body {
46
51
w .inspectCaseStatement (n )
Original file line number Diff line number Diff line change 1
1
package fixtures
2
2
3
- import "reflect"
3
+ import (
4
+ ast "go/ast"
5
+ "reflect"
6
+ )
4
7
5
8
func UselessBreaks () {
6
9
@@ -28,7 +31,7 @@ func UselessBreaks() {
28
31
for {
29
32
switch {
30
33
case c1 :
31
- break // MATCH /useless break in case clause (WARN: this break statement affects the switch or select statement and not the loop enclosing it)/
34
+ break // MATCH /useless break in case clause (WARN: this break statement affects this switch or select statement and not the loop enclosing it)/
32
35
}
33
36
}
34
37
@@ -37,7 +40,7 @@ func UselessBreaks() {
37
40
case * ast.FuncLit :
38
41
found = true
39
42
funcLit = node
40
- break // MATCH /useless break in case clause (WARN: this break statement affects the switch or select statement and not the loop enclosing it)/
43
+ break // MATCH /useless break in case clause (WARN: this break statement affects this switch or select statement and not the loop enclosing it)/
41
44
}
42
45
}
43
46
You can’t perform that action at this time.
0 commit comments