-
Notifications
You must be signed in to change notification settings - Fork 10
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
Include/Exclude Files by Pattern #42
Comments
@mvrahden Thanks for sharing that use case. Just to check, are you using this linter standalone or in the context of golangci-lint? Used standalone, the linter doesn't have too much control over exclusions. |
Hi @ashanbrown, we use it in the context of golangci-lint |
Does golangci-lint not allow you to control where your rules apply? Recently there were some updates to golangci-lint, so you could also both include and exclude a set of files. |
Interesting, I wasn't aware of that change. I'll look into it |
@atom-andrew I don't think that helps with forbidgo because using that approach you'd disable forbidgo completely for some files. However this feature is needed on a per-pattern bases. We do need some forbidgo patterns to be applied globally while others should be only applied only to specific files. |
Is excluding rules by text insufficient to handle these cases? The notes there say "Also, you can use issues.exclude-rules config option for per-path or per-linter configuration." Possibly you might need to annotate your rules (i.e. include some special string in them), so that you can easily find it to exclude. Just to step back again, I'd definitely prefer to avoid building complex configuration logic forbidigo that can be handled by golang-ci (and shared with other linters). I suppose what is fairly different between forbidigo and other linters is that the rules are all user-defined. I'm not working actively in golang myself these days, but I'd be curious if there are other linters that have user-defined rules and how they handle these exclusions. |
Hi @ashanbrown, I can confirm that the exclude by path and by text option would work. Thanks for pointing it out |
Simple Example
We want to prevent devs from using
os.Setenv
in Tests and uset.Setenv
instead.However, the usage of
os.Setenv
in source this could be a viable solution.Therefore we'd like have a filename include matcher, to enable this forbidigo rule only on certain filepatterns, e.g. only on suffix
_test\.go$
.Proposal
Add the option of a filename exclude/include pattern to the config, which helps to dismiss certain files from the rule-enforcement.
The text was updated successfully, but these errors were encountered: