diff options
author | Daniel Schwarz <daniel.schwarz@sonarsource.com> | 2017-10-13 14:16:52 +0200 |
---|---|---|
committer | Daniel Schwarz <bartfastiel@users.noreply.github.com> | 2017-10-17 11:24:42 +0200 |
commit | 6b73162dfd76a608eec0805214c0cf0032e37d0b (patch) | |
tree | f13013af3cb8f897a6bfbd0c9ae6f58d4393f1fb | |
parent | fe9ff67136c4a170f70350f7d1a7c48632966143 (diff) | |
download | sonarqube-6b73162dfd76a608eec0805214c0cf0032e37d0b.tar.gz sonarqube-6b73162dfd76a608eec0805214c0cf0032e37d0b.zip |
SONAR-9931 warn if sonar.cpd.cross_project is used in the compute engine
2 files changed, 13 insertions, 0 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/duplication/IntegrateCrossProjectDuplications.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/duplication/IntegrateCrossProjectDuplications.java index dde79aa7c16..85d6b5602c3 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/duplication/IntegrateCrossProjectDuplications.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/duplication/IntegrateCrossProjectDuplications.java @@ -27,6 +27,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import javax.annotation.Nonnull; +import org.sonar.api.CoreProperties; import org.sonar.api.config.Configuration; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; @@ -60,6 +61,9 @@ public class IntegrateCrossProjectDuplications { public IntegrateCrossProjectDuplications(Configuration config, DuplicationRepository duplicationRepository) { this.config = config; this.duplicationRepository = duplicationRepository; + if (config.getBoolean(CoreProperties.CPD_CROSS_PROJECT).orElse(false)) { + LOGGER.warn("This analysis uses the deprecated cross-project duplication feature."); + } } public void computeCpd(Component component, Collection<Block> originBlocks, Collection<Block> duplicationBlocks) { diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/duplication/IntegrateCrossProjectDuplicationsTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/duplication/IntegrateCrossProjectDuplicationsTest.java index 11e998b817a..dcb59e8d107 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/duplication/IntegrateCrossProjectDuplicationsTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/duplication/IntegrateCrossProjectDuplicationsTest.java @@ -332,6 +332,15 @@ public class IntegrateCrossProjectDuplicationsTest { assertThat(logTester.logs(LoggerLevel.WARN)).containsOnly("Too many duplication groups on file " + ORIGIN_FILE_KEY + ". Keeping only the first 100 groups."); } + @Test + public void log_warning_if_this_deprecated_feature_is_enabled() { + settings.setProperty("sonar.cpd.cross_project", "true"); + + new IntegrateCrossProjectDuplications(settings.asConfig(), duplicationRepository); + + assertThat(logTester.logs()).containsExactly("This analysis uses the deprecated cross-project duplication feature."); + } + private static Duplication crossProjectDuplication(TextBlock original, String otherFileKey, TextBlock duplicate) { return new Duplication(original, Arrays.<Duplicate>asList(new CrossProjectDuplicate(otherFileKey, duplicate))); } |