Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Feb 6, 2024

Conversation

copybara-service[bot]
Copy link
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
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
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