1
1
package rule
2
2
3
3
import (
4
- "github.com/mgechev/revive/lint"
5
4
"go/ast"
5
+
6
+ "github.com/mgechev/revive/lint"
6
7
)
7
8
8
9
// UseAnyRule lints given else constructs.
@@ -13,7 +14,6 @@ func (*UseAnyRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
13
14
var failures []lint.Failure
14
15
15
16
walker := lintUseAny {
16
- commentPositions : getCommentsPositions (file .AST .Comments ),
17
17
onFailure : func (failure lint.Failure ) {
18
18
failures = append (failures , failure )
19
19
},
@@ -30,8 +30,7 @@ func (*UseAnyRule) Name() string {
30
30
}
31
31
32
32
type lintUseAny struct {
33
- commentPositions []int
34
- onFailure func (lint.Failure )
33
+ onFailure func (lint.Failure )
35
34
}
36
35
37
36
func (w lintUseAny ) Visit (n ast.Node ) ast.Visitor {
@@ -41,13 +40,7 @@ func (w lintUseAny) Visit(n ast.Node) ast.Visitor {
41
40
}
42
41
43
42
if len (it .Methods .List ) != 0 {
44
- return w // it is not an empty interface
45
- }
46
-
47
- for _ , pos := range w .commentPositions {
48
- if pos > int (it .Pos ()) && pos < int (it .End ()) {
49
- return w // it is a comment inside the interface
50
- }
43
+ return w // it is not and empty interface
51
44
}
52
45
53
46
w .onFailure (lint.Failure {
@@ -59,14 +52,3 @@ func (w lintUseAny) Visit(n ast.Node) ast.Visitor {
59
52
60
53
return w
61
54
}
62
-
63
- func getCommentsPositions (commentGroups []* ast.CommentGroup ) []int {
64
- result := []int {}
65
- for _ , commentGroup := range commentGroups {
66
- for _ , comment := range commentGroup .List {
67
- result = append (result , int (comment .Pos ()))
68
- }
69
- }
70
-
71
- return result
72
- }
0 commit comments