fixer: add warning about possible line range issue

This commit is contained in:
Aleksandr Razumov 2020-04-27 20:07:09 +03:00
parent 3deb9d80ab
commit 56f2b7d59d
No known key found for this signature in database
GPG Key ID: 1D14A82D2E311045

View File

@ -223,6 +223,12 @@ func (f Fixer) writeFixedFile(origFileLines [][]byte, issues []result.Issue, tmp
} else {
nextIssueIndex++
rng := nextIssue.GetLineRange()
if rng.From > rng.To {
// Maybe better decision is to skip such issues, re-evaluate if regressed.
f.log.Warnf("[fixer]: issue line range is probably invalid, fix can be incorrect (from=%d, to=%d, linter=%s)",
rng.From, rng.To, nextIssue.FromLinter,
)
}
i += rng.To - rng.From
if nextIssue.Replacement.NeedOnlyDelete {
continue