Skip to content

Conversation

@sean-
Copy link
Contributor

@sean- sean- commented Dec 6, 2018

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.

This fixed unexpected breakage resulting from a recent upgrade.

Fixes: #301

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: golangci#301
@CLAassistant
Copy link

CLAassistant commented Dec 6, 2018

CLA assistant check
All committers have signed the CLA.

@jirfag
Copy link
Contributor

jirfag commented Dec 22, 2018

thank you! but tests don't pass, I will include your PR and fix it in #327

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't load and analyze dirs from --skip-dirs

3 participants