From 1e46f499f5879f330039482437682cd9e3016ccb Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Thu, 24 Jul 2014 14:48:35 +0200 Subject: [PATCH] SONAR-5389 Log reason why sensor is not executed --- .../sonar/batch/scan2/AnalyzerOptimizer.java | 20 +++++++++++++------ .../sonar/batch/scan2/SensorsExecutor.java | 8 +++----- 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; } -- 2.39.5