Skip to content

Commit

Permalink
Merge pull request #115 from rudrakshi/develop
Browse files Browse the repository at this point in the history
Fixing Code Coverage
  • Loading branch information
ThomasPohl authored Feb 15, 2020
2 parents fe99c0d + ef8b26d commit 0379794
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public class EsqlSensor implements Sensor {
private final ActionParser<Tree> parser;
// parsingErrorRuleKey equals null if ParsingErrorCheck is not activated
private RuleKey parsingErrorRuleKey = null;
private MetricsVisitor metricsVisitor = null;

public EsqlSensor(
CheckFactory checkFactory, FileLinesContextFactory fileLinesContextFactory, FileSystem fileSystem, NoSonarFilter noSonarFilter) {
Expand Down Expand Up @@ -134,7 +135,7 @@ protected void analyseFiles(
success = true;
} catch (CancellationException e) {
// do not propagate the exception
LOG.debug(e.toString(), e);
LOG.debug("Error while file analysis in code coverage" + e.toString(), e);
} finally {
stopProgressReport(progressReport, success);
}
Expand Down Expand Up @@ -311,7 +312,7 @@ public void execute(SensorContext context) {
public List<TreeVisitor> getTreeVisitors(SensorContext context) {
boolean ignoreHeaderComments = ignoreHeaderComments(context);

MetricsVisitor metricsVisitor = new MetricsVisitor(
metricsVisitor = new MetricsVisitor(
context,
ignoreHeaderComments,
fileLinesContextFactory);
Expand All @@ -328,12 +329,10 @@ public void highlightSymbols(InputFile inputFile, TreeVisitorContext treeVisitor
}

public void executeCoverageSensors(SensorContext context) {
boolean ignoreHeaderComments = ignoreHeaderComments(context);

MetricsVisitor metricsVisitor = new MetricsVisitor(
context,
ignoreHeaderComments,
fileLinesContextFactory);
//Removed re-initialization of metriccvisitor as executable lines were empty
if (metricsVisitor == null) {
LOG.debug("metricVisitor null");
}

executeCoverageSensors(context, metricsVisitor.executableLines());
}
Expand Down

0 comments on commit 0379794

Please sign in to comment.