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

**URL:** <https://community.sonarsource.com/t/false-negative-s3027-can-not-detect-single-unicode-character-like-u001b/26050>\
**Category:** SonarQube Server / Community Build\
**Tags:** java\
**Created:** [June 9, 2020, 2:04am UTC](https://community.sonarsource.com/t/false-negative-s3027-can-not-detect-single-unicode-character-like-u001b/26050 "2020-06-09T02:04:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wongwuchiu](https://avatars.discourse-cdn.com/v4/letter/w/6bbea6/32.png) [@wongwuchiu](https://community.sonarsource.com/u/wongwuchiu)\
**Post date:** [June 9, 2020, 2:04am UTC](https://community.sonarsource.com/t/false-negative-s3027-can-not-detect-single-unicode-character-like-u001b/26050/1 "2020-06-09T02:04:54Z")

</div>

**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:**

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

```

**Expected outcome:**  
false-negative

**Running Sonarqube through:**  
command line

---

<div class="post-metadata">

**Author:** ![Quentin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/quentin/32/74716_2.png) [@Quentin](https://community.sonarsource.com/u/Quentin)\
**Post date:** [June 9, 2020, 2:49pm UTC](https://community.sonarsource.com/t/false-negative-s3027-can-not-detect-single-unicode-character-like-u001b/26050/2 "2020-06-09T14:49:33Z")

</div>

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](https://jira.sonarsource.com/browse/RSPEC-3027?focusedCommentId=237695&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-237695), and this [ticket](https://jira.sonarsource.com/browse/SONARJAVA-3339).

Hope this makes sense,  
Quentin
