Skip to content
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

staticcheck: Add option for passing folders that should be avoided #822

Closed
Jacalz opened this issue Sep 12, 2020 · 4 comments
Closed

staticcheck: Add option for passing folders that should be avoided #822

Jacalz opened this issue Sep 12, 2020 · 4 comments

Comments

@Jacalz
Copy link

Jacalz commented Sep 12, 2020

It would be great if you could pass a folder (or folders) where you don't want staticcheck to check the .go files. Useful if you, for example, are vendoing a different go module outside of the normal vendor folder.

@Jacalz Jacalz added the needs-triage Newly filed issue that needs triage label Sep 12, 2020
@Jacalz
Copy link
Author

Jacalz commented Sep 12, 2020

Might be related to #429

@Jacalz Jacalz changed the title Add option for passing folders that should be avoided staticcheck: Add option for passing folders that should be avoided Sep 12, 2020
@ainar-g
Copy link
Contributor

ainar-g commented Sep 12, 2020

That's a relatively simple POSIX Shell script though:

$ go list ./... | grep -F -e example.com/bad/pkg -v | xargs staticcheck

@Jacalz
Copy link
Author

Jacalz commented Sep 13, 2020

Thanks @ainar-g. That is quite a good workaround until this is solved in a better way :)
Preferably, having this as an option in something like staticcheck.conf.

@dominikh
Copy link
Owner

until this is solved in a better way
There will likely not be a better way. Passing the packages you want checked on the command-line is exactly the way to solve this. If the ... pattern matches too many packages, then you'll have to use something like Ainar's approach to filter that list. This is in line with tools like go test, where go test ./... will (probably?) also run more tests than you intended.

You could also place a staticcheck.conf at the top of your "vendor" directory that disables all checks (checks = []) – but you may have to delete nested staticcheck.conf files if your vendored dependencies have any, or they might re-enable checks.

@dominikh dominikh removed the needs-triage Newly filed issue that needs triage label Sep 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants