Allowing to disable buildozer on specific targets via #buildozer: leave-alone#1453
Allowing to disable buildozer on specific targets via #buildozer: leave-alone#1453
Conversation
oreflow
commented
Mar 5, 2026
- Moving inherited comments to parsing instead of live-checks (note, this will miss comments added in the same change)
- Moving comment parsing to separate file, reused by both Buildifier and Buildozer
- Adding logic for Buildozer to ignore making changes to exprs tagged with #buildozer: leave-alone comments
…ve-alone - Moving inherited comments to parsing instead of live-checks (note, this will miss comments added in the same change) - Moving comment parsing to separate file, reused by both Buildifier and Buildozer - Adding logic for Buildozer to ignore making changes to exprs tagged with #buildozer: leave-alone comments
Summary of ChangesHello, 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 enhances the parsing and manipulation of BUILD files by introducing a new mechanism for comment inheritance within the AST and centralizing comment-related utilities. The primary impact is the ability to mark specific expressions with a Highlights
Changelog
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 introduces a useful feature to disable buildozer on specific targets using a #buildozer: leave-alone comment. The implementation correctly filters out tagged rules from modifications. The changes also include a significant and valuable refactoring of comment handling, moving comment inheritance logic into the parsing phase and centralizing it in a new comments.go file. This improves code clarity and maintainability.
I have a suggestion regarding the new comment inheritance logic to improve its clarity and ensure consistency with intended behavior.
| if suffixComment.Start.Line <= eStart.Line || suffixComment.Start.Line <= eEnd.Line { | ||
| // Suffix comments are inherited only for expressions which overlap with the comment line number. | ||
| cs.Inherited = append(cs.Inherited, suffixComment) | ||
| } |
There was a problem hiding this comment.
The condition suffixComment.Start.Line <= eStart.Line || suffixComment.Start.Line <= eEnd.Line is redundant and can be simplified to suffixComment.Start.Line <= eEnd.Line.
However, the existing comment on line 919 states that suffix comments are inherited for expressions that overlap with the comment line number. An overlap check would be eStart.Line <= suffixComment.Start.Line && suffixComment.Start.Line <= eEnd.Line.
This creates a discrepancy between the code's logic and its documentation. Please clarify the intended behavior. If the 'overlap' behavior (as described in the existing comment) was the intentional previous behavior, the code should be adjusted to implement that. If the suffixComment.Start.Line <= eEnd.Line behavior is the intended one, then the code can be simplified as noted, and the comment on line 919 should be updated to reflect this logic.
Please ensure the chosen behavior is consistent with previous intentional behavior.
References
- When modifying code, ensure that changes are consistent with previous behavior, especially if the previous behavior was intentional.