@@ -18,11 +18,12 @@ type posMapper func(pos token.Position) token.Position
18
18
// to get filename. And they return adjusted filename (e.g. *.qtpl) for an issue. We need
19
19
// restore real .go filename to properly output it, parse it, etc.
20
20
type FilenameUnadjuster struct {
21
- m map [string ]posMapper // map from adjusted filename to position mapper: adjusted -> unadjusted position
22
- log logutils.Log
21
+ m map [string ]posMapper // map from adjusted filename to position mapper: adjusted -> unadjusted position
22
+ log logutils.Log
23
+ loggedUnadjustments map [string ]bool
23
24
}
24
25
25
- var _ Processor = FilenameUnadjuster {}
26
+ var _ Processor = & FilenameUnadjuster {}
26
27
27
28
func NewFilenameUnadjuster (cache * astcache.Cache , log logutils.Log ) * FilenameUnadjuster {
28
29
m := map [string ]posMapper {}
@@ -51,16 +52,17 @@ func NewFilenameUnadjuster(cache *astcache.Cache, log logutils.Log) *FilenameUna
51
52
}
52
53
53
54
return & FilenameUnadjuster {
54
- m : m ,
55
- log : log ,
55
+ m : m ,
56
+ log : log ,
57
+ loggedUnadjustments : map [string ]bool {},
56
58
}
57
59
}
58
60
59
61
func (p FilenameUnadjuster ) Name () string {
60
62
return "filename_unadjuster"
61
63
}
62
64
63
- func (p FilenameUnadjuster ) Process (issues []result.Issue ) ([]result.Issue , error ) {
65
+ func (p * FilenameUnadjuster ) Process (issues []result.Issue ) ([]result.Issue , error ) {
64
66
return transformIssues (issues , func (i * result.Issue ) * result.Issue {
65
67
issueFilePath := i .FilePath ()
66
68
if ! filepath .IsAbs (i .FilePath ()) {
@@ -79,7 +81,10 @@ func (p FilenameUnadjuster) Process(issues []result.Issue) ([]result.Issue, erro
79
81
80
82
newI := * i
81
83
newI .Pos = mapper (i .Pos )
82
- p .log .Infof ("Unadjusted from %v to %v" , i .Pos , newI .Pos )
84
+ if ! p .loggedUnadjustments [i .Pos .Filename ] {
85
+ p .log .Infof ("Unadjusted from %v to %v" , i .Pos , newI .Pos )
86
+ p .loggedUnadjustments [i .Pos .Filename ] = true
87
+ }
83
88
return & newI
84
89
}), nil
85
90
}
0 commit comments