@@ -12,43 +12,43 @@ import (
12
12
)
13
13
14
14
func NewMirror () * goanalysis.Linter {
15
- var ( // Issue reporter related.
15
+ var (
16
16
mu sync.Mutex
17
17
issues []goanalysis.Issue
18
18
)
19
19
20
20
a := mirror .NewAnalyzer ()
21
21
a .Run = func (pass * analysis.Pass ) (any , error ) {
22
- // mirror only lints test files if the `--with-tests` flag is passed, so we
23
- // pass the `with-tests` flag as true to the analyzer before running it. This
24
- // can be turned off by using the regular golangci-lint flags such as `--tests`
25
- // or `--skip-files` or can be disabled per linter via exclude rules (see
26
- // https://github.com/golangci/golangci-lint/issues/2527#issuecomment-1023707262)
27
- withTests := true
28
- violations := mirror .Run (pass , withTests )
22
+ // mirror only lints test files if the `--with-tests` flag is passed,
23
+ // so we pass the `with-tests` flag as true to the analyzer before running it.
24
+ // This can be turned off by using the regular golangci-lint flags such as `--tests` or `--skip-files`
25
+ // or can be disabled per linter via exclude rules.
26
+ // (see https://github.com/golangci/golangci-lint/issues/2527#issuecomment-1023707262)
27
+ violations := mirror .Run (pass , true )
29
28
30
29
if len (violations ) == 0 {
31
30
return nil , nil
32
31
}
33
32
34
- for i := range violations {
35
- tmp := violations [i ].Issue (pass .Fset )
33
+ for index := range violations {
34
+ i := violations [index ].Issue (pass .Fset )
36
35
37
36
issue := result.Issue {
38
37
FromLinter : a .Name ,
39
- Text : tmp .Message ,
40
- Pos : tmp .Start ,
38
+ Text : i .Message ,
39
+ Pos : i .Start ,
41
40
}
42
41
43
- if len (tmp .InlineFix ) > 0 {
42
+ if len (i .InlineFix ) > 0 {
44
43
issue .Replacement = & result.Replacement {
45
44
Inline : & result.InlineFix {
46
- StartCol : tmp .Start .Column - 1 ,
47
- Length : len (tmp .Original ),
48
- NewString : tmp .InlineFix ,
45
+ StartCol : i .Start .Column - 1 ,
46
+ Length : len (i .Original ),
47
+ NewString : i .InlineFix ,
49
48
},
50
49
}
51
50
}
51
+
52
52
mu .Lock ()
53
53
issues = append (issues , goanalysis .NewIssue (& issue , pass ))
54
54
mu .Unlock ()
0 commit comments