Skip to content

fix: make Batch naming resource plural aware#1573

Merged
noahdietz merged 8 commits into
googleapis:mainfrom
noahdietz:batch-plural-methods
Dec 1, 2025
Merged

fix: make Batch naming resource plural aware#1573
noahdietz merged 8 commits into
googleapis:mainfrom
noahdietz:batch-plural-methods

Conversation

@noahdietz

Copy link
Copy Markdown
Contributor

Centralizes "plural method naming" check for collection-based methods, explicitly Batch methods e.g. AIP-231, into a common lint. Makes that common lint "resource aware" in that it checks if the resource in the response (if present) has the AIP-123 plural property set, then bases its method plural naming check on that value instead of the pluralize library.

Adds a bunch of test cases to each rule and the new common lint method.

Note: BatchDelete is not covered in the updated heuristics b.c the response is typically google.protobuf.Empty and the only reference to the resource being deleted is the resource_reference on the request message field repeated names. This should be updated later, but it is not urgent.

Updates #1566

@noahdietz
noahdietz requested review from a team and quirogas November 25, 2025 19:50
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @noahdietz, 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 significantly refactors the linting logic for "Batch" methods (e.g., BatchGet, BatchCreate, BatchUpdate, BatchDelete) to ensure their names correctly reflect plural resources. By centralizing the pluralization check into a new common utility function, the linter can now intelligently determine the correct plural form by first consulting the plural property defined in google.api.resource annotations. This enhancement provides more precise and context-aware validation for API method naming conventions, improving consistency across the API surface.

Highlights

  • Centralized Plural Method Naming Check: The logic for checking plural method names in collection-based methods (e.g., BatchGet, BatchCreate) has been centralized into a common utility function.
  • Resource-Aware Pluralization: The common lint now intelligently determines the correct plural form by first checking the plural property defined in google.api.resource annotations within the response message, providing more accurate validation.
  • Expanded Test Coverage: New test cases have been added across various rules and the new common lint method to ensure comprehensive validation of plural method naming, including scenarios with resource-aware pluralization and non-message response items.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a great improvement, centralizing the plural method naming check into a common, resource-aware lint function. This refactoring enhances maintainability and correctness by using the plural property from resource definitions. The addition of comprehensive test cases is also a valuable contribution. I have a couple of suggestions for the new LintPluralMethodName function to further improve readability and performance.

Comment thread rules/internal/utils/common_lints.go Outdated
Comment thread rules/internal/utils/common_lints.go Outdated
noahdietz and others added 4 commits November 25, 2025 11:58
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@noahdietz

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a great improvement. It centralizes the logic for checking plural method names for batch operations into a new, resource-aware utility function LintPluralMethodName. This refactoring significantly reduces code duplication and enhances the linter's accuracy by leveraging resource definitions when available. The accompanying test updates are thorough and cover the new functionality well. I've identified one potential high-severity issue in the new utility function that could lead to a panic, for which I've provided a suggestion.

Comment thread rules/internal/utils/common_lints.go Outdated
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@noahdietz

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a great improvement. It centralizes the logic for checking plural method names for batch operations into a new utility function, utils.LintPluralMethodName. This new function is also resource-aware, prioritizing the plural field from the resource definition (AIP-123) when available, which improves the linter's accuracy. The refactoring is applied consistently across all relevant batch method rules (AIP-231, 233, 234, 235), and the changes are well-supported by new and updated tests. The code quality is high, and I have only one minor suggestion.

Comment thread rules/internal/utils/common_lints.go Outdated
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@noahdietz
noahdietz enabled auto-merge (squash) December 1, 2025 17:29
@noahdietz
noahdietz merged commit c820a1c into googleapis:main Dec 1, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants