Skip to content

Rollforward of https://github.com/google/error-prone/commit/654d1dbf1e6dd652cd6e8ca003643ddf02266ec2: Handle Joiner.on(...) in AbstractToString.#4233

Merged
copybara-service[bot] merged 1 commit into
masterfrom
test_592550187
Feb 6, 2024
Merged

Conversation

@copybara-service
Copy link
Copy Markdown
Contributor

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.

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
@copybara-service copybara-service Bot merged commit 0bd7432 into master Feb 6, 2024
@copybara-service copybara-service Bot deleted the test_592550187 branch February 6, 2024 22:10
"class Test {",
" String test(Joiner j, Object[] a) {",
" return j.join(a);",
" }",
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.

@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]"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@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
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.

3 participants