]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5389 Log reason why sensor is not executed
authorJulien HENRY <julien.henry@sonarsource.com>
Thu, 24 Jul 2014 12:48:35 +0000 (14:48 +0200)
committerJulien HENRY <julien.henry@sonarsource.com>
Thu, 24 Jul 2014 12:56:37 +0000 (14:56 +0200)
sonar-batch/src/main/java/org/sonar/batch/scan2/AnalyzerOptimizer.java
sonar-batch/src/main/java/org/sonar/batch/scan2/SensorsExecutor.java

index fb461854c69c9a769a81021c834faf1ececdc035..4ae3ddfce095564f48038d31a791a041d59e2bf3 100644 (file)
  */
 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) {
index 14b6326b1508e69bcbcf4670171b2a808731a86f..d437eadb6fd30933e3cb9d5c115c28fe170842b7 100644 (file)
  */
 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;
       }