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

Support staticcheck analyzer globs #38

Open
jpeach opened this issue Dec 20, 2023 · 2 comments
Open

Support staticcheck analyzer globs #38

jpeach opened this issue Dec 20, 2023 · 2 comments

Comments

@jpeach
Copy link

jpeach commented Dec 20, 2023

staticcheck supports using globs to enable and disable specific checks. This doesn't work in the analyzer, resulting in Error in pop: KeyError: "@com_github_sluongng_nogo_analyzer//staticcheck:QF*".

It would be great to support the glob syntax.

https://staticcheck.dev/docs/configuration/options/

@tomqwpl
Copy link

tomqwpl commented Mar 26, 2024

Or the "all" and "-ST1000" type syntax. Currently I can't copy the list of analyzers from my "staticcheck.conf", as it is of the form
["all", "-ST1000", "-ST1003"]

@sluongng
Copy link
Owner

We don't support the all syntax. But we do export a constant with all analyzers and we also support the - prefix to exclude some analyzers.

For more details, see

# Remove analyzers prefixed with a '-'
if analyzer.startswith("-"):

An example of using it could be found here https://github.com/buildbuddy-io/buildbuddy/blob/09476dae4223fad357d6220be5e5231ecef34f45/BUILD#L135-L158


As for the glob syntax, I highly doubt that we would be able to support it with the current setup.

The reason is that we are declaring each analyzer as its own dedicated Go package. This lets us have a dedicated Bazel target for each analyzer, allowing fine-grained build and dependencies. This lets us do the analyzer selection on the starlark level, which does not provide a globbing matcher on a list of strings.

We could, theoretically group this analyzer up into bigger packages. Such as grouping all QF under the same package and moving the analyzer selection from Starlark down to the Go level. However, that does come with a certain set of tradeoffs and I am not sure if it's worth it.
For that reason, I am not motivated to work on such a change. But if someone is willing to put in the work to investigate the feasibility and contribute to such change, then we can review and eventually merge it (given that it's an improvement).

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

No branches or pull requests

3 participants