diff --git a/pkg/result/processors/fixer.go b/pkg/result/processors/fixer.go index f74b0f553cd5..8e66720fb938 100644 --- a/pkg/result/processors/fixer.go +++ b/pkg/result/processors/fixer.go @@ -80,13 +80,14 @@ func (p Fixer) process(issues []result.Issue) ([]result.Issue, error) { formatters := []string{gofumpt.Name, goimports.Name, gofmt.Name, gci.Name} var notFixableIssues []result.Issue - var formatIssues []result.Issue + + var tobeFormattedFiles map[string]struct{} for i := range issues { issue := issues[i] if slices.Contains(formatters, issue.FromLinter) { - formatIssues = append(formatIssues, issue) + tobeFormattedFiles[issue.FilePath()] = struct{}{} continue } @@ -203,9 +204,7 @@ func (p Fixer) process(issues []result.Issue) ([]result.Issue, error) { formattedFiles = append(formattedFiles, path) } - for i := range formatIssues { - path := issues[i].FilePath() - + for path := range tobeFormattedFiles { // Skips files already formatted by the previous fix step. if !slices.Contains(formattedFiles, path) { content, err := p.fileCache.GetFileBytes(path)