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

question: how do we skip running rules on tests with ruleguard? #306

Open
harshavardhana opened this issue Nov 15, 2021 · 3 comments
Open

Comments

@harshavardhana
Copy link
Contributor

The self-explanatory question, just need to know if there is a way to skip tests. Was not able to find them in the docs.

Thanks for the help.

@quasilyte
Copy link
Owner

Hmm.
Usually, ruleguard is used from the golangci-lint context.
If it can skip test directories, then you should be able to skip warnings for tests with ease.

As for a standalone ruleguard, I don't have a good solution out of my head. Is there a convention that other linters follow?

@peakle
Copy link
Contributor

peakle commented Dec 5, 2021

maybe for specific rules you can use pattern like this one:
m.Where(!m.File().Name.Matches("_test.go")))

@quasilyte
Copy link
Owner

@peakle that should work, yes.
This has a benefit that ruleguard may at some point use this filter information to avoid even running the rules on a file that would never match the filter.
We don't do this kind of optimization yet, but it's definitely possible.
Any m.File() related filters are a subject for this optimization.

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