Allow to exclude certain target from nogo facts collection #4353
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Feature
What does this PR do? Why is it needed?
After #4268, nogo collects facts from all targets. So
go_register_nogo
'sincludes
andexcludes
now overlap with the JSON config'sonly_files
andexclude_files
, which is to surppress nogo errors in certain files/targets. Meanwhile, collecting facts can be slow for very large Go packages for some analyzers, slower than compilation. To address the performance issue, this PR revertexcludes
to its previous behavior: stop nogo from collecting facts from certain packages, while makingincludes
ofgo_register_nogo
a no-op with a warning message, asking people to use the JSON config instead. So nogo will continue to collect facts from all targets, which is the safe default, except those inexcludes
.Other notes for review
With this PR, users need to add a config like this to surppress issues in external repositories:
Or if all Go code they care about are under a specific directory, they can have:
Alternatively, to be backward-compatible, we can add a flag or attribute like
exclude_collect_facts
, but adding that on top ofexcludes
andexclude_files
makes hard to remember which is which.