Rule not working correctly?

Hello I have setup and been using for some time the following:

  • SonarQube Server Developer Edition v2025.1.3
  • It is deployed as a zip

I’m trying to figure out why this rule doesn’t seem to be working correctly: Remove the non-escaped \u0009 character from this literal Rule ID:java:S2479

The rule has a property to allowTabsInTextBlocks which I’ve set to true but scans still pickup tabs, why?

Then I found somewhere else that this rule is getting deprecated or already has?

I’m a bit confused on how to proceed, any help is appreciated.

Thanks,

Lampros

Hi Lampros,

Can you provide a reproducer text block with a unicode tab where an issue is raised by this rule?

 
Thx,
Ann

Hi Ann,

Sure, here’s an example of one:

" FROM test.sysTest \n"

With an error of: Remove the non-escaped \u0009 character from this literal.

Please let me know if you need anything else.

Thanks,

Lampros

Hi Lampros,

I’m feeling a bit slow; I don’t see a unicode tab in that…?

 
Ann

Hi Ann,

My issue is the same as this one: https://community.sonarsource.com/t/how-to-get-rid-of-thousands-of-false-positives-for-java-21-remove-the-non-escaped-char-from-literal/136461/7

And I did notice that one of your colleagues mentioned:

To address the issue, you have two options: you can either deactivate the rule as Ann suggested, or adjust the parameter for rule S2479 to allow tabs within text blocks. For both, you need administrator right. I hope one of these solutions helps reduce the noise for you.

I am the full admin on our SonarQube instance and even though I use the `allowTabsInTextBlocks` attribute it still shows up as a finding.

Any ideas?

-Lampros

Hi Lampros,

Could I have a screenshot of the issue? Because the reproducer you’ve provided, in addition to apparently not containing \u0009, isn’t a “text block”, which could explain why the rule exception isn’t kicking in for you.

 
Ann

Hi Ann,

No problem, here’s a screenshot of it:

It’s a SQL query inside double quotes.

Hope that helps.

-Lampros

Hi Lampros,

Thanks for for the screenshot; it solves the mystery. You’ve enabled the parameter to “allow tabs in text blocks” but the issue is not being raised on a text block. It’s being raised on a plain, vanilla string. As I alluded earlier, text blocks are delineated by triple quotes (""").

 
HTH,
Ann

Morning Ann,

Okay thank you that helps me understand the why. We are limited to Java 8 so text blocks would be something that we couldn’t use/migrate to even if we wanted to right now.

So my only other alternative would be to turn off the rule? Or is there a way to customize it further than the one boolean field?

Thanks,

Lampros

Hi Lampros,

Why does the tab need to be inside the string? Why can you not just indent the string to where you want the 'FROM` to be?

 
Ann

Hi Ann,

Unfortunately I’m scanning code written by developers that had to use a SQL client/editor to write what they wanted and then they would copy paste it into Eclipse IDE which would handle tabs, space, etc. by doing what you see above.

Yes we could do what you suggested, I agree 100% and we might move to something like that for any future work. But to satisfy my curiosity, are there ways to customize such rules?

-Lampros

Hi Lampros,

You’ve already plumbed the depths of configuration for this rule. Your best option is probably to disable it.

 
HTH,
Ann

Hi Ann,

Thank you, have a great day.

-Lampros