Repository navigation
Conversation
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.
Contributor
There was a problem hiding this comment.
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) |
Contributor
There was a problem hiding this comment.
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
- 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)
- Ensure
t.Errorfmessages forcmp.Difffollow the project's style guide, specifically using the formatt.Errorf("mismatch (-want +got):\n%s", diff)without extra text or colons.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Update
collectRubyFilesto build its keep set only fromlibrary.Keepinstead of reusingbuildKeepSet, which implicitly addslib/<gem_path>/version.rb.Because
buildKeepSetincludesversion.rbto preventCleanandMoveAndMergeWithKeepfrom overwriting existing version files, reusing it inFormatcaused newly generatedversion.rbfiles (from #7807) to skip RuboCop formatting and retain a trailing blank line (Layout/TrailingEmptyLines). Paths explicitly configured inlibrary.Keepare still skipped.