diff options
author | Jenkins CI <ci@sonarsource.com> | 2015-03-03 07:59:36 +0100 |
---|---|---|
committer | Jenkins CI <ci@sonarsource.com> | 2015-03-03 07:59:36 +0100 |
commit | e0d9c3793d99ff6a26c694bf0f1d9af2e73b4950 (patch) | |
tree | c4954cc495575b83e4ac907a3878429c70b20b3f /sonar-plugin-api | |
parent | f48b42fdc9a7e389311304403afa6021556dc82b (diff) | |
parent | 006ed438573acae253f0601d9292364a40150909 (diff) | |
download | sonarqube-e0d9c3793d99ff6a26c694bf0f1d9af2e73b4950.tar.gz sonarqube-e0d9c3793d99ff6a26c694bf0f1d9af2e73b4950.zip |
Automatic merge from master
* origin/master:
fix source viewer test
Add search the ability to search for rules by profiles in RubyRuleService Needed to fix SQALE-269
SONAR-5884 show ut and it coverage separately
SONAR-5884 show ut and it coverage separately
SONAR-5884 Apply feedback on unit test and field names
SONAR-5884 Replace overall coverage with UT coverage, add IT coverage info
Revert "SONAR-6202 Compute overall coverage on all files"
SONAR-5077 Display ncloc of files with no language in size widget
SONAR-6233 Searching for rules without debt characteristic is not working
fix bug with extra duplicated line in the popup
fix bug with extra duplicated line
Fix quality flaws
update events widget
Update version of Git and SVN plugins to 1.0
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/measures/CoverageMeasuresBuilder.java | 69 |
1 files changed, 15 insertions, 54 deletions
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 @@ -35,47 +35,12 @@ 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<Integer> linesToCover; - private final Metric<Integer> uncoveredLines; - private final Metric<String> lineHits; - private final Metric<Integer> conditionsToCover; - private final Metric<Integer> uncoveredConditions; - private final Metric<String> conditionsByLine; - private final Metric<String> coveredConditionsByLine; - - private CoverageType(Metric<Integer> linesToCover, Metric<Integer> uncoveredLines, Metric<String> lineHits, Metric<Integer> conditionsToCover, - Metric<Integer> uncoveredConditions, Metric<String> conditionsByLine, Metric<String> coveredConditionsByLine) { - this.linesToCover = linesToCover; - this.uncoveredLines = uncoveredLines; - this.lineHits = lineHits; - this.conditionsToCover = conditionsToCover; - this.uncoveredConditions = uncoveredConditions; - this.conditionsByLine = conditionsByLine; - this.coveredConditionsByLine = coveredConditionsByLine; - } - - public List<Metric> all() { - return Arrays.<Metric>asList(linesToCover, uncoveredLines, lineHits, conditionsToCover, uncoveredConditions, conditionsByLine, coveredConditionsByLine); - } - } - - /** * Metrics of generated measures */ - public static final List<Metric> METRICS = CoverageType.UNIT.all(); + public static final List<Metric> METRICS = Arrays.<Metric>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<Integer, Integer> hitsByLine = Maps.newTreeMap(); @@ -145,33 +110,29 @@ public final class CoverageMeasuresBuilder { } public Collection<Measure> createMeasures() { - return createMeasures(CoverageType.UNIT); - } - - public Collection<Measure> createMeasures(CoverageType type) { Collection<Measure> 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); } |