Skip to content

Commit 3c66122

Browse files
committed
feat: new default for relative-path-mode to cfg
1 parent 645ec86 commit 3c66122

File tree

7 files changed

+16
-5
lines changed

7 files changed

+16
-5
lines changed

.golangci.next.reference.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4172,7 +4172,7 @@ run:
41724172
# - `gitroot`: the paths will be relative to the git root (the parent directory of `.git`).
41734173
# - `cfg`: the paths will be relative to the configuration file.
41744174
# - `wd` (NOT recommended): the paths will be relative to the place where golangci-lint is run.
4175-
# Default: wd
4175+
# Default: cfg
41764176
relative-path-mode: gomod
41774177

41784178
# Exit code when at least one issue was found.

pkg/fsutils/basepath.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ func AllRelativePathModes() []string {
2525

2626
func GetBasePath(ctx context.Context, mode, cfgDir string) (string, error) {
2727
if mode == "" {
28-
// TODO(ldez): v2 the default should be cfg or gomod.
29-
mode = RelativePathModeWd
28+
mode = RelativePathModeCfg
3029
}
3130

3231
switch mode {

test/run_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -548,12 +548,12 @@ func TestPathPrefix(t *testing.T) {
548548
}{
549549
{
550550
desc: "empty",
551-
pattern: "^testdata/withtests/",
551+
pattern: "^test/testdata/withtests/",
552552
},
553553
{
554554
desc: "prefixed",
555555
args: []string{"--path-prefix=cool"},
556-
pattern: "^cool/testdata/withtests",
556+
pattern: "^cool/test/testdata/withtests",
557557
},
558558
}
559559

test/testdata/configs/default_exclude.yml

+3
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ linters:
66
- std-error-handling
77
- common-false-positives
88
- legacy
9+
10+
run:
11+
relative-path-mode: wd

test/testdata/configs/multiple-issues-fix.yml

+3
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ formatters:
66
settings:
77
gofumpt:
88
extra-rules: true
9+
10+
run:
11+
relative-path-mode: wd

test/testdata/configs/output.yml

+3
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ linters-settings:
66
ignore-words:
77
- langauge
88
- Dialogue
9+
10+
run:
11+
relative-path-mode: wd

test/testdata/configs/path-except.yml

+3
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ linters:
1414
- path-except: _test\.go
1515
linters:
1616
- forbidigo
17+
18+
run:
19+
relative-path-mode: wd

0 commit comments

Comments
 (0)