-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Don't load and analyze dirs from --skip-dirs #301
Comments
hi! You can use something like: go list -f '{{.Dir}}' ./... | fgrep -v node_modules/ | xargs realpath --relative-to=. | xargs golangci-lint run -v |
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
Looks this is still happening for
|
@lnshi |
@jirfag When does the filtering currently happen, on a per-file basis? Could not golangci-lint run the filter on |
One big problem if also if you have packages that do not compile (as detected by |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
After changing some linter settings, we began seeing that the linter was failing to run on v6 (when the "V7" build tag was not given). The errors were complaining about duplicate declarations in the "fixtures/plugins" directory (which was meant to be ignored by the linter, via the "skip-dirs" option). After investigating, I learned that Golangci-lint will still try to parse and analyze directories that are skipped in this way - it only uses the "skip-dirs" option to filter out any lint errors that are found after analysis is complete. Here's an open GitHub issue about this: golangci/golangci-lint#301 This means that if there are compilation errors in these skipped dirs, they will fail the linter, even though we want to skip them. I'm fixing this with a workaround suggested in that issue. Something like: ``` go list ./... | (grep for dirs you care to lint) | xargs golangci-lint run ``` A nice side effect is that, by truly skipping analysis of these dirs, the linter runs faster. [#172389465] Authored-by: Reid Mitchell <rmitchell@pivotal.io>
hey @jirfag Thanks for that shell and I have skipped these dirs. But I have a question is that If I use the shell with |
I am trying to run golangci-lint on sourcegraph/sourcegraph but it is failing due to the presence of some Go code in one of our node_modules dependencies (weird but ¯\_(ツ)_/¯). I tried using
--skip-dirs node_modules
, but it seems to not have any effect.Reproduce:
Requested info:
Version of golangci-lint:
golangci-lint --version
(or git commit if you don't use binary distribution)55a18ae
Config file:
cat .golangci.yml
None
Go environment:
go version && go env
golangci-lint run -v
The text was updated successfully, but these errors were encountered: