Exclude function doc strings from external-path and canonical-repository lints#1450
Exclude function doc strings from external-path and canonical-repository lints#1450Silic0nS0ldier wants to merge 3 commits intobazelbuild:mainfrom
external-path and canonical-repository lints#1450Conversation
Summary of ChangesHello @Silic0nS0ldier, 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
Changelog
Activity
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 aims to prevent external-path and canonical-repository lints from firing on function docstrings. The changes include updating the linter logic to recognize docstring contexts and adding corresponding test cases. The documentation for external-path is also improved with more relevant examples.
My main feedback is regarding the implementation of isDocStringContext, which is a bit too broad and could lead to missed lint errors. I've provided a detailed comment with a suggested fix that not only corrects the logic but also extends it to handle file-level docstrings. Overall, this is a valuable improvement, and with the suggested change, it will be even more robust.
There was a problem hiding this comment.
Code Review
This pull request aims to exclude function docstrings from external-path and canonical-repository lints. The approach is to add a new helper isDocStringContext to detect when a string is a docstring and skip the linting. The changes also include updated examples in WARNINGS.md and new tests.
The implementation of isDocStringContext is slightly incorrect as it considers any top-level string in a function as a docstring, not just the first one. I've suggested a fix to make this check more precise. With that change, this PR looks good.
8999876 to
fb68714
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request aims to prevent external-path and canonical-repository lints from firing on function docstrings. The documentation for external-path is also improved with better examples. The core logic for identifying docstrings is a good start, but it's currently too broad and will incorrectly treat any triple-quoted string inside a function as a docstring. My review provides a fix to make this check more precise, ensuring only actual docstrings are ignored by the linter.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request effectively addresses the issue of false positives from external-path and canonical-repository lints within function docstrings. The introduction of the isDocStringContext helper function provides a clean and targeted way to identify function docstrings, ensuring they are correctly excluded from these specific lint checks. The implementation is robust, correctly handling cases where a string is not a docstring (i.e., not the first statement in a function). The accompanying test updates are thorough, covering both the cases that should be ignored and those that should still trigger a warning. Additionally, the update to WARNINGS.md with more illustrative examples for the external-path warning is a valuable improvement to the documentation. The changes are well-implemented and improve the linter's accuracy.
Addresses some feedback in #1386 (comment)
This is not exhaustive, the following are not handled;
Could be simplified to skipping any triple-quote string that is unassigned.
docattributes onrule,macro,repository_rule,attr.___, etc.Or for sake of simplicity, any named argument assignment for
doc.external-pathlint doc has also been updated with examples are more illustrative of what may be found in the wild (srcsanddataare normallylabel_listattributes which are immune to the problemsexternal-pathis trying to guard against).