Main Source rules are reported on Test Files

Template for a good new topic, formatted with Markdown:

  • ALM used GitHub
  • CI system used Jenkins
  • Languages of the repository Java

The rule java:S1874 is written in Sonarcloud as Analysis Scope : Main sources
I understand that it should only report issues from my production files and not my tests files, right ?

It is, however, reported in my test files, see the screenshot


The full path of this file is etech-central/src/test/java/eTech/ui/AbstractActivityTypeActionTest.java
My scope is defined in maven pom.xml as such :
Main project pom : <sonar.exclusions>**/*.jsp,**/*.html,**/*.xml,**/*.css</sonar.exclusions>
Module pom : No definition of analysis scope

Here’s the logs in my Jenkins build :

[INFO] 12:02:57.114 Indexing files...
[INFO] 12:02:57.115 Project configuration:
[INFO] 12:02:57.115   Excluded sources: **/build-wrapper-dump.json, **/*.jsp, **/*.html, **/*.xml, **/*.css

...

[INFO] 12:02:57.270 Indexing files of module 'etech-central'
[INFO] 12:02:57.270   Base dir: /home/****/workspace/ETECH_eTech_main/etech-central
[INFO] 12:02:57.271   Source paths: pom.xml, src/main/java
[INFO] 12:02:57.271   Test paths: src/test/java
[INFO] 12:02:57.271   Excluded sources: **/build-wrapper-dump.json, **/*.jsp, **/*.html, **/*.xml, **/*.css

Am I just misunderstanding how the rules analysis scope is designed ? Should I update something on my setup ? Or is there some kind of bug ?

1 Like

It looks like this was intentional…, but I personally lack any context for why now, and I don’t remember an announcement about these changes. I’ll ping around.

Thank you. This is a choice that can make sense, but the rule is not reported as Main and Test sources in Sonarcloud. This is not consistent with other rules. Examples below :
Capture d’écran du 2024-06-19 10-57-46

Hi Adam,
We recently noticed that many rules metadata (what you see on Sonarcloud) were not synchronized with the actual implementation scope. We currently have an ongoing effort to fix this so that all Java rules’ scopes reflect the actual implementation scope.

It should be rolled out pretty soon!

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.