SonarLint - Plugin for IntelliJ

Hi there,

I’m using SonarLint-Plugin for Intellij, and I’m wondering why SonarLint is not analyzing the code of my test-classes when triggering the inspection by “Analyze with SonarLint” context-menu.

when i rename the folder from ‘test’ to e.g.‘abc’ the inspection works.

Is this a normal behaviour and is there a way to configure this?

Thanks in advance

Best Regards


Hi Klaus,

When you say that test classes are not being analyzed, is it because you see them being excluded from the analysis in the logs or simply because no issue is being created for them?
There are many rules that don’t apply to test sources. So if a file is classified by IntelliJ as a test file, those rules won’t run for that file.
To check if this is the case, you can:

  • Check SonarLint logs with debug enabled, and see if the file is being excluded from the analysis (it shouldn’t)
  • Check in IntelliJ’s Project Structure if the folder in question changes to a test resource when you rename it.

Hi Duarte,

thank you for your message!

Ok - in the ‘log’-tab of the SonarLint-Section in IntelliJ there are info-loggings like:
Found 0 issues

So i guess it is indeed analyzed but many rules (e.g. ‘remove unused imports’ do not apply for Test-classes) do not apply.

Is there a list of rules that apply for test-classes. Is there any way to configure which rules are applied to test-classes. Or other way round: is there a way to configure, which classes are categorized as test-classes by SonarLint-Plugin?

Do you know, how to turn on debug-logging for SonarLint-Plugin in IntelliJ?.


Best Regards Klaus

It’s not possible to configure which rules apply to test classes.
In SonarLint you can’t see whether a rule applies to test classes or not. However you can find that information here or in SonarQube (when opening the details of a rule).

The classification of the source code is done by IntelliJ, based on your project structure.
You can find this information under the menu File -> Project Structure.

Thanks for your reply!