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

false positive in OrphanedFormatString check #1021

Closed
msridhar opened this issue May 4, 2018 · 1 comment
Closed

false positive in OrphanedFormatString check #1021

msridhar opened this issue May 4, 2018 · 1 comment

Comments

@msridhar
Copy link
Contributor

msridhar commented May 4, 2018

What version of Error Prone are you using?

Latest master

Does this issue reproduce with the latest release?

Yes

What did you do?

import java.util.Locale;
class OrphanedTest {
  public static void main(String[] args) {
    StringBuilder b = new StringBuilder().append("Hello ").append("%s");
    String formatted = String.format(Locale.getDefault(), b.toString(), "world");
    System.out.println(formatted);
  }
}

What did you expect to see?

No warning

What did you see instead?

OrphanedTest.java:4: warning: [OrphanedFormatString] String literal contains format specifiers, but is not passed to a format method
    StringBuilder b = new StringBuilder().append("Hello ").append("%s");
                                                                  ^
    (see http://errorprone.info/bugpattern/OrphanedFormatString)
1 warning
@awturner
Copy link
Contributor

awturner commented Sep 4, 2018

Thanks for the report.

This will be fixed in the next release. The check on StringBuilder.append has been tightened to only consider invocations which pass parameters (i.e. append(String, int, int) and append(char[], int, int)).

@ronshapiro ronshapiro mentioned this issue Sep 12, 2018
ronshapiro pushed a commit that referenced this issue Sep 12, 2018
…or if the append(CharSequence, int, int) or append(char[], int, int) overloads are invoked.

RELNOTES: OrphanedFormatString: only consider StringBuilder.append a likely error for some overloads (#1021)

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=211491078
cushon pushed a commit that referenced this issue Sep 13, 2018
if the append(CharSequence, int, int) or append(char[], int, int)
overloads are invoked.

RELNOTES: OrphanedFormatString: only consider StringBuilder.append a
likely error for some overloads
(#1021)

MOE_MIGRATED_REVID=211491078
@cushon cushon closed this as completed Jan 19, 2021
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

No branches or pull requests

3 participants