Skip to content

Commit 94275bf

Browse files
cushonronshapiro
authored andcommitted
Remove a branch that is never taken
Fixes https://github.com/google/google-java-format/pull/337/files ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=244289776
1 parent aee9cd8 commit 94275bf

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

core/src/main/java/com/google/googlejavaformat/java/RemoveUnusedImports.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ private static RangeMap<Integer, String> buildReplacements(
272272
endPosition = Math.max(CharMatcher.isNot(' ').indexIn(contents, endPosition), endPosition);
273273
String sep = Newlines.guessLineSeparator(contents);
274274
if (endPosition + sep.length() < contents.length()
275-
&& contents.subSequence(endPosition, endPosition + sep.length()).equals(sep)) {
275+
&& contents.subSequence(endPosition, endPosition + sep.length()).toString().equals(sep)) {
276276
endPosition += sep.length();
277277
}
278278
replacements.put(Range.closedOpen(importTree.getStartPosition(), endPosition), "");
@@ -304,9 +304,7 @@ private static boolean isUnused(
304304
JCImport importTree,
305305
String simpleName) {
306306
String qualifier =
307-
importTree.getQualifiedIdentifier() instanceof JCFieldAccess
308-
? ((JCFieldAccess) importTree.getQualifiedIdentifier()).getExpression().toString()
309-
: null;
307+
((JCFieldAccess) importTree.getQualifiedIdentifier()).getExpression().toString();
310308
if (qualifier.equals("java.lang")) {
311309
return true;
312310
}

0 commit comments

Comments
 (0)