Affects PMD Version: 6.14.0
Rule: SimplifyStartsWith
Description: pmd reports that expression can be simplified, but if string is empty, "simplified" code produces StringIndexOutOfBoundsException
Code Sample demonstrating the issue:
public class Example {
public static void main(String[] args) {
System.out.println(checkStringStartsFrom(""));
System.out.println(checkStringCharAt(""));
}
private static boolean checkStringStartsFrom(String string) {
return string.startsWith("*");
}
private static boolean checkStringCharAt(String string) {
return string.charAt(0) == '*';
}
}
Running PMD through: Maven
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4