File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ func NewUnused() *goanalysis.Linter {
33
33
for _ , ur := range u .Result () {
34
34
p := u .ProblemObject (lintCtx .Packages [0 ].Fset , ur )
35
35
pkg := typesToPkg [ur .Pkg ()]
36
- issues = append ( issues , goanalysis . NewIssue ( & result.Issue { //nolint:scopelint
36
+ i := & result.Issue {
37
37
FromLinter : name ,
38
38
Text : p .Message ,
39
39
Pos : p .Pos ,
@@ -42,11 +42,16 @@ func NewUnused() *goanalysis.Linter {
42
42
From : p .Pos .Line ,
43
43
To : p .End .Line ,
44
44
},
45
- Replacement : & result.Replacement {
45
+ }
46
+ // See https://github.com/golangci/golangci-lint/issues/1048
47
+ // If range is invalid, this will break `--fix` mode.
48
+ if i .LineRange .To >= i .LineRange .From {
49
+ i .Replacement = & result.Replacement {
46
50
// Suggest deleting unused stuff.
47
51
NeedOnlyDelete : true ,
48
- },
49
- }, nil ))
52
+ }
53
+ }
54
+ issues = append (issues , goanalysis .NewIssue (i , nil ))
50
55
}
51
56
return issues
52
57
}).WithContextSetter (func (lintCtx * linter.Context ) {
You can’t perform that action at this time.
0 commit comments