]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-11850 Don't warn user if properties are inherited
authorJulien HENRY <julien.henry@sonarsource.com>
Wed, 19 Jun 2019 08:49:24 +0000 (10:49 +0200)
committersonartech <sonartech@sonarsource.com>
Fri, 28 Jun 2019 06:45:50 +0000 (08:45 +0200)
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorBuilder.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/issues/IssuesMediumTest.java

index 6b4b9a7967716ce169b5d8cd723f48796aade49a..01f181d55f05c8e90e1971d0312650bd4f52b762 100644 (file)
@@ -31,6 +31,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Objects;
 import java.util.stream.Stream;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
@@ -182,7 +183,7 @@ public class ProjectReactorBuilder {
       workDir = initRootProjectWorkDir(baseDir, moduleProperties);
     } else {
       workDir = initModuleWorkDir(baseDir, moduleProperties);
-      checkUnsupportedIssueExclusions(moduleProperties);
+      checkUnsupportedIssueExclusions(moduleProperties, parent.properties());
     }
 
     return ProjectDefinition.create().setProperties(moduleProperties)
@@ -191,9 +192,9 @@ public class ProjectReactorBuilder {
       .setBuildDir(initModuleBuildDir(baseDir, moduleProperties));
   }
 
-  private void checkUnsupportedIssueExclusions(Map<String, String> moduleProperties) {
+  private void checkUnsupportedIssueExclusions(Map<String, String> moduleProperties, Map<String, String> parentProps) {
     UNSUPPORTED_PROPS_FOR_MODULES.stream().forEach(p -> {
-      if (moduleProperties.containsKey(p)) {
+      if (moduleProperties.containsKey(p) && !Objects.equals(moduleProperties.get(p), parentProps.get(p))) {
         warnOnceUnsupportedIssueExclusions(
           "Specifying issue exclusions at module level is not supported anymore. Configure the property '" + p + "' and any other issue exclusions at project level.");
       }
index 3fd82bf4afb7d2ee35256a2f369a95190b14b3d3..683773b6e94eca3ea874e0feda3be348b47a74f0 100644 (file)
@@ -285,6 +285,27 @@ public class IssuesMediumTest {
 
     issues = result.issuesFor(result.inputFile("moduleB/src/sampleB.xoo"));
     assertThat(issues).hasSize(10);
+
+
+    // SONAR-11850 The Maven scanner replicates properties defined on the root module to all modules
+    logTester.clear();
+    result = tester.newAnalysis()
+      .properties(ImmutableMap.<String, String>builder()
+        .put("sonar.projectBaseDir", baseDir.getAbsolutePath())
+        .put("sonar.projectKey", "com.foo.project")
+        .put("sonar.modules", "moduleA,moduleB")
+        .put("sonar.sources", "src")
+        .put("sonar.scm.disabled", "true")
+        .put("sonar.issue.ignore.multicriteria", "1")
+        .put("sonar.issue.ignore.multicriteria.1.ruleKey", "*")
+        .put("sonar.issue.ignore.multicriteria.1.resourceKey", "*")
+        .put("moduleA.sonar.issue.ignore.multicriteria", "1")
+        .put("moduleA.sonar.issue.ignore.multicriteria.1.ruleKey", "*")
+        .put("moduleA.sonar.issue.ignore.multicriteria.1.resourceKey", "*")
+        .build())
+      .execute();
+
+    assertThat(logTester.logs(LoggerLevel.WARN)).isEmpty();
   }
 
   @Test