From 56f2b7d59d6149a52559c23845f37f6f4739dd51 Mon Sep 17 00:00:00 2001 From: Aleksandr Razumov Date: Mon, 27 Apr 2020 20:07:09 +0300 Subject: [PATCH] fixer: add warning about possible line range issue --- pkg/result/processors/fixer.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/result/processors/fixer.go b/pkg/result/processors/fixer.go index 3f7abbc8..29313d7f 100644 --- a/pkg/result/processors/fixer.go +++ b/pkg/result/processors/fixer.go @@ -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