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 {
3333 for _ , ur := range u .Result () {
3434 p := u .ProblemObject (lintCtx .Packages [0 ].Fset , ur )
3535 pkg := typesToPkg [ur .Pkg ()]
36- issues = append ( issues , goanalysis . NewIssue ( & result.Issue { //nolint:scopelint
36+ i := & result.Issue {
3737 FromLinter : name ,
3838 Text : p .Message ,
3939 Pos : p .Pos ,
@@ -42,11 +42,16 @@ func NewUnused() *goanalysis.Linter {
4242 From : p .Pos .Line ,
4343 To : p .End .Line ,
4444 },
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 {
4650 // Suggest deleting unused stuff.
4751 NeedOnlyDelete : true ,
48- },
49- }, nil ))
52+ }
53+ }
54+ issues = append (issues , goanalysis .NewIssue (i , nil ))
5055 }
5156 return issues
5257 }).WithContextSetter (func (lintCtx * linter.Context ) {
You can’t perform that action at this time.
0 commit comments