Language: Java
Rule: S5665
Why it’s false: I should be able to include a slash character in the string that is followed by a literal quote
Using SonarLint 9.2.0.81471 in Eclipse 4.28.0 (20230608-1333) without connected mode
This java snippet shows TWO instances of a false positive see the embedded “<-” pointing to the cause.
private static final String S5665_FALSE_POSITIVE_DEMO= """
This is a path that sonar lint complains about:(single quote):
'C:\\foo\\bar\\' <- this quote following a slash
Sonar is fine with this without trailing slash 'C:\\foo\\bar'
This is another path sonar lint complains about (double quote):
"\\\\SERVER\\SHARE\\ETC\\" <- this quote following a slash
Sonar is also fine with this one: "\\\\SERVER\\SHARE\\ETC"
But note, the slash is escaping the slash NOT the quote
""";