aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java4
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/global/GlobalProjectSensor.java (renamed from plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/global/GlobalSensor.java)6
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/Sensor.java7
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorContext.java3
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorDescriptor.java5
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/scanner/sensor/ProjectSensor.java (renamed from sonar-plugin-api/src/main/java/org/sonar/api/scanner/sensor/Sensor.java)2
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputModuleTest.java71
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputProjectTest.java49
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/AbstractExtensionDictionnary.java4
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/BatchComponents.java2
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/JavaCpdBlockIndexerSensor.java3
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/report/AnalysisContextReportPublisher.java5
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/DefaultProjectRepositoriesLoader.java40
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleConfigurationProvider.java7
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleIndexer.java1
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectConfigurationProvider.java4
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java8
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java4
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ProjectFileIndexer.java15
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/AbstractSensorWrapper.java63
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ModuleSensorExtensionDictionnary.java5
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ModuleSensorWrapper.java40
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorExtensionDictionnary.java11
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorWrapper.java38
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/DefaultFileLinesContextTest.java4
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java4
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/postjob/DefaultPostJobContextTest.java5
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/QProfileVerifierTest.java4
28 files changed, 242 insertions, 172 deletions
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java
index 73efd1d2580..8817e5575ec 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java
@@ -32,7 +32,7 @@ import org.sonar.xoo.extensions.XooIssueFilter;
import org.sonar.xoo.extensions.XooPostJob;
import org.sonar.xoo.extensions.XooProjectBuilder;
import org.sonar.xoo.global.DeprecatedGlobalSensor;
-import org.sonar.xoo.global.GlobalSensor;
+import org.sonar.xoo.global.GlobalProjectSensor;
import org.sonar.xoo.lang.CpdTokenizerSensor;
import org.sonar.xoo.lang.LineMeasureSensor;
import org.sonar.xoo.lang.MeasureSensor;
@@ -174,7 +174,7 @@ public class XooPlugin implements Plugin {
context.addExtension(DeprecatedGlobalSensor.class);
}
if (context.getSonarQubeVersion().isGreaterThanOrEqual(Version.create(7, 6))) {
- context.addExtension(GlobalSensor.class);
+ context.addExtension(GlobalProjectSensor.class);
}
if (context.getSonarQubeVersion().isGreaterThanOrEqual(Version.create(7, 2))) {
context.addExtensions(
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/global/GlobalSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/global/GlobalProjectSensor.java
index e4aef94c692..67d214011f5 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/global/GlobalSensor.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/global/GlobalProjectSensor.java
@@ -19,15 +19,15 @@
*/
package org.sonar.xoo.global;
-import org.sonar.api.scanner.sensor.Sensor;
+import org.sonar.api.scanner.sensor.ProjectSensor;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.batch.sensor.SensorDescriptor;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
-public class GlobalSensor implements Sensor {
+public class GlobalProjectSensor implements ProjectSensor {
- private static final Logger LOG = Loggers.get(GlobalSensor.class);
+ private static final Logger LOG = Loggers.get(GlobalProjectSensor.class);
public static final String ENABLE_PROP = "sonar.scanner.mediumtest.globalSensor";
@Override
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/Sensor.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/Sensor.java
index ee04d993594..8e0a70824e9 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/Sensor.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/Sensor.java
@@ -20,8 +20,10 @@
package org.sonar.api.batch.sensor;
import org.sonar.api.ExtensionPoint;
+import org.sonar.api.batch.InstantiationStrategy;
import org.sonar.api.batch.ScannerSide;
import org.sonar.api.batch.sensor.internal.SensorContextTester;
+import org.sonar.api.scanner.sensor.ProjectSensor;
import org.sonarsource.api.sonarlint.SonarLintSide;
/**
@@ -33,12 +35,13 @@ import org.sonarsource.api.sonarlint.SonarLintSide;
*
* For testing purpose you can use {@link SensorContextTester}
* @since 5.1
- * @since 7.6 use {@link org.sonar.api.scanner.sensor.Sensor} instead to make your Sensor run only once per analysis, and no more once per module
+ * @since 7.6 use {@link ProjectSensor} instead to make your Sensor run only once per analysis, and no more once per module
*/
@ScannerSide
+@InstantiationStrategy(InstantiationStrategy.PER_PROJECT)
@SonarLintSide
@ExtensionPoint
-public interface Sensor {
+public interface Sensor extends ProjectSensor {
/**
* Populate {@link SensorDescriptor} of this sensor.
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorContext.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorContext.java
index 98cb74c0d15..8f7cb5fdaf6 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorContext.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorContext.java
@@ -43,6 +43,7 @@ import org.sonar.api.batch.sensor.symbol.NewSymbolTable;
import org.sonar.api.config.Configuration;
import org.sonar.api.config.Settings;
import org.sonar.api.scanner.fs.InputProject;
+import org.sonar.api.scanner.sensor.ProjectSensor;
import org.sonar.api.utils.Version;
/**
@@ -77,7 +78,7 @@ public interface SensorContext {
/**
* @since 5.5
* @deprecated since 7.6 modules are deprecated. Use {@link #project()} instead.
- * @throws UnsupportedOperationException for global {@link org.sonar.api.scanner.sensor.Sensor}s
+ * @throws UnsupportedOperationException for global {@link ProjectSensor}s
*/
@Deprecated
InputModule module();
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorDescriptor.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorDescriptor.java
index 133766139d3..6a868bb187c 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorDescriptor.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorDescriptor.java
@@ -22,9 +22,10 @@ package org.sonar.api.batch.sensor;
import java.util.function.Predicate;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.config.Configuration;
+import org.sonar.api.scanner.sensor.ProjectSensor;
/**
- * Describe what a {@link org.sonar.api.scanner.sensor.Sensor} is doing. Information may be used by the platform
+ * Describe what a {@link Sensor} is doing. Information may be used by the platform
* to log interesting information or perform some optimization.
* See {@link Sensor#describe(SensorDescriptor)}
* @since 5.1
@@ -88,7 +89,7 @@ public interface SensorDescriptor {
/**
* This sensor should be executed at the project level, instead of per-module.
* @since 6.4
- * @deprecated since 7.6 change your {@link Sensor} to a {@link org.sonar.api.scanner.sensor.Sensor} instead
+ * @deprecated since 7.6 change your {@link Sensor} to a {@link ProjectSensor} instead
*/
@Deprecated
SensorDescriptor global();
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scanner/sensor/Sensor.java b/sonar-plugin-api/src/main/java/org/sonar/api/scanner/sensor/ProjectSensor.java
index ededb64909a..689b56e1484 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/scanner/sensor/Sensor.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/scanner/sensor/ProjectSensor.java
@@ -38,7 +38,7 @@ import org.sonarsource.api.sonarlint.SonarLintSide;
@ScannerSide
@SonarLintSide
@ExtensionPoint
-public interface Sensor {
+public interface ProjectSensor {
/**
* Populate {@link SensorDescriptor} of this sensor.
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputModuleTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputModuleTest.java
new file mode 100644
index 00000000000..abe834bc3d6
--- /dev/null
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputModuleTest.java
@@ -0,0 +1,71 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.api.batch.fs.internal;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+import org.sonar.api.batch.bootstrap.ProjectDefinition;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class DefaultInputModuleTest {
+
+ private static final String FILE_1 = "file1";
+ private static final String TEST_1 = "test1";
+ @Rule
+ public TemporaryFolder temp = new TemporaryFolder();
+
+ @Test
+ public void testGetters() throws IOException {
+ ProjectDefinition def = ProjectDefinition.create();
+ def.setKey("moduleKey");
+ File baseDir = temp.newFolder();
+ Path src = baseDir.toPath().resolve(FILE_1);
+ Files.createFile(src);
+ Path test = baseDir.toPath().resolve(TEST_1);
+ Files.createFile(test);
+ def.setBaseDir(baseDir);
+ File workDir = temp.newFolder();
+ def.setWorkDir(workDir);
+ def.setSources(FILE_1);
+ def.setTests(TEST_1);
+ DefaultInputModule module = new DefaultInputModule(def);
+
+ assertThat(module.key()).isEqualTo("moduleKey");
+ assertThat(module.definition()).isEqualTo(def);
+ assertThat(module.getBranch()).isNull();
+ assertThat(module.getBaseDir()).isEqualTo(baseDir.toPath());
+ assertThat(module.getKeyWithBranch()).isEqualTo("moduleKey");
+ assertThat(module.getWorkDir()).isEqualTo(workDir.toPath());
+ assertThat(module.getEncoding()).isEqualTo(Charset.defaultCharset());
+ assertThat(module.getSourceDirsOrFiles()).containsExactlyInAnyOrder(src);
+ assertThat(module.getTestDirsOrFiles()).containsExactlyInAnyOrder(test);
+ assertThat(module.getEncoding()).isEqualTo(Charset.defaultCharset());
+
+ assertThat(module.isFile()).isFalse();
+ }
+
+}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputProjectTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputProjectTest.java
index e9e54e5a77a..33751cd6151 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputProjectTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputProjectTest.java
@@ -21,6 +21,8 @@ package org.sonar.api.batch.fs.internal;
import java.io.File;
import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
@@ -46,23 +48,42 @@ public class DefaultInputProjectTest {
def.setWorkDir(workDir);
def.setSources("file1");
def.setTests("test1");
- AbstractProjectOrModule module = new DefaultInputProject(def);
+ AbstractProjectOrModule project = new DefaultInputProject(def);
- assertThat(module.key()).isEqualTo("projectKey");
- assertThat(module.getName()).isEqualTo("projectName");
- assertThat(module.getOriginalName()).isEqualTo("projectName");
- assertThat(module.definition()).isEqualTo(def);
- assertThat(module.getBranch()).isNull();
- assertThat(module.getBaseDir()).isEqualTo(baseDir.toPath());
- assertThat(module.getKeyWithBranch()).isEqualTo("projectKey");
- assertThat(module.getVersion()).isEqualTo("version");
- assertThat(module.getOriginalVersion()).isEqualTo("version");
- assertThat(module.getDescription()).isEqualTo("desc");
- assertThat(module.getWorkDir()).isEqualTo(workDir.toPath());
+ assertThat(project.key()).isEqualTo("projectKey");
+ assertThat(project.getName()).isEqualTo("projectName");
+ assertThat(project.getOriginalName()).isEqualTo("projectName");
+ assertThat(project.definition()).isEqualTo(def);
+ assertThat(project.getBranch()).isNull();
+ assertThat(project.getBaseDir()).isEqualTo(baseDir.toPath());
+ assertThat(project.getKeyWithBranch()).isEqualTo("projectKey");
+ assertThat(project.getVersion()).isEqualTo("version");
+ assertThat(project.getOriginalVersion()).isEqualTo("version");
+ assertThat(project.getDescription()).isEqualTo("desc");
+ assertThat(project.getWorkDir()).isEqualTo(workDir.toPath());
+ assertThat(project.getEncoding()).isEqualTo(Charset.defaultCharset());
- assertThat(module.properties()).hasSize(6);
+ assertThat(project.properties()).hasSize(6);
- assertThat(module.isFile()).isFalse();
+ assertThat(project.isFile()).isFalse();
+ }
+
+ @Test
+ public void testEncoding() throws IOException {
+ ProjectDefinition def = ProjectDefinition.create();
+ def.setKey("projectKey");
+ def.setName("projectName");
+ File baseDir = temp.newFolder();
+ def.setBaseDir(baseDir);
+ def.setVersion("version");
+ def.setDescription("desc");
+ File workDir = temp.newFolder();
+ def.setWorkDir(workDir);
+ def.setSources("file1");
+ def.setProperty("sonar.sourceEncoding", "UTF-16");
+ AbstractProjectOrModule project = new DefaultInputProject(def);
+
+ assertThat(project.getEncoding()).isEqualTo(StandardCharsets.UTF_16);
}
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/AbstractExtensionDictionnary.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/AbstractExtensionDictionnary.java
index d4733375ba8..240c2c4da65 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/AbstractExtensionDictionnary.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/AbstractExtensionDictionnary.java
@@ -64,9 +64,9 @@ public abstract class AbstractExtensionDictionnary {
protected <T> List<T> getFilteredExtensions(Class<T> type, @Nullable ExtensionMatcher matcher) {
List<T> result = new ArrayList<>();
- for (Object extension : getExtensions(type)) {
+ for (T extension : getExtensions(type)) {
if (shouldKeep(type, extension, matcher)) {
- result.add((T) extension);
+ result.add(extension);
}
}
return result;
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/BatchComponents.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/BatchComponents.java
index d5487c990ca..e9005b92353 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/BatchComponents.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/BatchComponents.java
@@ -25,6 +25,7 @@ import java.util.List;
import org.sonar.core.component.DefaultResourceTypes;
import org.sonar.core.config.CorePropertyDefinitions;
import org.sonar.core.issue.tracking.Tracker;
+import org.sonar.scanner.cpd.JavaCpdBlockIndexerSensor;
import org.sonar.scanner.externalissue.ExternalIssuesImportSensor;
import org.sonar.scanner.genericcoverage.GenericCoverageSensor;
import org.sonar.scanner.genericcoverage.GenericTestExecutionSensor;
@@ -44,6 +45,7 @@ public class BatchComponents {
components.addAll(CorePropertyDefinitions.all());
if (!analysisMode.isIssues()) {
components.add(ZeroCoverageSensor.class);
+ components.add(JavaCpdBlockIndexerSensor.class);
// Generic coverage
components.add(GenericCoverageSensor.class);
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/JavaCpdBlockIndexerSensor.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/JavaCpdBlockIndexerSensor.java
index defff497883..5770e8869ab 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/JavaCpdBlockIndexerSensor.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/JavaCpdBlockIndexerSensor.java
@@ -61,8 +61,7 @@ public class JavaCpdBlockIndexerSensor implements Sensor {
@Override
public void describe(SensorDescriptor descriptor) {
descriptor.name("Java CPD Block Indexer")
- .onlyOnLanguage("java")
- .global();
+ .onlyOnLanguage("java");
}
@Override
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/AnalysisContextReportPublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/AnalysisContextReportPublisher.java
index 5c60eb4e2d2..ebb8a8facaa 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/AnalysisContextReportPublisher.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/AnalysisContextReportPublisher.java
@@ -64,10 +64,8 @@ public class AnalysisContextReportPublisher {
private final InputModuleHierarchy hierarchy;
private final InputComponentStore store;
- private ScannerReportWriter writer;
-
public AnalysisContextReportPublisher(ProjectServerSettings projectServerSettings, AnalysisMode mode, ScannerPluginRepository pluginRepo, System2 system,
- GlobalServerSettings globalServerSettings, InputModuleHierarchy hierarchy, InputComponentStore store) {
+ GlobalServerSettings globalServerSettings, InputModuleHierarchy hierarchy, InputComponentStore store) {
this.projectServerSettings = projectServerSettings;
this.mode = mode;
this.pluginRepo = pluginRepo;
@@ -81,7 +79,6 @@ public class AnalysisContextReportPublisher {
if (mode.isIssues()) {
return;
}
- this.writer = writer;
File analysisLog = writer.getFileStructure().analysisLog();
try (BufferedWriter fileWriter = Files.newBufferedWriter(analysisLog.toPath(), StandardCharsets.UTF_8)) {
if (LOG.isDebugEnabled()) {
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/DefaultProjectRepositoriesLoader.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/DefaultProjectRepositoriesLoader.java
index 8a7d8c7f1e0..85e71d87100 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/DefaultProjectRepositoriesLoader.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/DefaultProjectRepositoriesLoader.java
@@ -27,7 +27,6 @@ import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nullable;
-import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.utils.MessageException;
@@ -51,8 +50,11 @@ public class DefaultProjectRepositoriesLoader implements ProjectRepositoriesLoad
public ProjectRepositories load(String projectKey, boolean issuesMode, @Nullable String branchBase) {
GetRequest request = new GetRequest(getUrl(projectKey, issuesMode, branchBase));
try (WsResponse response = wsClient.call(request)) {
- InputStream is = response.contentStream();
- return processStream(is, projectKey);
+ try (InputStream is = response.contentStream()) {
+ return processStream(is);
+ } catch (IOException e) {
+ throw new IllegalStateException("Couldn't load project repository for " + projectKey, e);
+ }
} catch (RuntimeException e) {
if (shouldThrow(e)) {
throw e;
@@ -91,26 +93,20 @@ public class DefaultProjectRepositoriesLoader implements ProjectRepositoriesLoad
return false;
}
- private ProjectRepositories processStream(InputStream is, String projectKey) {
- try {
- WsProjectResponse response = WsProjectResponse.parseFrom(is);
- if (response.getFileDataByModuleAndPathCount() == 0) {
- return new SingleProjectRepository(constructFileDataMap(response.getFileDataByPathMap()), new Date(response.getLastAnalysisDate()));
- } else {
- final Map<String, SingleProjectRepository> repositoriesPerModule = new HashMap<>();
- response.getFileDataByModuleAndPathMap().keySet().forEach(moduleKey -> {
- WsProjectResponse.FileDataByPath filePaths = response.getFileDataByModuleAndPathMap().get(moduleKey);
- repositoriesPerModule.put(moduleKey, new SingleProjectRepository(
- constructFileDataMap(filePaths.getFileDataByPathMap()), new Date(response.getLastAnalysisDate())));
- });
- return new MultiModuleProjectRepository(repositoriesPerModule, new Date(response.getLastAnalysisDate()));
- }
-
- } catch (IOException e) {
- throw new IllegalStateException("Couldn't load project repository for " + projectKey, e);
- } finally {
- IOUtils.closeQuietly(is);
+ private static ProjectRepositories processStream(InputStream is) throws IOException {
+ WsProjectResponse response = WsProjectResponse.parseFrom(is);
+ if (response.getFileDataByModuleAndPathCount() == 0) {
+ return new SingleProjectRepository(constructFileDataMap(response.getFileDataByPathMap()), new Date(response.getLastAnalysisDate()));
+ } else {
+ final Map<String, SingleProjectRepository> repositoriesPerModule = new HashMap<>();
+ response.getFileDataByModuleAndPathMap().keySet().forEach(moduleKey -> {
+ WsProjectResponse.FileDataByPath filePaths = response.getFileDataByModuleAndPathMap().get(moduleKey);
+ repositoriesPerModule.put(moduleKey, new SingleProjectRepository(
+ constructFileDataMap(filePaths.getFileDataByPathMap()), new Date(response.getLastAnalysisDate())));
+ });
+ return new MultiModuleProjectRepository(repositoriesPerModule, new Date(response.getLastAnalysisDate()));
}
+
}
private static Map<String, FileData> constructFileDataMap(Map<String, WsProjectResponse.FileData> content) {
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleConfigurationProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleConfigurationProvider.java
index 556d09b9184..a60556dee6c 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleConfigurationProvider.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleConfigurationProvider.java
@@ -28,18 +28,15 @@ import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.fs.internal.DefaultInputModule;
import org.sonar.scanner.bootstrap.GlobalAnalysisMode;
import org.sonar.scanner.bootstrap.GlobalConfiguration;
-import org.sonar.scanner.report.AnalysisContextReportPublisher;
public class ModuleConfigurationProvider extends ProviderAdapter {
private ModuleConfiguration moduleConfiguration;
- public ModuleConfiguration provide(GlobalConfiguration globalConfig, DefaultInputModule module, ProjectServerSettings projectServerSettings,
- GlobalAnalysisMode analysisMode, AnalysisContextReportPublisher contextReportPublisher) {
+ public ModuleConfiguration provide(GlobalConfiguration globalConfig, DefaultInputModule module, ProjectServerSettings projectServerSettings, GlobalAnalysisMode analysisMode) {
if (moduleConfiguration == null) {
- Map<String, String> settings = new LinkedHashMap<>();
- settings.putAll(projectServerSettings.properties());
+ Map<String, String> settings = new LinkedHashMap<>(projectServerSettings.properties());
addScannerSideProperties(settings, module.definition());
moduleConfiguration = new ModuleConfiguration(globalConfig.getDefinitions(), globalConfig.getEncryption(), analysisMode, settings);
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleIndexer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleIndexer.java
index 4b85e732f66..da1c14363ca 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleIndexer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleIndexer.java
@@ -20,7 +20,6 @@
package org.sonar.scanner.scan;
import org.picocontainer.Startable;
-import org.sonar.api.batch.fs.internal.AbstractProjectOrModule;
import org.sonar.api.batch.fs.internal.DefaultInputModule;
import org.sonar.api.batch.fs.internal.InputModuleHierarchy;
import org.sonar.scanner.scan.filesystem.InputComponentStore;
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectConfigurationProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectConfigurationProvider.java
index 8c774902e88..8f5752d6a36 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectConfigurationProvider.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectConfigurationProvider.java
@@ -31,8 +31,8 @@ public class ProjectConfigurationProvider extends ProviderAdapter {
private ProjectConfiguration projectConfig;
- public ProjectConfiguration provide(DefaultInputProject project, GlobalConfiguration globalConfig, GlobalServerSettings globalServerSettings, ProjectServerSettings projectServerSettings,
- GlobalAnalysisMode mode, MutableProjectSettings projectSettings) {
+ public ProjectConfiguration provide(DefaultInputProject project, GlobalConfiguration globalConfig, GlobalServerSettings globalServerSettings,
+ ProjectServerSettings projectServerSettings, GlobalAnalysisMode mode, MutableProjectSettings projectSettings) {
if (projectConfig == null) {
Map<String, String> settings = new LinkedHashMap<>();
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java
index 295417852b7..b3d656a55c3 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java
@@ -261,7 +261,6 @@ public class ProjectScanContainer extends ComponentContainer {
CpdExecutor.class,
CpdSettings.class,
SonarCpdBlockIndex.class,
- JavaCpdBlockIndexerSensor.class,
// PostJobs
PostJobsExecutor.class,
@@ -327,7 +326,12 @@ public class ProjectScanContainer extends ComponentContainer {
@VisibleForTesting
static ExtensionMatcher getScannerProjectExtensionsFilter() {
- return extension -> isScannerSide(extension) || (isDeprecatedScannerSide(extension) && isInstantiationStrategy(extension, PER_BATCH));
+ return extension -> {
+ if (isDeprecatedScannerSide(extension)) {
+ return isInstantiationStrategy(extension, PER_BATCH);
+ }
+ return isScannerSide(extension);
+ };
}
@Override
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java
index 46e60710237..e9721a38add 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java
@@ -136,7 +136,7 @@ public class FileIndexer {
issueExclusionsLoader.addMulticriteriaPatterns(inputFile.getProjectRelativePath(), inputFile.key());
}
LOG.debug("'{}' indexed {}with language '{}'", projectRelativePath, type == Type.TEST ? "as test " : "", inputFile.language());
- evaluateCoverageExclusions(module, moduleCoverageExclusions, inputFile);
+ evaluateCoverageExclusions(moduleCoverageExclusions, inputFile);
if (properties.preloadFileMetadata()) {
inputFile.checkMetadata();
}
@@ -151,7 +151,7 @@ public class FileIndexer {
}
}
- private void evaluateCoverageExclusions(DefaultInputModule module, ModuleCoverageExclusions moduleCoverageExclusions, DefaultInputFile inputFile) {
+ private void evaluateCoverageExclusions(ModuleCoverageExclusions moduleCoverageExclusions, DefaultInputFile inputFile) {
boolean excludedByProjectConfiguration = projectCoverageExclusions.isExcluded(inputFile);
if (excludedByProjectConfiguration) {
inputFile.setExcludedForCoverage(true);
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ProjectFileIndexer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ProjectFileIndexer.java
index af87198823f..6663c08ec88 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ProjectFileIndexer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ProjectFileIndexer.java
@@ -39,7 +39,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.batch.fs.InputFile.Type;
import org.sonar.api.batch.fs.internal.DefaultInputModule;
-import org.sonar.api.batch.fs.internal.DefaultInputProject;
import org.sonar.api.batch.fs.internal.InputModuleHierarchy;
import org.sonar.api.scan.filesystem.PathResolver;
import org.sonar.scanner.util.ProgressReport;
@@ -51,21 +50,17 @@ public class ProjectFileIndexer {
private static final Logger LOG = LoggerFactory.getLogger(ProjectFileIndexer.class);
private final AbstractExclusionFilters projectExclusionFilters;
- private final DefaultInputProject project;
private final InputComponentStore componentStore;
private final InputModuleHierarchy inputModuleHierarchy;
- private final ProjectCoverageExclusions projectCoverageExclusions;
private final FileIndexer fileIndexer;
private ProgressReport progressReport;
- public ProjectFileIndexer(DefaultInputProject project, InputComponentStore componentStore, AbstractExclusionFilters exclusionFilters,
- InputModuleHierarchy inputModuleHierarchy, ProjectCoverageExclusions projectCoverageExclusions,
+ public ProjectFileIndexer(InputComponentStore componentStore, AbstractExclusionFilters exclusionFilters,
+ InputModuleHierarchy inputModuleHierarchy,
FileIndexer fileIndexer) {
- this.project = project;
this.componentStore = componentStore;
this.inputModuleHierarchy = inputModuleHierarchy;
- this.projectCoverageExclusions = projectCoverageExclusions;
this.fileIndexer = fileIndexer;
this.projectExclusionFilters = exclusionFilters;
}
@@ -95,7 +90,7 @@ public class ProjectFileIndexer {
private void index(DefaultInputModule module, AtomicInteger excludedByPatternsCount) {
if (componentStore.allModules().size() > 1) {
LOG.info(" Indexing files from module {}", module.getName());
- LOG.info(" Base dir: {}", module.getBaseDir().toAbsolutePath().toString());
+ LOG.info(" Base dir: {}", module.getBaseDir().toAbsolutePath());
logPaths(" Source paths: ", module.getBaseDir(), module.getSourceDirsOrFiles());
logPaths(" Test paths: ", module.getBaseDir(), module.getTestDirsOrFiles());
}
@@ -108,7 +103,7 @@ public class ProjectFileIndexer {
private static void logPaths(String label, Path baseDir, List<Path> paths) {
if (!paths.isEmpty()) {
StringBuilder sb = new StringBuilder(label);
- for (Iterator<Path> it = paths.iterator(); it.hasNext(); ) {
+ for (Iterator<Path> it = paths.iterator(); it.hasNext();) {
Path file = it.next();
Optional<String> relativePathToBaseDir = PathResolver.relativize(baseDir, file);
if (!relativePathToBaseDir.isPresent()) {
@@ -204,7 +199,7 @@ public class ProjectFileIndexer {
}
@Override
- public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
+ public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
return FileVisitResult.CONTINUE;
}
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/AbstractSensorWrapper.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/AbstractSensorWrapper.java
new file mode 100644
index 00000000000..0d9f8cf4e79
--- /dev/null
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/AbstractSensorWrapper.java
@@ -0,0 +1,63 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.scanner.sensor;
+
+import org.sonar.api.batch.sensor.SensorContext;
+import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor;
+import org.sonar.api.scanner.sensor.ProjectSensor;
+
+public abstract class AbstractSensorWrapper<G extends ProjectSensor> {
+ private final G wrappedSensor;
+ private final SensorContext context;
+ private final DefaultSensorDescriptor descriptor;
+ private final AbstractSensorOptimizer optimizer;
+
+ public AbstractSensorWrapper(G sensor, SensorContext context, AbstractSensorOptimizer optimizer) {
+ this.wrappedSensor = sensor;
+ this.optimizer = optimizer;
+ this.context = context;
+ this.descriptor = new DefaultSensorDescriptor();
+ sensor.describe(this.descriptor);
+ if (descriptor.name() == null) {
+ descriptor.name(sensor.getClass().getName());
+ }
+ }
+
+ public boolean shouldExecute() {
+ return optimizer.shouldExecute(descriptor);
+ }
+
+ public void analyse() {
+ wrappedSensor.execute(context);
+ }
+
+ public G wrappedSensor() {
+ return wrappedSensor;
+ }
+
+ @Override
+ public String toString() {
+ return descriptor.name();
+ }
+
+ public boolean isGlobal() {
+ return descriptor.isGlobal();
+ }
+}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ModuleSensorExtensionDictionnary.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ModuleSensorExtensionDictionnary.java
index e90cb636063..ba024b3b60d 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ModuleSensorExtensionDictionnary.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ModuleSensorExtensionDictionnary.java
@@ -22,16 +22,15 @@ package org.sonar.scanner.sensor;
import java.util.Collection;
import java.util.stream.Collectors;
import org.sonar.api.batch.sensor.Sensor;
-import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.core.platform.ComponentContainer;
import org.sonar.scanner.bootstrap.AbstractExtensionDictionnary;
public class ModuleSensorExtensionDictionnary extends AbstractExtensionDictionnary {
- private final SensorContext sensorContext;
+ private final ModuleSensorContext sensorContext;
private final ModuleSensorOptimizer sensorOptimizer;
- public ModuleSensorExtensionDictionnary(ComponentContainer componentContainer, SensorContext sensorContext, ModuleSensorOptimizer sensorOptimizer) {
+ public ModuleSensorExtensionDictionnary(ComponentContainer componentContainer, ModuleSensorContext sensorContext, ModuleSensorOptimizer sensorOptimizer) {
super(componentContainer);
this.sensorContext = sensorContext;
this.sensorOptimizer = sensorOptimizer;
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ModuleSensorWrapper.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ModuleSensorWrapper.java
index 541a8bee87e..8f968d72397 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ModuleSensorWrapper.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ModuleSensorWrapper.java
@@ -20,44 +20,10 @@
package org.sonar.scanner.sensor;
import org.sonar.api.batch.sensor.Sensor;
-import org.sonar.api.batch.sensor.SensorContext;
-import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor;
-public class ModuleSensorWrapper {
- private final Sensor wrappedSensor;
- private final SensorContext context;
- private final DefaultSensorDescriptor descriptor;
- private final ModuleSensorOptimizer optimizer;
+public class ModuleSensorWrapper extends AbstractSensorWrapper<Sensor> {
- public ModuleSensorWrapper(Sensor sensor, SensorContext context, ModuleSensorOptimizer optimizer) {
- this.wrappedSensor = sensor;
- this.optimizer = optimizer;
- this.context = context;
- this.descriptor = new DefaultSensorDescriptor();
- sensor.describe(this.descriptor);
- if (descriptor.name() == null) {
- descriptor.name(sensor.getClass().getName());
- }
- }
-
- public boolean shouldExecute() {
- return optimizer.shouldExecute(descriptor);
- }
-
- public void analyse() {
- wrappedSensor.execute(context);
- }
-
- public Sensor wrappedSensor() {
- return wrappedSensor;
- }
-
- @Override
- public String toString() {
- return descriptor.name();
- }
-
- public boolean isGlobal() {
- return descriptor.isGlobal();
+ public ModuleSensorWrapper(Sensor sensor, ModuleSensorContext context, ModuleSensorOptimizer optimizer) {
+ super(sensor, context, optimizer);
}
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorExtensionDictionnary.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorExtensionDictionnary.java
index 34a05fe0933..47e6b3720a6 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorExtensionDictionnary.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorExtensionDictionnary.java
@@ -22,15 +22,14 @@ package org.sonar.scanner.sensor;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
-import org.sonar.api.batch.sensor.SensorContext;
-import org.sonar.api.scanner.sensor.Sensor;
+import org.sonar.api.scanner.sensor.ProjectSensor;
import org.sonar.core.platform.ComponentContainer;
import org.sonar.scanner.bootstrap.AbstractExtensionDictionnary;
public class ProjectSensorExtensionDictionnary extends AbstractExtensionDictionnary {
- private final SensorContext sensorContext;
- private final AbstractSensorOptimizer sensorOptimizer;
+ private final ProjectSensorContext sensorContext;
+ private final ProjectSensorOptimizer sensorOptimizer;
public ProjectSensorExtensionDictionnary(ComponentContainer componentContainer, ProjectSensorContext sensorContext, ProjectSensorOptimizer sensorOptimizer) {
super(componentContainer);
@@ -39,10 +38,10 @@ public class ProjectSensorExtensionDictionnary extends AbstractExtensionDictionn
}
public List<ProjectSensorWrapper> selectSensors() {
- Collection<Sensor> result = sort(getFilteredExtensions(Sensor.class, null));
+ Collection<ProjectSensor> result = sort(getFilteredExtensions(ProjectSensor.class, null));
return result.stream()
.map(s -> new ProjectSensorWrapper(s, sensorContext, sensorOptimizer))
- .filter(s -> s.shouldExecute())
+ .filter(ProjectSensorWrapper::shouldExecute)
.collect(Collectors.toList());
}
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorWrapper.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorWrapper.java
index b8463937f31..97afb6b9f33 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorWrapper.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorWrapper.java
@@ -19,42 +19,12 @@
*/
package org.sonar.scanner.sensor;
-import org.sonar.api.batch.sensor.SensorContext;
-import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor;
-import org.sonar.api.scanner.sensor.Sensor;
+import org.sonar.api.scanner.sensor.ProjectSensor;
-public class ProjectSensorWrapper {
- private final Sensor wrappedSensor;
- private final SensorContext context;
- private final DefaultSensorDescriptor descriptor;
- private final AbstractSensorOptimizer optimizer;
+public class ProjectSensorWrapper extends AbstractSensorWrapper<ProjectSensor> {
- public ProjectSensorWrapper(Sensor sensor, SensorContext context, AbstractSensorOptimizer optimizer) {
- this.wrappedSensor = sensor;
- this.optimizer = optimizer;
- this.context = context;
- this.descriptor = new DefaultSensorDescriptor();
- sensor.describe(this.descriptor);
- if (descriptor.name() == null) {
- descriptor.name(sensor.getClass().getName());
- }
- }
-
- public boolean shouldExecute() {
- return optimizer.shouldExecute(descriptor);
- }
-
- public void analyse() {
- wrappedSensor.execute(context);
- }
-
- public Sensor wrappedSensor() {
- return wrappedSensor;
- }
-
- @Override
- public String toString() {
- return descriptor.name();
+ public ProjectSensorWrapper(ProjectSensor sensor, ProjectSensorContext context, ProjectSensorOptimizer optimizer) {
+ super(sensor, context, optimizer);
}
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/DefaultFileLinesContextTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/DefaultFileLinesContextTest.java
index 0983d76d2ae..7d28d497230 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/DefaultFileLinesContextTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/DefaultFileLinesContextTest.java
@@ -24,7 +24,6 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.junit.rules.TemporaryFolder;
import org.mockito.ArgumentCaptor;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
@@ -53,9 +52,6 @@ public class DefaultFileLinesContextTest {
private static final String BRANCHES_METRIC_KEY = "branches";
@Rule
- public TemporaryFolder temp = new TemporaryFolder();
-
- @Rule
public ExpectedException thrown = ExpectedException.none();
private DefaultFileLinesContext fileLineMeasures;
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java
index 211f289ec9f..20f8754b038 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java
@@ -43,7 +43,7 @@ import org.sonar.scanner.mediumtest.AnalysisResult;
import org.sonar.scanner.mediumtest.ScannerMediumTester;
import org.sonar.xoo.XooPlugin;
import org.sonar.xoo.global.DeprecatedGlobalSensor;
-import org.sonar.xoo.global.GlobalSensor;
+import org.sonar.xoo.global.GlobalProjectSensor;
import org.sonar.xoo.rule.XooRulesDefinition;
import static java.util.stream.Collectors.joining;
@@ -705,7 +705,7 @@ public class FileSystemMediumTest {
File projectDir = new File("test-resources/mediumtest/xoo/multi-modules-sample");
AnalysisResult result = tester
.newAnalysis(new File(projectDir, "sonar-project.properties"))
- .property(GlobalSensor.ENABLE_PROP, "true")
+ .property(GlobalProjectSensor.ENABLE_PROP, "true")
.execute();
assertThat(result.inputFiles()).hasSize(4);
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/postjob/DefaultPostJobContextTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/postjob/DefaultPostJobContextTest.java
index f9381879df1..b9a9e561c0e 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/postjob/DefaultPostJobContextTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/postjob/DefaultPostJobContextTest.java
@@ -22,9 +22,7 @@ package org.sonar.scanner.postjob;
import java.io.IOException;
import java.util.Arrays;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
import org.sonar.api.batch.AnalysisMode;
import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
import org.sonar.api.batch.postjob.issue.PostJobIssue;
@@ -41,9 +39,6 @@ import static org.mockito.Mockito.when;
public class DefaultPostJobContextTest {
- @Rule
- public TemporaryFolder temp = new TemporaryFolder();
-
private IssueCache issueCache;
private InputComponentStore componentStore;
private DefaultPostJobContext context;
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/QProfileVerifierTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/QProfileVerifierTest.java
index 18facbe6391..3b6188f4ca9 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/QProfileVerifierTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/QProfileVerifierTest.java
@@ -23,7 +23,6 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.junit.rules.TemporaryFolder;
import org.slf4j.Logger;
import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
import org.sonar.api.config.internal.MapSettings;
@@ -38,9 +37,6 @@ import static org.mockito.Mockito.when;
public class QProfileVerifierTest {
@Rule
- public TemporaryFolder temp = new TemporaryFolder();
-
- @Rule
public ExpectedException thrown = ExpectedException.none();
private InputComponentStore store;