File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -164,6 +164,7 @@ func (p *Nolint) shouldPassIssue(i *result.Issue) (bool, error) {
164
164
165
165
for _ , ir := range fd .ignoredRanges {
166
166
if ir .doesMatch (i ) {
167
+ nolintDebugf ("found ignored range for issue %v: %v" , i , ir )
167
168
ir .matchedIssueFromLinter [i .FromLinter ] = true
168
169
if ir .originalRange != nil {
169
170
ir .originalRange .matchedIssueFromLinter [i .FromLinter ] = true
@@ -203,7 +204,10 @@ func (e *rangeExpander) Visit(node ast.Node) ast.Visitor {
203
204
}
204
205
205
206
expandedRange := * foundRange
206
- expandedRange .originalRange = foundRange
207
+ // store the original unexpanded range for matching nolintlint issues
208
+ if expandedRange .originalRange == nil {
209
+ expandedRange .originalRange = foundRange
210
+ }
207
211
if expandedRange .To < nodeEndLine {
208
212
expandedRange .To = nodeEndLine
209
213
}
Original file line number Diff line number Diff line change 1
- //args: -Enolintlint
1
+ //args: -Enolintlint -Emisspell
2
2
//config: linters-settings.nolintlint.require-explanation=true
3
3
//config: linters-settings.nolintlint.require-specific=true
4
4
//config: linters-settings.nolintlint.allow-leading-space=false
@@ -10,4 +10,11 @@ func Foo() {
10
10
fmt .Println ("not specific" ) //nolint // ERROR "directive `.*` should mention specific linter such as `//nolint:my-linter`"
11
11
fmt .Println ("not machine readable" ) // nolint // ERROR "directive `.*` should be written as `//nolint`"
12
12
fmt .Println ("extra spaces" ) // nolint:deadcode // because // ERROR "directive `.*` should not have more than one leading space"
13
+
14
+ // test expanded range
15
+ //nolint:misspell // deliberate misspelling to trigger nolintlint
16
+ func () {
17
+ mispell := true
18
+ fmt .Println (mispell )
19
+ }()
13
20
}
You can’t perform that action at this time.
0 commit comments