diff --git a/core/src/main/java/com/google/errorprone/bugpatterns/UnsafeLocaleUsage.java b/core/src/main/java/com/google/errorprone/bugpatterns/UnsafeLocaleUsage.java index 1746c86ab6f..442f01bab4e 100644 --- a/core/src/main/java/com/google/errorprone/bugpatterns/UnsafeLocaleUsage.java +++ b/core/src/main/java/com/google/errorprone/bugpatterns/UnsafeLocaleUsage.java @@ -84,10 +84,9 @@ public Description matchNewClass(NewClassTree tree, VisitorState state) { String replacementArg = arg instanceof JCLiteral ? String.format( - "\"%s\"", ASTHelpers.constValue(arg, String.class).replace("_", "-")) + "\"%s\"", ASTHelpers.constValue(arg, String.class).replace('_', '-')) : String.format( - "%s.replace(\"_\", \"-\")", - state.getSourceForNode(constructorArguments.get(0))); + "%s.replace('_', '-')", state.getSourceForNode(constructorArguments.get(0))); descriptionBuilder.addFix( SuggestedFix.replace(tree, String.format("Locale.forLanguageTag(%s)", replacementArg))); diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/UnsafeLocaleUsageTest.java b/core/src/test/java/com/google/errorprone/bugpatterns/UnsafeLocaleUsageTest.java index a690f816147..fbcee7a2c31 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/UnsafeLocaleUsageTest.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/UnsafeLocaleUsageTest.java @@ -60,7 +60,7 @@ class Test { static class Inner { private Locale locale; Inner(String a) { - locale = Locale.forLanguageTag(a.replace("_", "-")); + locale = Locale.forLanguageTag(a.replace('_', '-')); } }