# Main Source rules are reported on Test Files

**URL:** <https://community.sonarsource.com/t/main-source-rules-are-reported-on-test-files/117450>\
**Category:** SonarQube Cloud\
**Tags:** maven, java, scanner\
**Created:** [June 18, 2024, 3:34pm UTC](https://community.sonarsource.com/t/main-source-rules-are-reported-on-test-files/117450 "2024-06-18T15:34:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![adambir](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/adambir/32/55704_2.png) [@adambir](https://community.sonarsource.com/u/adambir)\
**Post date:** [June 18, 2024, 3:34pm UTC](https://community.sonarsource.com/t/main-source-rules-are-reported-on-test-files/117450/1 "2024-06-18T15:34:29Z")

</div>

Template for a good new topic, formatted with [Markdown](https://commonmark.org/help/):

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

The rule [java:S1874](https://rules.sonarsource.com/java/RSPEC-5738/?search=1874) 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

 ![Capture d’écran du 2024-06-18 17-27-51](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/5/1/516c86d1afd9a707fd7ac0431c8f7e47c76a1a53.png)  
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 :

```auto
[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 ?

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [June 19, 2024, 6:44am UTC](https://community.sonarsource.com/t/main-source-rules-are-reported-on-test-files/117450/4 "2024-06-19T06:44:55Z")

</div>

It looks like this was [intentional…](https://sonarsource.atlassian.net/browse/SONARJAVA-4940), but I personally lack any context for why _now_, and I don’t remember an announcement about these changes. I’ll ping around.

---

<div class="post-metadata">

**Author:** ![adambir](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/adambir/32/55704_2.png) [@adambir](https://community.sonarsource.com/u/adambir)\
**Post date:** [June 19, 2024, 9:00am UTC](https://community.sonarsource.com/t/main-source-rules-are-reported-on-test-files/117450/6 "2024-06-19T09:00:12Z")

</div>

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](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/0/2/02a13a5af0500b92843d295397d05a526510f282.png)

 ![Capture d’écran du 2024-06-19 10-59-57](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/3/5/351fd6574461eab7676d51244b988587258f0fe0.png)

---

<div class="post-metadata">

**Author:** ![Leonardo\_Pilastri](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/leonardo_pilastri/32/38853_2.png) [@Leonardo\_Pilastri](https://community.sonarsource.com/u/Leonardo_Pilastri)\
**Post date:** [June 19, 2024, 9:08am UTC](https://community.sonarsource.com/t/main-source-rules-are-reported-on-test-files/117450/7 "2024-06-19T09:08:50Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [June 26, 2024, 9:09am UTC](https://community.sonarsource.com/t/main-source-rules-are-reported-on-test-files/117450/9 "2024-06-26T09:09:55Z")

</div>

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