Please provide
- Operating system: Windows 10
- IDE name and flavor/env: Eclipse 4.23
- SonarLint plugin version: 7.4.0.46482
- Is connected mode used: No
- Connected to SonarCloud or SonarQube (and which version):
And a thorough description of the problem / question:
Error reported:
public static String quoteIfSpaces(final String str) {
if (indexOf(str, ' ') != -1) {
return quoted(str, '"'); //<-- error here
}
return str;
}
public static int indexOf(final String inStr, final char del) {
if (inStr != null) {
return inStr.indexOf(del);
}
return -1;
}
and the reported info:
It can easily be seen that if null is passed as str, indexOf will return -1, in which case quoted will never be called.