Skip to content

Commit 441bdb3

Browse files
sean-jirfag
authored andcommitted
Fix the skip-dirs option.
Prior to this change the SkipDir runner was not skipping files such as `foo/bar/baz.go` with a `skip-dir` entry of `foo/bar` when the `run` command was invoked with an argument of `foo/...`. This is both a surprising and problematic behavior change. The pathology was: 1. `shouldPassIssue()` was receiving an input like `foo/bar/baz.go` 2. `shouldPassIssue()` would call `p.getLongestArgRelativeIssuePath()` which was returning `bar`, not `foo/bar` as expected. 3. The reason for this was because inside of `getLongestArgRelativeIssuePath()` it was trimming the prefix that matched the path prefix (e.g. `foo/`). If you have the file structure: - foo/bar/baz.go - bur/bar/baz.go There is no way to isolate `foo/bar` from `bur/baz` without strictly controlling both your `skip-dirs` configuration and the arguments to `run`. The rest of the logic to skip files that don't match `run`'s argument is valid, however the regexp should be evaluated based on the `filepath.Dir()` of the input (e.g. `foo/bar`) and not the truncated version of the issue's filepath. Fixes: #301
1 parent e72fe05 commit 441bdb3

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

Diff for: pkg/result/processors/skip_dirs.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@ func (p *SkipDirs) getLongestArgRelativeIssuePath(i *result.Issue) string {
8585
continue
8686
}
8787

88-
relPath := strings.TrimPrefix(issueAbsPath, arg)
89-
relPath = strings.TrimPrefix(relPath, string(filepath.Separator))
90-
return relPath
88+
return i.FilePath()
9189
}
9290

9391
p.log.Infof("Issue path %q isn't relative to any of run args", i.FilePath())

0 commit comments

Comments
 (0)