Sonarlint running locally does not catch parent pom.xml rule exclusion

Hi @NathanEckert

SonarLint and SonarCloud analysis configurations follow a different approach. SonarCloud uses one of the SonarScanners (here I guess you are using the scanner for Maven). The scanner for Maven will try to infer your project structure from the Maven model. For special cases like yours, you can override the scanner behavior using properties sonar.sources and sonar.tests.

SonarLint on its side relies on IDE metadata. IDEs like IntelliJ already have their own way to “understand” Maven project structure, and deciding what is test and what is production code.

Basically, SonarLint will respect what you see in the IDEA project structure:

We think SonarLint behavior should be consistent with what you see in your IDE (green folder = test, blue folder = main code).

So one simple way to fix your problem is to let IntelliJ know that the folder src is a test folder, by manually changing the folder type in the project structure.

In the long run, it might be better to also let Maven knows, and declare that your src folder is a test folder, using something like:

  <build>
    <testSourceDirectory>${basedir}/src</testSourceDirectory>
  </build>

This way, when Intellij will import your project, it will automatically know that src is a test folder. And it should also automatically be picked by the scanner for Maven.

But this might be a bit tricky, since I guess your tck is a kind of reusable test library, so you want tests to be packaged. You can try to follow this Maven guide.