Skip to content

Commit

Permalink
SONARJAVA-4752 FP in S5665 when \\" and \\' are not intended to be es…
Browse files Browse the repository at this point in the history
…caped (#4691)
  • Loading branch information
kaufco committed Feb 27, 2024
1 parent 4f14679 commit 92c7e18
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,62 @@ public void str() {
What's the point, really
"""; // Compliant

String question8 = """
"What's the point, really
?"""; // Compliant

String question9 = """
\\"What's the point, really
?"""; // Compliant

String question10 = """
\\\"What's the point, really
?"""; // Noncompliant@-1

String question11 = """
\\\\"What's the point, really
?"""; // Compliant

String question12 = """
\\\\\"What's the point, really
?"""; // Noncompliant@-1

String question13 = """
\\"\"\"What's the point, really
?"""; // Noncompliant@-1 {{Remove this unnecessary escape sequence.}}

String question14 = """
\\"\\"\"What's the point, really
?"""; // Noncompliant@-1 {{Remove this unnecessary escape sequence.}}

String question15 = """
\\"\\"\\"What's the point, really
?"""; // Compliant

String question16 = """
\\"\\\"\\"What's the point, really
?"""; // Noncompliant@-1 {{Remove this unnecessary escape sequence.}}

String question17 = """
\\\\\\\\'What's the point, really\\\\\\\\'
?"""; // Compliant

String question19 = """
\\\\\\\\\'What's the point, really\\\\\\\\\'
?"""; // Noncompliant@-1 {{Remove this unnecessary escape sequence.}}

String question20 = """
What's
the
point,
really\\n?"""; // Compliant

String notEscapedDoubleQuote = """
"\\\\\\\\SERVER\\\\SHARE\\\\ETC\\\\"
"""; // Compliant

String notEscapedSingleQuote = """
'C:\\\\foo\\\\bar\\\\'
"""; // Compliant
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public void visitNode(Tree tree) {
String[] lines = value.split("\r?\n|\r");

for (int i = 0; i < lines.length; ++i) {
lines[i] = lines[i].replace("\\\\","");
if (lines[i].contains("\\\"\\\"\\\"")) {
addIssue(startLine + i, TRIPLE_QUOTE_MESSAGE);
} else {
Expand Down

0 comments on commit 92c7e18

Please sign in to comment.