Rollforward of https://github.com/google/error-prone/commit/654d1dbf1e6dd652cd6e8ca003643ddf02266ec2: Handle Joiner.on(...) in AbstractToString.#4233
Merged
Conversation
80f149d to
0331a27
Compare
Not yet handling the Iterable overload; that's a bit more involved given the lack of prior art. Handily there was a 'isInVarargsPosition' _right there_. PiperOrigin-RevId: 604758974
0331a27 to
0bd7432
Compare
ash211
reviewed
Mar 26, 2024
| "class Test {", | ||
| " String test(Joiner j, Object[] a) {", | ||
| " return j.join(a);", | ||
| " }", |
Contributor
There was a problem hiding this comment.
@graememorgan Do you intend to support the Joiner.join overload where the varargs parameter has other fixed parameters before it?
One of the codebases I maintain has this example:
private static String makePath(Namespace namespace, Project project, String... path) {
return "/" + Joiner.on("/").join(namespace.name(), project.name(), (Object[]) path);
}
And it's now erroring with:
error: [ArrayToString] Calling toString on an array does not provide useful information
return "/" + Joiner.on("/").join(namespace.name(), project.name(), (Object[]) path);
^
(see https://errorprone.info/bugpattern/ArrayToString)
Did you mean 'return "/" + Joiner.on("/").join(namespace.name(), project.name(), Arrays.toString((Object[]) path));'?
The suggestion is an unwanted behavior change, because it introduces the array format and causes tests to start failing with:
Expected :"/NamespacePath/ProjectPath/folder1/folder2/folder3"
Actual :"/NamespacePath/ProjectPath/[folder1, folder2, folder3]"
Collaborator
There was a problem hiding this comment.
@ash211 thanks for the comment, there's a fix in progress for that
copybara-service Bot
pushed a commit
that referenced
this pull request
Mar 27, 2024
…er.join(Object, Object, Object...)` #4233 (review) PiperOrigin-RevId: 619367171
copybara-service Bot
pushed a commit
that referenced
this pull request
Mar 27, 2024
…er.join(Object, Object, Object...)` #4233 (review) PiperOrigin-RevId: 619537499
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.
Rollforward of 654d1db: Handle Joiner.on(...) in AbstractToString.
Not yet handling the Iterable overload; that's a bit more involved given the lack of prior art.
Handily there was a 'isInVarargsPosition' right there.