aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2016-08-29 15:34:48 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2016-08-29 15:34:48 +0200
commit0fa7bac665d9c3a29af5db01a445e71d7af23ca5 (patch)
tree52449fad607ae5799033994cb262608c83282cd4 /sonar-scanner-engine
parent971c84d19547548ca70251d6131018ed0d083179 (diff)
downloadsonarqube-0fa7bac665d9c3a29af5db01a445e71d7af23ca5.tar.gz
sonarqube-0fa7bac665d9c3a29af5db01a445e71d7af23ca5.zip
SONAR-5813 Fully drop support of "sonar.cpd.xxx.skip" properties
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/deprecated/DeprecatedCpdBlockIndexerSensor.java28
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd/deprecated/DeprecatedCpdBlockIndexerSensorTest.java27
2 files changed, 2 insertions, 53 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/deprecated/DeprecatedCpdBlockIndexerSensor.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/deprecated/DeprecatedCpdBlockIndexerSensor.java
index 1d66024c21c..c2af38c5875 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/deprecated/DeprecatedCpdBlockIndexerSensor.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/deprecated/DeprecatedCpdBlockIndexerSensor.java
@@ -22,14 +22,12 @@ package org.sonar.scanner.cpd.deprecated;
import com.google.common.annotations.VisibleForTesting;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonar.api.CoreProperties;
import org.sonar.api.batch.CpdMapping;
import org.sonar.api.batch.Phase;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.sensor.Sensor;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.batch.sensor.SensorDescriptor;
-import org.sonar.api.config.Settings;
/**
* Feed block index using deprecated {@link CpdMapping} extension point if not already
@@ -44,13 +42,11 @@ public class DeprecatedCpdBlockIndexerSensor implements Sensor {
private CpdBlockIndexer javaCpdBlockIndexer;
private CpdBlockIndexer defaultCpdBlockIndexer;
- private Settings settings;
private FileSystem fs;
- public DeprecatedCpdBlockIndexerSensor(JavaCpdBlockIndexer javaCpdBlockIndexer, DefaultCpdBlockIndexer defaultCpdBlockIndexer, Settings settings, FileSystem fs) {
+ public DeprecatedCpdBlockIndexerSensor(JavaCpdBlockIndexer javaCpdBlockIndexer, DefaultCpdBlockIndexer defaultCpdBlockIndexer, FileSystem fs) {
this.javaCpdBlockIndexer = javaCpdBlockIndexer;
this.defaultCpdBlockIndexer = defaultCpdBlockIndexer;
- this.settings = settings;
this.fs = fs;
}
@@ -67,32 +63,10 @@ public class DeprecatedCpdBlockIndexerSensor implements Sensor {
return defaultCpdBlockIndexer;
}
- @VisibleForTesting
- boolean isSkipped(String language) {
- String key = "sonar.cpd." + language + ".skip";
- if (settings.hasKey(key)) {
- return settings.getBoolean(key);
- }
- return settings.getBoolean(CoreProperties.CPD_SKIP_PROPERTY);
- }
-
@Override
public void execute(SensorContext context) {
- if (settings.hasKey(CoreProperties.CPD_SKIP_PROPERTY)) {
- LOG.warn("\"sonar.cpd.skip\" property is deprecated and will be removed. Please set \"sonar.cpd.exclusions=**\" instead to disable duplication mechanism.");
- }
for (String language : fs.languages()) {
- if (settings.hasKey("sonar.cpd." + language + ".skip")) {
- LOG
- .warn("\"sonar.cpd." + language + ".skip\" property is deprecated and will be removed. Please set \"sonar.cpd.exclusions=**\" instead to disable duplication mechanism.");
- }
-
- if (isSkipped(language)) {
- LOG.info("Detection of duplicated code is skipped for {}", language);
- continue;
- }
-
CpdBlockIndexer blockIndexer = getBlockIndexer(language);
if (!blockIndexer.isLanguageSupported(language)) {
LOG.debug("Detection of duplicated code is not supported for {}", language);
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd/deprecated/DeprecatedCpdBlockIndexerSensorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd/deprecated/DeprecatedCpdBlockIndexerSensorTest.java
index 092a3499c10..a8c734eeba3 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd/deprecated/DeprecatedCpdBlockIndexerSensorTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd/deprecated/DeprecatedCpdBlockIndexerSensorTest.java
@@ -25,10 +25,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.sonar.api.batch.fs.internal.DefaultFileSystem;
-import org.sonar.api.config.PropertyDefinitions;
-import org.sonar.api.config.Settings;
import org.sonar.scanner.FakeJava;
-import org.sonar.scanner.cpd.CpdComponents;
import static org.assertj.core.api.Assertions.assertThat;
@@ -40,36 +37,14 @@ public class DeprecatedCpdBlockIndexerSensorTest {
JavaCpdBlockIndexer sonarEngine;
DefaultCpdBlockIndexer sonarBridgeEngine;
DeprecatedCpdBlockIndexerSensor sensor;
- Settings settings;
@Before
public void setUp() throws IOException {
sonarEngine = new JavaCpdBlockIndexer(null, null, null);
sonarBridgeEngine = new DefaultCpdBlockIndexer(new CpdMappings(), null, null, null);
- settings = new Settings(new PropertyDefinitions(CpdComponents.class));
DefaultFileSystem fs = new DefaultFileSystem(temp.newFolder().toPath());
- sensor = new DeprecatedCpdBlockIndexerSensor(sonarEngine, sonarBridgeEngine, settings, fs);
- }
-
- @Test
- public void test_global_skip() {
- settings.setProperty("sonar.cpd.skip", true);
- assertThat(sensor.isSkipped(FakeJava.KEY)).isTrue();
- }
-
- @Test
- public void should_not_skip_by_default() {
- assertThat(sensor.isSkipped(FakeJava.KEY)).isFalse();
- }
-
- @Test
- public void should_skip_by_language() {
- settings.setProperty("sonar.cpd.skip", false);
- settings.setProperty("sonar.cpd.php.skip", true);
-
- assertThat(sensor.isSkipped("php")).isTrue();
- assertThat(sensor.isSkipped(FakeJava.KEY)).isFalse();
+ sensor = new DeprecatedCpdBlockIndexerSensor(sonarEngine, sonarBridgeEngine, fs);
}
@Test