aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-07-24 14:48:35 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2014-07-24 14:56:37 +0200
commit1e46f499f5879f330039482437682cd9e3016ccb (patch)
tree1fccd56d1332c143f7ea05ab9891621ccbf0eada /sonar-batch
parent6d556fb4191aa47eeecde5d148040607c71ab74f (diff)
downloadsonarqube-1e46f499f5879f330039482437682cd9e3016ccb.tar.gz
sonarqube-1e46f499f5879f330039482437682cd9e3016ccb.zip
SONAR-5389 Log reason why sensor is not executed
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan2/AnalyzerOptimizer.java20
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan2/SensorsExecutor.java8
2 files changed, 17 insertions, 11 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan2/AnalyzerOptimizer.java b/sonar-batch/src/main/java/org/sonar/batch/scan2/AnalyzerOptimizer.java
index fb461854c69..4ae3ddfce09 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan2/AnalyzerOptimizer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan2/AnalyzerOptimizer.java
@@ -19,16 +19,19 @@
*/
package org.sonar.batch.scan2;
-import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor;
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.sonar.api.BatchComponent;
import org.sonar.api.batch.fs.FilePredicate;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.rule.ActiveRules;
+import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor;
public class AnalyzerOptimizer implements BatchComponent {
+ private static final Logger LOG = LoggerFactory.getLogger(AnalyzerOptimizer.class);
+
private final FileSystem fs;
private final ActiveRules activeRules;
@@ -41,10 +44,15 @@ public class AnalyzerOptimizer implements BatchComponent {
* Decide if the given Analyzer should be executed.
*/
public boolean shouldExecute(DefaultSensorDescriptor descriptor) {
- // FS Conditions
- boolean fsCondition = fsCondition(descriptor);
- boolean activeRulesCondition = activeRulesCondition(descriptor);
- return fsCondition && activeRulesCondition;
+ if (!fsCondition(descriptor)) {
+ LOG.debug("'{}' skipped because there is no related file in current project", descriptor.name());
+ return false;
+ }
+ if (!activeRulesCondition(descriptor)) {
+ LOG.debug("'{}' skipped because there is no related rule activated in the quality profile", descriptor.name());
+ return false;
+ }
+ return true;
}
private boolean activeRulesCondition(DefaultSensorDescriptor descriptor) {
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan2/SensorsExecutor.java b/sonar-batch/src/main/java/org/sonar/batch/scan2/SensorsExecutor.java
index 14b6326b150..d437eadb6fd 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan2/SensorsExecutor.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan2/SensorsExecutor.java
@@ -19,13 +19,12 @@
*/
package org.sonar.batch.scan2;
-import org.sonar.api.batch.sensor.Sensor;
-import org.sonar.api.batch.sensor.SensorContext;
-import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.BatchComponent;
+import org.sonar.api.batch.sensor.Sensor;
+import org.sonar.api.batch.sensor.SensorContext;
+import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor;
import org.sonar.batch.bootstrap.BatchExtensionDictionnary;
import java.util.Collection;
@@ -51,7 +50,6 @@ public class SensorsExecutor implements BatchComponent {
analyzer.describe(descriptor);
if (!optimizer.shouldExecute(descriptor)) {
- LOG.debug("Analyzer skipped: " + descriptor.name());
continue;
}