From 441e13b88700accbf00ee814059aca55de4f51b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=20Kl=C3=A4rner?= Date: Thu, 15 Aug 2024 17:45:36 +0200 Subject: [PATCH] fix(output): compare line numbers while consolidating without comparing line numbers we do not detect two blocks of errors with the same error message that are next to each other in output, but their originating sections are separated by error-free lines incorrect example: multiple-wrong-indentations.txt: 2-7: Wrong amount of left-padding spaces(want multiple of 10) 6 errors found 1 files checked correct example: multiple-wrong-indentations.txt: 2-4: Wrong amount of left-padding spaces(want multiple of 10) 8-9: Wrong amount of left-padding spaces(want multiple of 10) 6 errors found 1 files checked --- pkg/error/error.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/error/error.go b/pkg/error/error.go index 0d97a972..be62878b 100644 --- a/pkg/error/error.go +++ b/pkg/error/error.go @@ -56,7 +56,7 @@ func ConsolidateErrors(errors []ValidationError, config config.Config) []Validat // scan through the errors after the current one for j, nextError := range errorsWithLines[i+1:] { config.Logger.Debug("comparing against error %d(%s)", j, nextError.Message) - if nextError.Message.Error() == thisError.Message.Error() { + if nextError.Message.Error() == thisError.Message.Error() && nextError.LineNumber == thisError.LineNumber+thisError.ConsecuitiveCount+1 { thisError.ConsecuitiveCount++ // keep track of how many consecutive lines we've seen i = i + j + 1 // make sure the outer loop jumps over the consecutive errors we just found } else {