-
-
Notifications
You must be signed in to change notification settings - Fork 675
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
nogo: include and exclude targets in configuration #2513
Comments
This is kind of hard to set up. The Configuring analyzers section in the nogo documentation has some information on this. However, the configuration language leaves a lot to be desired, and there's no simple way to exclude external packages. I'll retitle the issue to reflect that. Nogo definitely needs to be able to analyze packages in external repos though, and that should remain the default. |
Our repo ran into an issue where we were unintentionally linting an external library. As an attempt to prevent linting external libraries within our nogo config all of our linters have the line:
However, if an external repo contains At first, I tried to fix by adding an anchor (e.g.
|
Its a bit confusing how I am running into this
As we have an indirect dependency on github.com/mattn/go-sqlite3 which is cgo, I have added
to our config... but it still failing as its scanning from rules_go_work-* for whatever reason So adding another exclude on |
I'm hitting the same issue; tried to setup nogo but I get a ton of build-time code analysis errors for external projects (maybe also for internal code, I'm not getting that far). Is it not possible to have some kind of option in the register-toolchain and disable nogo at runtime / analysis phase even? Edit: I just gave this a shot and "solved" this here: master...tommyknows:nogo-exclude It's not really pretty, but maybe a good starting point for a proper PR? |
@tommyknows That solution looks reasonable, and would definitely increase the usability of |
Would it make sense to just add an extra |
Copying a comment from #2675: I think it would be reasonable to add fields like |
+1 to @brianwolfe's suggestion: we could reserve the analyzer name |
As long as we are confident there won't be an analyzer called |
We experience this too when udating to 0.27. It looks exactly like in this old issue: #2172 |
This may also be related: #2862 |
I'm interested in picking this up: I put together a PoC here: #3351 I took the suggestion in #2513 (comment) and tried to apply it., but called it |
Nogo can now be restricted to on a per-package level: https://github.com/bazelbuild/rules_go/blob/master/docs/go/core/bzlmod.md#configuring-nogo |
What version of rules_go are you using?
What version of gazelle are you using?
What version of Bazel are you using?
bazel 3.1.0-homebrew
Does this issue reproduce with the latest releases of all the above?
Yes
What operating system and processor architecture are you using?
Macos
Any other potentially useful information about your toolchain?
I am using go modules.
What did you do?
go_register_toolchains(nogo = "@io_bazel_rules_go//:tools_nogo")
I want to use nogo. I followed the instructions ( I know it mentions this) and it lines external packages which I have no control over. Is there a way I can limit it my code ?
What did you expect to see?
Lint only my code
What did you see instead?
Lints everything in the external.
The text was updated successfully, but these errors were encountered: