@@ -21,7 +21,8 @@ type ignoredRange struct {
21
21
linters []string
22
22
matchedIssueFromLinter map [string ]bool
23
23
result.Range
24
- col int
24
+ col int
25
+ originalRange * ignoredRange // pre-expanded range (used to match nolintlint issues)
25
26
}
26
27
27
28
func (i * ignoredRange ) doesMatch (issue * result.Issue ) bool {
@@ -163,7 +164,11 @@ func (p *Nolint) shouldPassIssue(i *result.Issue) (bool, error) {
163
164
164
165
for _ , ir := range fd .ignoredRanges {
165
166
if ir .doesMatch (i ) {
167
+ nolintDebugf ("found ignored range for issue %v: %v" , i , ir )
166
168
ir .matchedIssueFromLinter [i .FromLinter ] = true
169
+ if ir .originalRange != nil {
170
+ ir .originalRange .matchedIssueFromLinter [i .FromLinter ] = true
171
+ }
167
172
return false , nil
168
173
}
169
174
}
@@ -199,9 +204,14 @@ func (e *rangeExpander) Visit(node ast.Node) ast.Visitor {
199
204
}
200
205
201
206
expandedRange := * foundRange
207
+ // store the original unexpanded range for matching nolintlint issues
208
+ if expandedRange .originalRange == nil {
209
+ expandedRange .originalRange = foundRange
210
+ }
202
211
if expandedRange .To < nodeEndLine {
203
212
expandedRange .To = nodeEndLine
204
213
}
214
+
205
215
nolintDebugf ("found range is %v for node %#v [%d;%d], expanded range is %v" ,
206
216
* foundRange , node , nodeStartLine , nodeEndLine , expandedRange )
207
217
e .expandedRanges = append (e .expandedRanges , expandedRange )
0 commit comments