[false-negative]S3027 can not detect single unicode character like "\u001B"

Affects Sonarqube Version:
Sonarqube version: 8.1.0.31237
sonar-scanner version: 4.2.0.1873-windows

Rule:
S3027: String function use should be optimized for single characters

Description:
Unable to detect single unicode character like “\u001B”.
This rule is implemented in java-checks-6.2.0.21135-sources.jar!\org\sonar\java\checks\StringMethodsOnSingleCharCheck.java
This rule uses return argValue.length() == 2 && argValue.charAt(0) == ‘\’; to determine whether the string is a single character,
and does not apply to the case of single unicode characters.

Code Sample demonstrating the issue:

int aIndex = addString.indexOf("\u001B");

Expected outcome:
false-negative

Running Sonarqube through:
command line

Hello,

Thanks for taking the time to clearly report this false negative.

I understand that the rule could be improved, however, it is deprecated, it should not be used anymore and therefore it doesn’t make sense to improve it further.

In fact, the whole rule in itself is questionable, there is no strong evidence that what it is claiming is correct. You can find more information in this comment, and this ticket.

Hope this makes sense,
Quentin