Some but not all rules are applied to test files in Java

Please provide

  • Operating system: OS X 13.5
  • SonarLint plugin version:
  • Programming language you’re coding in: Java
  • Is connected mode used: No
    • Connected to SonarCloud or SonarQube (and which version):

And a thorough description of the problem / question:

I know that my test files are not excluded as I have no exclusions defined, and because sonarlint reports other issues in this test file, but one specific rule is not being applied (even though it is applied to non test files in the same project in the same working session)

So for example, this line is reported if in src, but not if in a test java file

List<Integer> a = new ArrayList<Integer>();


Welcome to the community!

Unfortunately, there’s a strict segregation between rules that are applied on source code and those that apply to tests. (Yes, I know. You want tests to be high-quality and bug-free too. :slightly_frowning_face:) That’s what you’re running into. If you have normal rules being applied to other test files, then SonarLint is misunderstanding what they are.