Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Mar 7, 2024
1 parent 0fa95de commit 13b6954
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions pkg/result/processors/fixer.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,22 @@ func (f Fixer) mergeLineIssues(lineNum int, lineIssues []result.Issue, origFileL

// check issues first
for ind := range lineIssues {
i := &lineIssues[ind]
if i.LineRange != nil {
li := &lineIssues[ind]

if li.LineRange != nil {
f.log.Infof("Line %d has multiple issues but at least one of them is ranged: %#v", lineNum, lineIssues)
return &lineIssues[0]
}

r := i.Replacement
if r.Inline == nil || len(r.NewLines) != 0 || r.NeedOnlyDelete {
inline := li.Replacement.Inline

if inline == nil || len(li.Replacement.NewLines) != 0 || li.Replacement.NeedOnlyDelete {
f.log.Infof("Line %d has multiple issues but at least one of them isn't inline: %#v", lineNum, lineIssues)
return i
return li
}

if r.Inline.StartCol < 0 || r.Inline.Length <= 0 || r.Inline.StartCol+r.Inline.Length > len(origLine) {
f.log.Warnf("Line %d (%q) has invalid inline fix: %#v, %#v", lineNum, origLine, i, r.Inline)
if inline.StartCol < 0 || inline.Length <= 0 || inline.StartCol+inline.Length > len(origLine) {
f.log.Warnf("Line %d (%q) has invalid inline fix: %#v, %#v", lineNum, origLine, li, inline)
return nil
}
}
Expand Down

0 comments on commit 13b6954

Please sign in to comment.