Skip to content

Commit 57bd7bf

Browse files
moitiasscop
authored andcommitted
fix: make --fix work (naively) with --prefix-path
1 parent 610a2bd commit 57bd7bf

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

pkg/result/processors/fixer.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@ func (f Fixer) Process(issues []result.Issue) []result.Issue {
5656
for file, issuesToFix := range issuesToFixPerFile {
5757
var err error
5858
f.sw.TrackStage("all", func() {
59-
err = f.fixIssuesInFile(file, issuesToFix)
59+
fileWithoutPathPrefix := file
60+
61+
if f.cfg.Output.PathPrefix != "" {
62+
fileWithoutPathPrefix = strings.Replace(fileWithoutPathPrefix, f.cfg.Output.PathPrefix+string(filepath.Separator), "", 1)
63+
}
64+
err = f.fixIssuesInFile(fileWithoutPathPrefix, issuesToFix)
6065
})
6166
if err != nil {
6267
f.log.Errorf("Failed to fix issues in file %s: %s", file, err)

test/fix_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ func TestFix(t *testing.T) {
5353
"--print-linter-name=false",
5454
"--out-format=line-number",
5555
"--fix",
56+
"--path-prefix=mock",
5657
).
5758
WithRunContext(rc).
5859
WithTargetPath(input).

0 commit comments

Comments
 (0)