@@ -21,7 +21,8 @@ type ignoredRange struct {
2121 linters []string
2222 matchedIssueFromLinter map [string ]bool
2323 result.Range
24- col int
24+ col int
25+ originalRange * ignoredRange // pre-expanded range (used to match nolintlint issues)
2526}
2627
2728func (i * ignoredRange ) doesMatch (issue * result.Issue ) bool {
@@ -163,7 +164,11 @@ func (p *Nolint) shouldPassIssue(i *result.Issue) (bool, error) {
163164
164165 for _ , ir := range fd .ignoredRanges {
165166 if ir .doesMatch (i ) {
167+ nolintDebugf ("found ignored range for issue %v: %v" , i , ir )
166168 ir .matchedIssueFromLinter [i .FromLinter ] = true
169+ if ir .originalRange != nil {
170+ ir .originalRange .matchedIssueFromLinter [i .FromLinter ] = true
171+ }
167172 return false , nil
168173 }
169174 }
@@ -199,9 +204,14 @@ func (e *rangeExpander) Visit(node ast.Node) ast.Visitor {
199204 }
200205
201206 expandedRange := * foundRange
207+ // store the original unexpanded range for matching nolintlint issues
208+ if expandedRange .originalRange == nil {
209+ expandedRange .originalRange = foundRange
210+ }
202211 if expandedRange .To < nodeEndLine {
203212 expandedRange .To = nodeEndLine
204213 }
214+
205215 nolintDebugf ("found range is %v for node %#v [%d;%d], expanded range is %v" ,
206216 * foundRange , node , nodeStartLine , nodeEndLine , expandedRange )
207217 e .expandedRanges = append (e .expandedRanges , expandedRange )
0 commit comments