Disable bzl-visibility lint if the target file has a visibility() declaration#1439
Disable bzl-visibility lint if the target file has a visibility() declaration#1439oreflow merged 3 commits intobazelbuild:mainfrom
visibility() declaration#1439Conversation
…eclaration. The official docs for this lint say: > This lint predates the load visibility feature and is unnecessary in workspaces where .bzl files declare visibilities. However the lint can sometimes get in the way, by warning about instances where the usage is actually intended. Since `visibility()` is more explicit, and more strictly enforced, there is no need for the lint to return any warnings if the target file has a visibility declaration. MARKDOWN=true
Summary of ChangesHello @haberman, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refines the behavior of the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly implements the logic to disable the bzl-visibility lint when a visibility() declaration is present in the target file. The change to move the lint from FileWarningMap to MultiFileWarningMap is appropriate, as it now requires reading other files. The added test case is also good for verifying the new behavior. However, I've found a critical issue in the implementation that could lead to a panic due to an unsafe type assertion. Please address this to ensure the stability of the linter.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
oreflow
left a comment
There was a problem hiding this comment.
LGTM, just the mentioned note on that it would be great to have a test case where the file exists but does not have a visibility statement
|
Thanks for the review! PTAL. |
The official docs for the bzl-visibility lint say:
This statement is correct; load visibility is a strictly superior mechanism, because it is more explicit and more strictly enforced. All code should move towards
visibility()and away from this legacyprivate/naming scheme.However, this lint currently fires even in cases where visibility has been explicitly specified. This is unfortunate, because the usage may be intended, in which case the warning is pure noise. The only way to disable the warning in that case is to put the following comment on the code performing the import:
If
foo.bzlhas explicitly added the caller to itsvisibility()list, this extra comment is pure noise that adds no value. Worse, it's likely to get copied and pasted around, whether or not it is really needed.We should fix this by making the warning notice that the target file has an explicit
visibility()definition. If so, there is no need to emit the legacy warning.MARKDOWN=true