aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src/main/java/org/sonar/scanner
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2022-07-19 17:16:19 -0500
committersonartech <sonartech@sonarsource.com>2022-07-23 20:02:53 +0000
commit0771cedad60f3542aab4e858227c0e4fc98e08b8 (patch)
tree9c54359ae41b3466a0b1ba386b722ded15427967 /sonar-scanner-engine/src/main/java/org/sonar/scanner
parentb0058ce4110d6311c9fe3f81252da28883de1c43 (diff)
downloadsonarqube-0771cedad60f3542aab4e858227c0e4fc98e08b8.tar.gz
sonarqube-0771cedad60f3542aab4e858227c0e4fc98e08b8.zip
SONAR-17044 Fix ITs
Diffstat (limited to 'sonar-scanner-engine/src/main/java/org/sonar/scanner')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ModuleSensorsExecutor.java17
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/UnchangedFilesHandler.java6
2 files changed, 13 insertions, 10 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ModuleSensorsExecutor.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ModuleSensorsExecutor.java
index 80c13e1ce64..b2eba806cfb 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ModuleSensorsExecutor.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ModuleSensorsExecutor.java
@@ -37,13 +37,15 @@ public class ModuleSensorsExecutor {
private final ModuleSensorExtensionDictionary selector;
private final SensorStrategy strategy;
private final ScannerPluginRepository pluginRepo;
+ private final ExecutingSensorContext executingSensorCtx;
private final boolean isRoot;
public ModuleSensorsExecutor(ModuleSensorExtensionDictionary selector, DefaultInputModule module, InputModuleHierarchy hierarchy,
- SensorStrategy strategy, ScannerPluginRepository pluginRepo) {
+ SensorStrategy strategy, ScannerPluginRepository pluginRepo, ExecutingSensorContext executingSensorCtx) {
this.selector = selector;
this.strategy = strategy;
this.pluginRepo = pluginRepo;
+ this.executingSensorCtx = executingSensorCtx;
this.isRoot = hierarchy.isRoot(module);
}
@@ -80,20 +82,19 @@ public class ModuleSensorsExecutor {
private void execute(Collection<ModuleSensorWrapper> sensors) {
for (ModuleSensorWrapper sensor : sensors) {
- String sensorName = getSensorName(sensor);
- profiler.startInfo("Sensor " + sensorName);
+ SensorId sensorId = getSensorId(sensor);
+ profiler.startInfo("Sensor " + sensorId);
+ executingSensorCtx.setSensorExecuting(sensorId);
sensor.analyse();
+ executingSensorCtx.clearExecutingSensor();
profiler.stopInfo();
}
}
- private String getSensorName(ModuleSensorWrapper sensor) {
+ private SensorId getSensorId(ModuleSensorWrapper sensor) {
ClassLoader cl = getSensorClassLoader(sensor);
String pluginKey = pluginRepo.getPluginKey(cl);
- if (pluginKey != null) {
- return sensor.toString() + " [" + pluginKey + "]";
- }
- return sensor.toString();
+ return new SensorId(pluginKey, sensor.toString());
}
private static ClassLoader getSensorClassLoader(ModuleSensorWrapper sensor) {
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/UnchangedFilesHandler.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/UnchangedFilesHandler.java
index 29803dbee67..353a49991a8 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/UnchangedFilesHandler.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/UnchangedFilesHandler.java
@@ -32,7 +32,9 @@ public class UnchangedFilesHandler {
private static final Logger LOG = Loggers.get(UnchangedFilesHandler.class);
private static final Set<SensorId> ENABLED_SENSORS = Set.of(
new SensorId("cpp", "CFamily"),
- new SensorId("cobol", "CobolSquidSensor"));
+ new SensorId("cobol", "CobolSquidSensor"),
+ // for ITs
+ new SensorId("xoo", "Mark As Unchanged Sensor"));
private static final String ENABLE_PROPERTY_KEY = "sonar.unchangedFiles.optimize";
private final boolean featureActive;
private final ExecutingSensorContext executingSensorContext;
@@ -67,6 +69,6 @@ public class UnchangedFilesHandler {
}
private boolean isFeatureActive() {
- return featureActive && ENABLED_SENSORS.contains(executingSensorContext.getSensorExecuting());
+ return featureActive && executingSensorContext.getSensorExecuting() != null && ENABLED_SENSORS.contains(executingSensorContext.getSensorExecuting());
}
}