8000 fix(internal/librarian/ruby): format version.rb during rubocop batch by suztomo · Pull Request #8018 · googleapis/librarian · GitHub
[go: up one dir, main page]

Skip to content

fix(internal/librarian/ruby): format version.rb during rubocop batch - #8018

Open
suztomo wants to merge 1 commit into
googleapis:mainfrom
suztomo:fix/ruby-format-version-rb
Open

suztomo wants to merge 1 commit into
googleapis:mainfrom
suztomo:fix/ruby-format-version-rb

Conversation

@suztomo
@suztomo suztomo commented Dec 4, 2026
Copy link
Copy Markdown
Member

Update collectRubyFiles to build its keep set only from library.Keep instead of reusing buildKeepSet, which implicitly adds lib/<gem_path>/version.rb.

Because buildKeepSet includes version.rb to prevent Clean and MoveAndMergeWithKeep from overwriting existing version files, reusing it in Format caused newly generated version.rb files (from #7807) to skip RuboCop formatting and retain a trailing blank line (Layout/TrailingEmptyLines). Paths explicitly configured in library.Keep are still skipped.

Update collectRubyFiles to build its keep set only from library.Keep
instead of reusing buildKeepSet, which implicitly adds the library's
version.rb file.

Because buildKeepSet includes version.rb to prevent Clean and
MoveAndMergeWithKeep from overwriting existing version files, reusing it
in Format caused newly generated version.rb files to skip RuboCop
formatting and retain a trailing blank line (Layout/TrailingEmptyLines).
Explicitly kept paths in library.Keep are still skipped.
@suztomo
suztomo requested a review from a team as a code owner December 4, 2026 21:55
@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 refactors collectRubyFiles in internal/librarian/ruby/format.go to build and normalize the keepSet inline using filepath.ToSlash and filepath.Clean. It also adds a unit test TestCollectRubyFiles_VersionFile to verify the collection behavior of version files. The reviewer noted a style guide violation in the test's error message for cmp.Diff and suggested using the standard format string.

want = []string{versionPath}
}
if diff := cmp.Diff(want, files); diff != "" {
t.Errorf("collectRubyFiles() mismatch (-want +got):\n%s", diff)
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.

medium

According to the Go style guide, the error message format for cmp.Diff should not be modified or customized. Please use the exact format string "mismatch (-want +got):\n%s".

Suggested change
t.Errorf("collectRubyFiles() mismatch (-want +got):\n%s", diff)
t.Errorf("mismatch (-want +got):\n%s", diff)
References
  1. Always compare in want, got order, and use the exact format string 'mismatch (-want +got):\n%s' for the error message (do not modify or customize this format string). (link)
  2. Ensure t.Errorf messages for cmp.Diff follow the project's style guide, specifically using the format t.Errorf("mismatch (-want +got):\n%s", diff) without extra text or colons.

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.

1 participant

0