File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -13,28 +13,26 @@ type RedundantBuildTagRule struct{}
13
13
// `//go:build` comments are automatically added by gofmt when Go 1.17+ is used.
14
14
// See https://pkg.go.dev/cmd/go#hdr-Build_constraints
15
15
func (* RedundantBuildTagRule ) Apply (file * lint.File , arguments lint.Arguments ) []lint.Failure {
16
- var failures []lint.Failure
17
-
18
16
for _ , group := range file .AST .Comments {
19
17
hasGoBuild := false
20
18
for _ , comment := range group .List {
21
19
if strings .HasPrefix (comment .Text , "//go:build " ) {
22
20
hasGoBuild = true
23
21
continue
24
22
}
23
+
25
24
if hasGoBuild && strings .HasPrefix (comment .Text , "// +build " ) {
26
- failures = append ( failures , lint.Failure {
25
+ return [] lint.Failure { {
27
26
Category : "style" ,
28
27
Confidence : 1 ,
29
28
Node : comment ,
30
29
Failure : `The build tag "// +build" is redundant since Go 1.17 and can be removed` ,
31
- })
32
- return failures
30
+ }}
33
31
}
34
32
}
35
33
}
36
34
37
- return failures
35
+ return []lint. Failure {}
38
36
}
39
37
40
38
// Name returns the rule name.
You can’t perform that action at this time.
0 commit comments