Allow to exclude certain target from nogo facts collection#4353
Open
linzhp wants to merge 9 commits intobazel-contrib:masterfrom
Open
Allow to exclude certain target from nogo facts collection#4353linzhp wants to merge 9 commits intobazel-contrib:masterfrom
linzhp wants to merge 9 commits intobazel-contrib:masterfrom
Conversation
linzhp
commented
May 22, 2025
| } | ||
| if currentConfig.excludeFiles == nil { | ||
| // TODO(linzhp): add a test to verify the case of []. | ||
| currentConfig.excludeFiles = []*regexp.Regexp{_externalFilePattern} |
Contributor
Author
There was a problem hiding this comment.
With this, most repos no longer need the JSON config unless they want to exclude certain paths in the repo. @fmeum
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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'sincludesandexcludesnow overlap with the JSON config'sonly_filesandexclude_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 revertexcludesto its previous behavior: stop nogo from collecting facts from certain packages. To avoid collecting facts from IDL-generated code, users can do this:The
includesofgo_register_nogoa no-op with a warning message, so nogo collects facts from all packages unless excluded explicitly. Users have to use the JSON config to limit the scope of nogo validation.This PR also exclude all external targets from nogo validation by default, which is equivalent to
{ "_base": { "exclude_files": { "^external/": "external repositories" } } }Other notes for review
Alternatively, to be backward-compatible, we can add a flag or attribute like
exclude_collect_facts, but adding that on top ofexcludesandexclude_filesmakes hard to remember which is which.