Skip to content

Commit 9f24cce

Browse files
SONARJAVA-6212 Document and rename sonarRules property for ruling tests (#5534)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 91519e8 commit 9f24cce

3 files changed

Lines changed: 29 additions & 5 deletions

File tree

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,18 @@ Failing to do so will produce inconsistencies with the expected results.
120120

121121
From the `its/ruling` folder, launch the ruling tests:
122122

123-
mvn clean install -Pit-ruling -DcommunityEditionTestsOnly=true
123+
mvn clean install -Pit-ruling -DcommunityEditionTestsOnly=true
124124
# Alternatively
125125
JAVA_HOME=/my/local/java21/jdk/ mvn clean install -Pit-ruling -DcommunityEditionTestsOnly=true
126126

127-
Note for internal contributors: in order to also execute the tests that depend on the SonarQube Server Enterprise Edition, use:
127+
Note for internal contributors: in order to also execute the tests that depend on the SonarQube Server Enterprise Edition, use:
128128

129129
mvn clean install -Pit-ruling
130130

131+
To run the ruling tests for only a subset of rules, use the `sonarRules` property with a comma-separated list of rule keys:
132+
133+
mvn clean install -Pit-ruling -DsonarRules=S100,S101
134+
131135
This test gives you the opportunity to examine the issues created by each rule and make sure they're what you expect. Any implemented rule is highly likely to raise issues on the multiple projects we use as ruling code base.
132136

133137
* For a newly implemented rule, it means that a first build will most probably fail, caused by differences between expected results (without any values for the new rule) and the new results. You can inspect these new issues by searching for files named after your rule (`squid-SXXXX.json`) in the following folder:

its/ruling/pom.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,20 @@
114114
</plugins>
115115
</build>
116116
</profile>
117+
<profile>
118+
<id>only-jboss-project</id>
119+
<build>
120+
<plugins>
121+
<plugin>
122+
<groupId>org.apache.maven.plugins</groupId>
123+
<artifactId>maven-surefire-plugin</artifactId>
124+
<configuration>
125+
<test>org.sonar.java.it.JavaRulingTest#jboss_ejb3_tutorial</test>
126+
</configuration>
127+
</plugin>
128+
</plugins>
129+
</build>
130+
</profile>
117131
<profile>
118132
<id>only-sonarqube-project</id>
119133
<build>

its/ruling/src/test/java/org/sonar/java/it/JavaRulingTest.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,17 @@ public class JavaRulingTest {
7171
private static final String INCREMENTAL_ANALYSIS_KEY = "sonar.java.skipUnchanged";
7272
private static final String SONAR_CACHING_ENABLED_KEY = "sonar.analysisCache.enabled";
7373

74-
// by default all rules are enabled, if you want to enable just a subset of rules you can specify the list of
75-
// rule keys from the command line using "rules" property, i.e. mvn test -Drules=S100,S101
74+
/**
75+
* By default, all rules are enabled.
76+
* If you want to enable just a subset of rules, you can specify the list of rule keys from the command line
77+
* using the "sonarRules" property, i.e.
78+
* <pre>{@code
79+
* mvn test -DsonarRules=S100,S101
80+
* }</pre>
81+
*/
7682
private static final ImmutableSet<String> SUBSET_OF_ENABLED_RULES = ImmutableSet.copyOf(
7783
Splitter.on(',').trimResults().omitEmptyStrings().splitToList(
78-
System.getProperty("rules", "")
84+
System.getProperty("sonarRules", "")
7985
)
8086
);
8187

0 commit comments

Comments
 (0)