8000 fix: exclusions path-except by ldez · Pull Request #5798 · golangci/golangci-lint · GitHub
[go: up one dir, main page]

Skip to content

fix: exclusions path-except #5798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/result/processors/exclusion_paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,5 @@ func (p *ExclusionPaths) shouldPassIssue(issue *result.Issue) bool {
matched = true
}

return !matched
return matched
}
41 changes: 31 additions & 10 deletions pkg/result/processors/exclusion_paths_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ func TestExclusionPaths_Process(t *testing.T) {
{RelativePath: filepath.FromSlash("base/d/file.go")},
},
expected: []result.Issue{
{RelativePath: filepath.FromSlash("base/a/file.go")},
{RelativePath: filepath.FromSlash("base/b/file.go")},
{RelativePath: filepath.FromSlash("base/d/file.go")},
{RelativePath: filepath.FromSlash("base/c/file.go")},
{RelativePath: filepath.FromSlash("base/c/a/file.go")},
{RelativePath: filepath.FromSlash("base/c/b/file.go")},
},
},
{
Expand All @@ -151,9 +151,9 @@ func TestExclusionPaths_Process(t *testing.T) {
{RelativePath: filepath.FromSlash("base/d/file.go")},
},
expected: []result.Issue{
{RelativePath: filepath.FromSlash("base/a/file.go")},
{RelativePath: filepath.FromSlash("base/b/file.go")},
{RelativePath: filepath.FromSlash("base/d/file.go")},
{RelativePath: filepath.FromSlash("base/c/file.go")},
{RelativePath: filepath.FromSlash("base/c/a/file.go")},
{RelativePath: filepath.FromSlash("base/c/b/file.go")},
},
},
{
Expand All @@ -174,13 +174,14 @@ func TestExclusionPaths_Process(t *testing.T) {
{RelativePath: filepath.FromSlash("base/e/file.go")},
},
expected: []result.Issue{
{RelativePath: filepath.FromSlash("base/a/file.go")},
{RelativePath: filepath.FromSlash("base/b/file.go")},
{RelativePath: filepath.FromSlash("base/d/file.go")},
{RelativePath: filepath.FromSlash("base/c/file.go")},
{RelativePath: filepath.FromSlash("base/c/a/file.go")},
{RelativePath: filepath.FromSlash("base/c/b/file.go")},
{RelativePath: filepath.FromSlash("base/e/file.go")},
},
},
{
desc: "pathsExcept and paths",
desc: "pathsExcept and paths (disjoint)",
cfg: &config.LinterExclusions{
Paths: []string{"^base/b/"},
PathsExcept: []string{`^base/c/.*$`},
Expand All @@ -194,9 +195,29 @@ func TestExclusionPaths_Process(t *testing.T) {
{RelativePath: filepath.FromSlash("base/d/file.go")},
},
expected: []result.Issue{
{RelativePath: filepath.FromSlash("base/c/file.go")},
{RelativePath: filepath.FromSlash("base/c/a/file.go")},
{RelativePath: filepath.FromSlash("base/c/b/file.go")},
},
},
{
desc: "pathsExcept and paths (intersection)",
cfg: &config.LinterExclusions{
Paths: []string{"^base/c/a/"},
PathsExcept: []string{`^base/c/.*$`},
},
issues: []result.Issue{
{RelativePath: filepath.FromSlash("base/a/file.go")},
{RelativePath: filepath.FromSlash("base/b/file.go")},
{RelativePath: filepath.FromSlash("base/c/file.go")},
{RelativePath: filepath.FromSlash("base/c/a/file.go")},
{RelativePath: filepath.FromSlash("base/c/b/file.go")},
{RelativePath: filepath.FromSlash("base/d/file.go")},
},
expected: []result.Issue{
{RelativePath: filepath.FromSlash("base/c/file.go")},
{RelativePath: filepath.FromSlash("base/c/b/file.go")},
},
},
}

Expand Down
Loading
0