Skip to content

Commit 0ffdad5

Browse files
committed
Added check for empty iterables
1 parent 679c4ac commit 0ffdad5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

core/src/main/java/com/google/errorprone/bugpatterns/StringConcatToTextBlock.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ && isSameType(getType(parent), state.getSymtab().stringType, state)) {
9898
.filter(t -> t.kind().equals(Tokens.TokenKind.STRINGLITERAL))
9999
.map(t -> t.stringVal())
100100
.collect(toImmutableList());
101-
boolean trailingNewline = getLast(strings).endsWith("\n");
101+
boolean trailingNewline = !strings.isEmpty() && getLast(strings) != null && getLast(strings).endsWith("\n");
102102
// Only migrate if there are enough lines to make it worthwhile. Escaping the trailing newline
103103
// slightly reduces the readability benefit of migrating, so require an extra line to make it
104104
// worth it.

0 commit comments

Comments
 (0)