diff --git a/pkg/result/processors/fixer.go b/pkg/result/processors/fixer.go index 17f519e32ba1..88d8d23fc3da 100644 --- a/pkg/result/processors/fixer.go +++ b/pkg/result/processors/fixer.go @@ -57,7 +57,12 @@ func (f Fixer) Process(issues []result.Issue) []result.Issue { for file, issuesToFix := range issuesToFixPerFile { var err error f.sw.TrackStage("all", func() { - err = f.fixIssuesInFile(file, issuesToFix) + fileWithoutPathPrefix := file + + if f.cfg.Output.PathPrefix != "" { + fileWithoutPathPrefix = strings.TrimPrefix(fileWithoutPathPrefix, f.cfg.Output.PathPrefix+string(filepath.Separator)) + } + err = f.fixIssuesInFile(fileWithoutPathPrefix, issuesToFix) }) if err != nil { f.log.Errorf("Failed to fix issues in file %s: %s", file, err) diff --git a/test/fix_test.go b/test/fix_test.go index 97cde38834b0..1c6ee7ec8e76 100644 --- a/test/fix_test.go +++ b/test/fix_test.go @@ -44,7 +44,7 @@ func TestFix(t *testing.T) { args := []string{ "--disable-all", "--print-issued-lines=false", "--print-linter-name=false", "--out-format=line-number", - "--allow-parallel-runners", "--fix", + "--allow-parallel-runners", "--fix", "--path-prefix=mock", input, } rc := extractRunContextFromComments(t, input)