From 7fec39b0b5d604167fefd615c5400cd597166685 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Mon, 2 Mar 2015 14:48:24 +0100 Subject: Revert "SONAR-6202 Compute overall coverage on all files" This reverts commit eac465bea9f5bf89a7beb8036e4d8eea4723f421. Conflicts: plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java --- .../api/measures/CoverageMeasuresBuilder.java | 69 +++++----------------- 1 file changed, 15 insertions(+), 54 deletions(-) (limited to 'sonar-plugin-api') diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoverageMeasuresBuilder.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoverageMeasuresBuilder.java index 7648dac9e8e..823155b2d0a 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoverageMeasuresBuilder.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoverageMeasuresBuilder.java @@ -34,48 +34,13 @@ import java.util.SortedMap; */ public final class CoverageMeasuresBuilder { - /** - * @since 5.1 - */ - public static enum CoverageType { - UNIT(CoreMetrics.LINES_TO_COVER, CoreMetrics.UNCOVERED_LINES, CoreMetrics.COVERAGE_LINE_HITS_DATA, - CoreMetrics.CONDITIONS_TO_COVER, CoreMetrics.UNCOVERED_CONDITIONS, CoreMetrics.CONDITIONS_BY_LINE, - CoreMetrics.COVERED_CONDITIONS_BY_LINE), - IT(CoreMetrics.IT_LINES_TO_COVER, CoreMetrics.IT_UNCOVERED_LINES, CoreMetrics.IT_COVERAGE_LINE_HITS_DATA, - CoreMetrics.IT_CONDITIONS_TO_COVER, CoreMetrics.IT_UNCOVERED_CONDITIONS, CoreMetrics.IT_CONDITIONS_BY_LINE, - CoreMetrics.IT_COVERED_CONDITIONS_BY_LINE), - OVERALL(CoreMetrics.OVERALL_LINES_TO_COVER, CoreMetrics.OVERALL_UNCOVERED_LINES, CoreMetrics.OVERALL_COVERAGE_LINE_HITS_DATA, - CoreMetrics.OVERALL_CONDITIONS_TO_COVER, CoreMetrics.OVERALL_UNCOVERED_CONDITIONS, CoreMetrics.OVERALL_CONDITIONS_BY_LINE, - CoreMetrics.OVERALL_COVERED_CONDITIONS_BY_LINE); - - private final Metric linesToCover; - private final Metric uncoveredLines; - private final Metric lineHits; - private final Metric conditionsToCover; - private final Metric uncoveredConditions; - private final Metric conditionsByLine; - private final Metric coveredConditionsByLine; - - private CoverageType(Metric linesToCover, Metric uncoveredLines, Metric lineHits, Metric conditionsToCover, - Metric uncoveredConditions, Metric conditionsByLine, Metric coveredConditionsByLine) { - this.linesToCover = linesToCover; - this.uncoveredLines = uncoveredLines; - this.lineHits = lineHits; - this.conditionsToCover = conditionsToCover; - this.uncoveredConditions = uncoveredConditions; - this.conditionsByLine = conditionsByLine; - this.coveredConditionsByLine = coveredConditionsByLine; - } - - public List all() { - return Arrays.asList(linesToCover, uncoveredLines, lineHits, conditionsToCover, uncoveredConditions, conditionsByLine, coveredConditionsByLine); - } - } - /** * Metrics of generated measures */ - public static final List METRICS = CoverageType.UNIT.all(); + public static final List METRICS = Arrays.asList( + CoreMetrics.LINES_TO_COVER, CoreMetrics.UNCOVERED_LINES, CoreMetrics.COVERAGE_LINE_HITS_DATA, + CoreMetrics.CONDITIONS_TO_COVER, CoreMetrics.UNCOVERED_CONDITIONS, CoreMetrics.CONDITIONS_BY_LINE, + CoreMetrics.COVERED_CONDITIONS_BY_LINE); private int totalCoveredLines = 0, totalConditions = 0, totalCoveredConditions = 0; private SortedMap hitsByLine = Maps.newTreeMap(); @@ -145,33 +110,29 @@ public final class CoverageMeasuresBuilder { } public Collection createMeasures() { - return createMeasures(CoverageType.UNIT); - } - - public Collection createMeasures(CoverageType type) { Collection measures = Lists.newArrayList(); if (getLinesToCover() > 0) { - measures.add(new Measure(type.linesToCover, (double) getLinesToCover())); - measures.add(new Measure(type.uncoveredLines, (double) (getLinesToCover() - getCoveredLines()))); - measures.add(new Measure(type.lineHits).setData(KeyValueFormat.format(hitsByLine)).setPersistenceMode(PersistenceMode.DATABASE)); + measures.add(new Measure(CoreMetrics.LINES_TO_COVER, (double) getLinesToCover())); + measures.add(new Measure(CoreMetrics.UNCOVERED_LINES, (double) (getLinesToCover() - getCoveredLines()))); + measures.add(new Measure(CoreMetrics.COVERAGE_LINE_HITS_DATA).setData(KeyValueFormat.format(hitsByLine)).setPersistenceMode(PersistenceMode.DATABASE)); } if (getConditions() > 0) { - measures.add(new Measure(type.conditionsToCover, (double) getConditions())); - measures.add(new Measure(type.uncoveredConditions, (double) (getConditions() - getCoveredConditions()))); - measures.add(createConditionsByLine(type)); - measures.add(createCoveredConditionsByLine(type)); + measures.add(new Measure(CoreMetrics.CONDITIONS_TO_COVER, (double) getConditions())); + measures.add(new Measure(CoreMetrics.UNCOVERED_CONDITIONS, (double) (getConditions() - getCoveredConditions()))); + measures.add(createConditionsByLine()); + measures.add(createCoveredConditionsByLine()); } return measures; } - private Measure createCoveredConditionsByLine(CoverageType type) { - return new Measure(type.coveredConditionsByLine) + private Measure createCoveredConditionsByLine() { + return new Measure(CoreMetrics.COVERED_CONDITIONS_BY_LINE) .setData(KeyValueFormat.format(coveredConditionsByLine)) .setPersistenceMode(PersistenceMode.DATABASE); } - private Measure createConditionsByLine(CoverageType type) { - return new Measure(type.conditionsByLine) + private Measure createConditionsByLine() { + return new Measure(CoreMetrics.CONDITIONS_BY_LINE) .setData(KeyValueFormat.format(conditionsByLine)) .setPersistenceMode(PersistenceMode.DATABASE); } -- cgit v1.2.3