False positive for rule java:S2479 "Whitespace and control characters in literals should be explicit"

When using SonarLint for Eclipse 5.9.0.31414
with a Java project with Java 15 I get SonarQube issue java:S2479 “Whitespace and control characters in literals should be explicit” on the text block that contains tabs (see also the screenshot at the end of the post):

package example;

public class Example {
	public String m() {
		return """
				public class Example {
					public static void main(String[] args) {
					}
				}
				""";
	}
}

This looks like a false positive (even because the rule description also says “Text Blocks string literals (java 13 three double-quote marks) can contain tabulations to allow indentation using tabulations.”)

Hi Lorenzo,
We will try to improve the rule with this ticket SONARJAVA-3867. Thanks for your feedback.

Great! Though I’m finding the ticket misleading: the rule explicitly says that inside java text blocks the rule should not be applied, while the ticket seems to put the exclusion for java text blocks in doubt. IMHO java text blocks were born for having indentation characters…

I don’t know yet how we will fix the rule (ignoring tabs in text blocks like previously, adding a parameter to allow tabs in text blocks, split the rule in two rules to separate string literals and text blocks, …)
But in any case, the current rule description and the current rule implementation are not aligned, so we will have to fix this, that’s a good point.

I added my comment to the issue itself

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.