diff options
38 files changed, 491 insertions, 271 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/CountUnresolvedIssuesDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/CountUnresolvedIssuesDecorator.java index 00c145353dd..d82a34e6c99 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/CountUnresolvedIssuesDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/CountUnresolvedIssuesDecorator.java @@ -85,7 +85,7 @@ public class CountUnresolvedIssuesDecorator implements Decorator { @DependedUpon public List<Metric> generatesIssuesMetrics() { - return ImmutableList.of( + return ImmutableList.<Metric>of( CoreMetrics.VIOLATIONS, CoreMetrics.BLOCKER_VIOLATIONS, CoreMetrics.CRITICAL_VIOLATIONS, diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssuesDensityDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssuesDensityDecorator.java index 0fd2b10d0c6..a804bbd9a42 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssuesDensityDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssuesDensityDecorator.java @@ -19,7 +19,11 @@ */ package org.sonar.plugins.core.issue; -import org.sonar.api.batch.*; +import org.sonar.api.batch.Decorator; +import org.sonar.api.batch.DecoratorBarriers; +import org.sonar.api.batch.DecoratorContext; +import org.sonar.api.batch.DependedUpon; +import org.sonar.api.batch.DependsUpon; import org.sonar.api.measures.CoreMetrics; import org.sonar.api.measures.Measure; import org.sonar.api.measures.MeasureUtils; @@ -42,7 +46,7 @@ public class IssuesDensityDecorator implements Decorator { @DependsUpon public List<Metric> dependsUponWeightedIissuesAndNcloc() { - return Arrays.asList(CoreMetrics.WEIGHTED_VIOLATIONS, CoreMetrics.NCLOC); + return Arrays.<Metric>asList(CoreMetrics.WEIGHTED_VIOLATIONS, CoreMetrics.NCLOC); } @DependedUpon diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/WeightedIssuesDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/WeightedIssuesDecorator.java index e3172e5870c..a7af9d3ff29 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/WeightedIssuesDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/WeightedIssuesDecorator.java @@ -43,16 +43,14 @@ import java.util.Arrays; import java.util.List; import java.util.Map; -@Properties( - @Property( - key = CoreProperties.CORE_RULE_WEIGHTS_PROPERTY, - defaultValue = CoreProperties.CORE_RULE_WEIGHTS_DEFAULT_VALUE, - name = "Rules weight", - description = "A weight is associated to each severity to emphasize the most critical issues.", - project = false, - global = true, - category = CoreProperties.CATEGORY_GENERAL) -) +@Properties(@Property( + key = CoreProperties.CORE_RULE_WEIGHTS_PROPERTY, + defaultValue = CoreProperties.CORE_RULE_WEIGHTS_DEFAULT_VALUE, + name = "Rules weight", + description = "A weight is associated to each severity to emphasize the most critical issues.", + project = false, + global = true, + category = CoreProperties.CATEGORY_GENERAL)) public class WeightedIssuesDecorator implements Decorator { private Settings settings; @@ -64,7 +62,7 @@ public class WeightedIssuesDecorator implements Decorator { @DependsUpon public List<Metric> dependsUponIssues() { - return Arrays.asList(CoreMetrics.BLOCKER_VIOLATIONS, CoreMetrics.CRITICAL_VIOLATIONS, + return Arrays.<Metric>asList(CoreMetrics.BLOCKER_VIOLATIONS, CoreMetrics.CRITICAL_VIOLATIONS, CoreMetrics.MAJOR_VIOLATIONS, CoreMetrics.MINOR_VIOLATIONS, CoreMetrics.INFO_VIOLATIONS); } diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/BranchCoverageDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/BranchCoverageDecorator.java index 36378cdf82d..951c1d383a1 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/BranchCoverageDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/BranchCoverageDecorator.java @@ -31,8 +31,8 @@ import java.util.List; public final class BranchCoverageDecorator extends AbstractCoverageDecorator { @DependsUpon public List<Metric> dependsUponMetrics() { - return ImmutableList.of(CoreMetrics.UNCOVERED_CONDITIONS, CoreMetrics.CONDITIONS_TO_COVER, - CoreMetrics.NEW_UNCOVERED_CONDITIONS, CoreMetrics.NEW_CONDITIONS_TO_COVER); + return ImmutableList.<Metric>of(CoreMetrics.UNCOVERED_CONDITIONS, CoreMetrics.CONDITIONS_TO_COVER, + CoreMetrics.NEW_UNCOVERED_CONDITIONS, CoreMetrics.NEW_CONDITIONS_TO_COVER); } @Override diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CommentDensityDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CommentDensityDecorator.java index 65502c74449..3bba4a2a52d 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CommentDensityDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CommentDensityDecorator.java @@ -19,9 +19,6 @@ */ package org.sonar.plugins.core.sensors; -import java.util.Arrays; -import java.util.List; - import org.sonar.api.batch.Decorator; import org.sonar.api.batch.DecoratorContext; import org.sonar.api.batch.DependedUpon; @@ -33,16 +30,19 @@ import org.sonar.api.measures.Metric; import org.sonar.api.resources.Project; import org.sonar.api.resources.Resource; +import java.util.Arrays; +import java.util.List; + public class CommentDensityDecorator implements Decorator { @DependsUpon public List<Metric> dependsUponMetrics() { - return Arrays.asList(CoreMetrics.NCLOC, CoreMetrics.COMMENT_LINES, CoreMetrics.PUBLIC_API, CoreMetrics.PUBLIC_UNDOCUMENTED_API); + return Arrays.<Metric>asList(CoreMetrics.NCLOC, CoreMetrics.COMMENT_LINES, CoreMetrics.PUBLIC_API, CoreMetrics.PUBLIC_UNDOCUMENTED_API); } @DependedUpon public List<Metric> generatesMetrics() { - return Arrays.asList(CoreMetrics.COMMENT_LINES_DENSITY, CoreMetrics.PUBLIC_DOCUMENTED_API_DENSITY); + return Arrays.<Metric>asList(CoreMetrics.COMMENT_LINES_DENSITY, CoreMetrics.PUBLIC_DOCUMENTED_API_DENSITY); } public boolean shouldExecuteOnProject(Project project) { diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CoverageDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CoverageDecorator.java index aa8804106c4..2d37d02dec9 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CoverageDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CoverageDecorator.java @@ -31,7 +31,7 @@ import java.util.Collection; public final class CoverageDecorator extends AbstractCoverageDecorator { @DependsUpon public Collection<Metric> usedMetrics() { - return ImmutableList.of(CoreMetrics.LINES_TO_COVER, CoreMetrics.UNCOVERED_LINES, CoreMetrics.NEW_LINES_TO_COVER, + return ImmutableList.<Metric>of(CoreMetrics.LINES_TO_COVER, CoreMetrics.UNCOVERED_LINES, CoreMetrics.NEW_LINES_TO_COVER, CoreMetrics.NEW_UNCOVERED_LINES, CoreMetrics.CONDITIONS_TO_COVER, CoreMetrics.UNCOVERED_CONDITIONS, CoreMetrics.NEW_CONDITIONS_TO_COVER, CoreMetrics.NEW_UNCOVERED_CONDITIONS); } diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ItBranchCoverageDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ItBranchCoverageDecorator.java index bd0c595d9a5..eb515e363a5 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ItBranchCoverageDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ItBranchCoverageDecorator.java @@ -32,8 +32,8 @@ public final class ItBranchCoverageDecorator extends AbstractCoverageDecorator { @DependsUpon public List<Metric> dependsUponMetrics() { - return ImmutableList.of(CoreMetrics.IT_UNCOVERED_CONDITIONS, CoreMetrics.IT_CONDITIONS_TO_COVER, - CoreMetrics.NEW_IT_UNCOVERED_CONDITIONS, CoreMetrics.NEW_IT_CONDITIONS_TO_COVER); + return ImmutableList.<Metric>of(CoreMetrics.IT_UNCOVERED_CONDITIONS, CoreMetrics.IT_CONDITIONS_TO_COVER, + CoreMetrics.NEW_IT_UNCOVERED_CONDITIONS, CoreMetrics.NEW_IT_CONDITIONS_TO_COVER); } @Override diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ItCoverageDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ItCoverageDecorator.java index 24d931c934d..a9bd603985a 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ItCoverageDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ItCoverageDecorator.java @@ -31,9 +31,9 @@ import java.util.Collection; public final class ItCoverageDecorator extends AbstractCoverageDecorator { @DependsUpon public Collection<Metric> usedMetrics() { - return ImmutableList.of(CoreMetrics.IT_LINES_TO_COVER, CoreMetrics.IT_UNCOVERED_LINES, CoreMetrics.NEW_IT_LINES_TO_COVER, - CoreMetrics.NEW_IT_UNCOVERED_LINES, CoreMetrics.IT_CONDITIONS_TO_COVER, CoreMetrics.IT_UNCOVERED_CONDITIONS, - CoreMetrics.NEW_IT_CONDITIONS_TO_COVER, CoreMetrics.NEW_IT_UNCOVERED_CONDITIONS); + return ImmutableList.<Metric>of(CoreMetrics.IT_LINES_TO_COVER, CoreMetrics.IT_UNCOVERED_LINES, CoreMetrics.NEW_IT_LINES_TO_COVER, + CoreMetrics.NEW_IT_UNCOVERED_LINES, CoreMetrics.IT_CONDITIONS_TO_COVER, CoreMetrics.IT_UNCOVERED_CONDITIONS, + CoreMetrics.NEW_IT_CONDITIONS_TO_COVER, CoreMetrics.NEW_IT_UNCOVERED_CONDITIONS); } @Override diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ItLineCoverageDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ItLineCoverageDecorator.java index f516d34537f..651d379c92e 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ItLineCoverageDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ItLineCoverageDecorator.java @@ -31,8 +31,8 @@ import java.util.List; public final class ItLineCoverageDecorator extends AbstractCoverageDecorator { @DependsUpon public List<Metric> dependsUponMetrics() { - return ImmutableList.of(CoreMetrics.IT_UNCOVERED_LINES, CoreMetrics.IT_LINES_TO_COVER, CoreMetrics.NEW_IT_UNCOVERED_LINES, - CoreMetrics.NEW_IT_LINES_TO_COVER); + return ImmutableList.<Metric>of(CoreMetrics.IT_UNCOVERED_LINES, CoreMetrics.IT_LINES_TO_COVER, CoreMetrics.NEW_IT_UNCOVERED_LINES, + CoreMetrics.NEW_IT_LINES_TO_COVER); } @Override diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/LineCoverageDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/LineCoverageDecorator.java index d9db9c8d394..feaf04176cf 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/LineCoverageDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/LineCoverageDecorator.java @@ -31,8 +31,8 @@ import java.util.List; public final class LineCoverageDecorator extends AbstractCoverageDecorator { @DependsUpon public List<Metric> dependsUponMetrics() { - return ImmutableList.of(CoreMetrics.UNCOVERED_LINES, CoreMetrics.LINES_TO_COVER, CoreMetrics.NEW_UNCOVERED_LINES, - CoreMetrics.NEW_LINES_TO_COVER); + return ImmutableList.<Metric>of(CoreMetrics.UNCOVERED_LINES, CoreMetrics.LINES_TO_COVER, CoreMetrics.NEW_UNCOVERED_LINES, + CoreMetrics.NEW_LINES_TO_COVER); } @Override diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/OverallBranchCoverageDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/OverallBranchCoverageDecorator.java index 19e02290842..2c54896f22d 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/OverallBranchCoverageDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/OverallBranchCoverageDecorator.java @@ -31,8 +31,8 @@ import java.util.List; public final class OverallBranchCoverageDecorator extends AbstractCoverageDecorator { @DependsUpon public List<Metric> dependsUponMetrics() { - return ImmutableList.of(CoreMetrics.OVERALL_UNCOVERED_CONDITIONS, CoreMetrics.OVERALL_CONDITIONS_TO_COVER, - CoreMetrics.NEW_OVERALL_UNCOVERED_CONDITIONS, CoreMetrics.NEW_OVERALL_CONDITIONS_TO_COVER); + return ImmutableList.<Metric>of(CoreMetrics.OVERALL_UNCOVERED_CONDITIONS, CoreMetrics.OVERALL_CONDITIONS_TO_COVER, + CoreMetrics.NEW_OVERALL_UNCOVERED_CONDITIONS, CoreMetrics.NEW_OVERALL_CONDITIONS_TO_COVER); } @Override diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/OverallCoverageDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/OverallCoverageDecorator.java index dd106fd64e6..998e4b3ef24 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/OverallCoverageDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/OverallCoverageDecorator.java @@ -31,9 +31,9 @@ import java.util.Collection; public final class OverallCoverageDecorator extends AbstractCoverageDecorator { @DependsUpon public Collection<Metric> usedMetrics() { - return ImmutableList.of(CoreMetrics.OVERALL_LINES_TO_COVER, CoreMetrics.OVERALL_UNCOVERED_LINES, CoreMetrics.NEW_OVERALL_LINES_TO_COVER, - CoreMetrics.NEW_OVERALL_UNCOVERED_LINES, CoreMetrics.OVERALL_CONDITIONS_TO_COVER, CoreMetrics.OVERALL_UNCOVERED_CONDITIONS, - CoreMetrics.NEW_OVERALL_CONDITIONS_TO_COVER, CoreMetrics.NEW_OVERALL_UNCOVERED_CONDITIONS); + return ImmutableList.<Metric>of(CoreMetrics.OVERALL_LINES_TO_COVER, CoreMetrics.OVERALL_UNCOVERED_LINES, CoreMetrics.NEW_OVERALL_LINES_TO_COVER, + CoreMetrics.NEW_OVERALL_UNCOVERED_LINES, CoreMetrics.OVERALL_CONDITIONS_TO_COVER, CoreMetrics.OVERALL_UNCOVERED_CONDITIONS, + CoreMetrics.NEW_OVERALL_CONDITIONS_TO_COVER, CoreMetrics.NEW_OVERALL_UNCOVERED_CONDITIONS); } @Override diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/OverallLineCoverageDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/OverallLineCoverageDecorator.java index 35dc51718f0..a3ab283cf9d 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/OverallLineCoverageDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/OverallLineCoverageDecorator.java @@ -31,8 +31,8 @@ import java.util.List; public final class OverallLineCoverageDecorator extends AbstractCoverageDecorator { @DependsUpon public List<Metric> dependsUponMetrics() { - return ImmutableList.of(CoreMetrics.OVERALL_UNCOVERED_LINES, CoreMetrics.OVERALL_LINES_TO_COVER, CoreMetrics.NEW_OVERALL_UNCOVERED_LINES, - CoreMetrics.NEW_OVERALL_LINES_TO_COVER); + return ImmutableList.<Metric>of(CoreMetrics.OVERALL_UNCOVERED_LINES, CoreMetrics.OVERALL_LINES_TO_COVER, CoreMetrics.NEW_OVERALL_UNCOVERED_LINES, + CoreMetrics.NEW_OVERALL_LINES_TO_COVER); } @Override diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/UnitTestDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/UnitTestDecorator.java index 6fca0264d7d..3423b73ee21 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/UnitTestDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/UnitTestDecorator.java @@ -38,7 +38,7 @@ public class UnitTestDecorator implements Decorator { @DependedUpon public List<Metric> generatesMetrics() { - return Arrays.asList(CoreMetrics.TEST_EXECUTION_TIME, CoreMetrics.TESTS, CoreMetrics.TEST_ERRORS, CoreMetrics.TEST_FAILURES, CoreMetrics.TEST_SUCCESS_DENSITY); + return Arrays.<Metric>asList(CoreMetrics.TEST_EXECUTION_TIME, CoreMetrics.TESTS, CoreMetrics.TEST_ERRORS, CoreMetrics.TEST_FAILURES, CoreMetrics.TEST_SUCCESS_DENSITY); } public boolean shouldExecuteOnProject(Project project) { diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewCoverageAggregator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewCoverageAggregator.java index cfd472d0d47..c23d303dbd2 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewCoverageAggregator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewCoverageAggregator.java @@ -44,7 +44,7 @@ public final class NewCoverageAggregator implements Decorator { @DependedUpon public List<Metric> generatesNewCoverageMetrics() { - return Arrays.asList( + return Arrays.<Metric>asList( CoreMetrics.NEW_LINES_TO_COVER, CoreMetrics.NEW_UNCOVERED_LINES, CoreMetrics.NEW_CONDITIONS_TO_COVER, CoreMetrics.NEW_UNCOVERED_CONDITIONS, CoreMetrics.NEW_IT_LINES_TO_COVER, CoreMetrics.NEW_IT_UNCOVERED_LINES, CoreMetrics.NEW_IT_CONDITIONS_TO_COVER, CoreMetrics.NEW_IT_UNCOVERED_CONDITIONS, CoreMetrics.NEW_OVERALL_LINES_TO_COVER, CoreMetrics.NEW_OVERALL_UNCOVERED_LINES, CoreMetrics.NEW_OVERALL_CONDITIONS_TO_COVER, CoreMetrics.NEW_OVERALL_UNCOVERED_CONDITIONS); @@ -69,23 +69,23 @@ public final class NewCoverageAggregator implements Decorator { } void aggregate(DecoratorContext context, Metric metric, int maxPeriods) { - int[] variations = {0,0,0,0,0}; - boolean[] hasValues = {false,false,false,false,false}; + int[] variations = {0, 0, 0, 0, 0}; + boolean[] hasValues = {false, false, false, false, false}; for (Measure child : context.getChildrenMeasures(metric)) { - for (int indexPeriod=1 ; indexPeriod<=maxPeriods ; indexPeriod++) { + for (int indexPeriod = 1; indexPeriod <= maxPeriods; indexPeriod++) { Double variation = child.getVariation(indexPeriod); - if (variation!=null) { - variations[indexPeriod-1]=variations[indexPeriod-1] + variation.intValue(); - hasValues[indexPeriod-1]=true; + if (variation != null) { + variations[indexPeriod - 1] = variations[indexPeriod - 1] + variation.intValue(); + hasValues[indexPeriod - 1] = true; } } } if (ArrayUtils.contains(hasValues, true)) { Measure measure = new Measure(metric); - for (int index=0 ; index<5 ; index++) { + for (int index = 0; index < 5; index++) { if (hasValues[index]) { - measure.setVariation(index+1, (double)variations[index]); + measure.setVariation(index + 1, (double) variations[index]); } } context.saveMeasure(measure); diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TendencyDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TendencyDecoratorTest.java index 8713c66537b..4240fa71bd7 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TendencyDecoratorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TendencyDecoratorTest.java @@ -20,11 +20,13 @@ package org.sonar.plugins.core.timemachine; import org.junit.Test; +import org.junit.matchers.JUnitMatchers; import org.sonar.api.batch.DecoratorContext; import org.sonar.api.batch.TimeMachine; import org.sonar.api.batch.TimeMachineQuery; import org.sonar.api.measures.CoreMetrics; import org.sonar.api.measures.Measure; +import org.sonar.api.measures.Metric; import org.sonar.api.measures.MetricFinder; import org.sonar.api.resources.Directory; import org.sonar.api.resources.Project; @@ -36,7 +38,6 @@ import java.util.Date; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.matchers.JUnitMatchers.hasItems; import static org.mockito.Matchers.anyList; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; @@ -51,13 +52,13 @@ public class TendencyDecoratorTest { when(project.getAnalysisDate()).thenReturn(date("2009-12-25")); MetricFinder metricFinder = mock(MetricFinder.class); - when(metricFinder.findAll()).thenReturn(Arrays.asList(CoreMetrics.LINES, CoreMetrics.COVERAGE, CoreMetrics.COVERAGE_LINE_HITS_DATA, CoreMetrics.PROFILE)); + when(metricFinder.findAll()).thenReturn(Arrays.<Metric>asList(CoreMetrics.LINES, CoreMetrics.COVERAGE, CoreMetrics.COVERAGE_LINE_HITS_DATA, CoreMetrics.PROFILE)); TendencyDecorator decorator = new TendencyDecorator(null, metricFinder); TimeMachineQuery query = decorator.initQuery(project); assertThat(query.getMetrics().size(), is(2)); - assertThat(query.getMetrics(), hasItems(CoreMetrics.LINES, CoreMetrics.COVERAGE)); + assertThat(query.getMetrics(), JUnitMatchers.<Metric>hasItems(CoreMetrics.LINES, CoreMetrics.COVERAGE)); assertThat(query.getFrom(), is(date("2009-11-25"))); assertThat(query.isToCurrentAnalysis(), is(true)); } diff --git a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/decorators/DuplicationDensityDecorator.java b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/decorators/DuplicationDensityDecorator.java index de5b307c3f1..bea536ce8d0 100644 --- a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/decorators/DuplicationDensityDecorator.java +++ b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/decorators/DuplicationDensityDecorator.java @@ -36,11 +36,11 @@ public class DuplicationDensityDecorator implements Decorator { @DependsUpon public List<Metric> dependsUponMetrics() { - return Arrays.asList( - CoreMetrics.NCLOC, - CoreMetrics.COMMENT_LINES, - CoreMetrics.DUPLICATED_LINES, - CoreMetrics.LINES); + return Arrays.<Metric>asList( + CoreMetrics.NCLOC, + CoreMetrics.COMMENT_LINES, + CoreMetrics.DUPLICATED_LINES, + CoreMetrics.LINES); } @DependedUpon diff --git a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/decorators/SumDuplicationsDecorator.java b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/decorators/SumDuplicationsDecorator.java index ffb168dcd16..29110918beb 100644 --- a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/decorators/SumDuplicationsDecorator.java +++ b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/decorators/SumDuplicationsDecorator.java @@ -35,7 +35,7 @@ public class SumDuplicationsDecorator extends AbstractSumChildrenDecorator { @Override @DependedUpon public List<Metric> generatesMetrics() { - return Arrays.asList(CoreMetrics.DUPLICATED_BLOCKS, CoreMetrics.DUPLICATED_FILES, CoreMetrics.DUPLICATED_LINES); + return Arrays.<Metric>asList(CoreMetrics.DUPLICATED_BLOCKS, CoreMetrics.DUPLICATED_FILES, CoreMetrics.DUPLICATED_LINES); } @Override diff --git a/sonar-batch/src/main/java/org/sonar/batch/debt/DebtDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/debt/DebtDecorator.java index 17475936308..c2c9c6b0e4c 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/debt/DebtDecorator.java +++ b/sonar-batch/src/main/java/org/sonar/batch/debt/DebtDecorator.java @@ -85,7 +85,7 @@ public final class DebtDecorator implements Decorator { @DependedUpon public List<Metric> generatesMetrics() { - return Arrays.asList(CoreMetrics.TECHNICAL_DEBT); + return Arrays.<Metric>asList(CoreMetrics.TECHNICAL_DEBT); } public void decorate(Resource resource, DecoratorContext context) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/debt/NewDebtDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/debt/NewDebtDecorator.java index fe738d63de8..7320c9c912d 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/debt/NewDebtDecorator.java +++ b/sonar-batch/src/main/java/org/sonar/batch/debt/NewDebtDecorator.java @@ -21,7 +21,11 @@ package org.sonar.batch.debt; import com.google.common.collect.ImmutableList; -import org.sonar.api.batch.*; +import org.sonar.api.batch.Decorator; +import org.sonar.api.batch.DecoratorBarriers; +import org.sonar.api.batch.DecoratorContext; +import org.sonar.api.batch.DependedUpon; +import org.sonar.api.batch.DependsUpon; import org.sonar.api.component.ResourcePerspectives; import org.sonar.api.issue.Issuable; import org.sonar.api.issue.Issue; @@ -33,7 +37,6 @@ import org.sonar.api.resources.Project; import org.sonar.api.resources.Resource; import org.sonar.batch.components.Period; import org.sonar.batch.components.TimeMachineConfiguration; -import org.sonar.batch.debt.IssueChangelogDebtCalculator; import javax.annotation.Nullable; @@ -54,7 +57,7 @@ public final class NewDebtDecorator implements Decorator { private final IssueChangelogDebtCalculator issueChangelogDebtCalculator; public NewDebtDecorator(ResourcePerspectives perspectives, TimeMachineConfiguration timeMachineConfiguration, - IssueChangelogDebtCalculator issueChangelogDebtCalculator) { + IssueChangelogDebtCalculator issueChangelogDebtCalculator) { this.perspectives = perspectives; this.timeMachineConfiguration = timeMachineConfiguration; this.issueChangelogDebtCalculator = issueChangelogDebtCalculator; @@ -66,9 +69,9 @@ public final class NewDebtDecorator implements Decorator { @DependedUpon public List<Metric> generatesMetrics() { - return ImmutableList.of( + return ImmutableList.<Metric>of( CoreMetrics.NEW_TECHNICAL_DEBT - ); + ); } public void decorate(Resource resource, DecoratorContext context) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/language/LanguageDistributionDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/language/LanguageDistributionDecorator.java index fcada30d053..6b4842f71dc 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/language/LanguageDistributionDecorator.java +++ b/sonar-batch/src/main/java/org/sonar/batch/language/LanguageDistributionDecorator.java @@ -20,7 +20,6 @@ package org.sonar.batch.language; -import com.google.common.collect.ImmutableList; import org.sonar.api.batch.Decorator; import org.sonar.api.batch.DecoratorContext; import org.sonar.api.batch.DependedUpon; @@ -34,8 +33,6 @@ import org.sonar.api.resources.Project; import org.sonar.api.resources.Resource; import org.sonar.api.resources.ResourceUtils; -import java.util.List; - public class LanguageDistributionDecorator implements Decorator { public boolean shouldExecuteOnProject(Project project) { @@ -43,15 +40,13 @@ public class LanguageDistributionDecorator implements Decorator { } @DependsUpon - public List<Metric> dependsUponMetrics() { - return ImmutableList.<Metric>of(CoreMetrics.LINES); + public Metric dependsUponMetric() { + return CoreMetrics.LINES; } @DependedUpon - public List<Metric> generatesMetrics() { - return ImmutableList.of( - CoreMetrics.NCLOC_LANGUAGE_DISTRIBUTION - ); + public Metric generatesMetric() { + return CoreMetrics.NCLOC_LANGUAGE_DISTRIBUTION; } public void decorate(Resource resource, DecoratorContext context) { diff --git a/sonar-batch/src/test/java/org/sonar/batch/FormulaDecoratorTest.java b/sonar-batch/src/test/java/org/sonar/batch/FormulaDecoratorTest.java index 1f9e03483a6..ff3d20c6ddc 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/FormulaDecoratorTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/FormulaDecoratorTest.java @@ -21,18 +21,27 @@ package org.sonar.batch; import org.junit.Test; import org.sonar.api.batch.DecoratorContext; -import org.sonar.api.measures.*; +import org.sonar.api.measures.CoreMetrics; +import org.sonar.api.measures.Formula; +import org.sonar.api.measures.FormulaContext; +import org.sonar.api.measures.FormulaData; +import org.sonar.api.measures.Measure; +import org.sonar.api.measures.Metric; import org.sonar.api.test.IsMeasure; import java.util.Arrays; import java.util.Collections; import java.util.List; +import static org.fest.assertions.Assertions.assertThat; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; -import static org.junit.internal.matchers.IsCollectionContaining.hasItem; +import static org.mockito.Matchers.any; import static org.mockito.Matchers.argThat; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; public class FormulaDecoratorTest { @@ -45,7 +54,7 @@ public class FormulaDecoratorTest { public void declareDependencies() { Formula formula = new Formula() { public List<Metric> dependsUponMetrics() { - return Arrays.asList(CoreMetrics.COMPLEXITY, CoreMetrics.COVERAGE); + return Arrays.<Metric>asList(CoreMetrics.COMPLEXITY, CoreMetrics.COVERAGE); } public Measure calculate(FormulaData data, FormulaContext context) { @@ -54,8 +63,7 @@ public class FormulaDecoratorTest { }; Metric metric = new Metric("ncloc").setFormula(formula); List<Metric> dependencies = new FormulaDecorator(metric).dependsUponMetrics(); - assertThat(dependencies, hasItem(CoreMetrics.COMPLEXITY)); - assertThat(dependencies, hasItem(CoreMetrics.COVERAGE)); + assertThat(dependencies).containsOnly(CoreMetrics.COMPLEXITY, CoreMetrics.COVERAGE); } @Test diff --git a/sonar-batch/src/test/java/org/sonar/batch/language/LanguageDistributionDecoratorTest.java b/sonar-batch/src/test/java/org/sonar/batch/language/LanguageDistributionDecoratorTest.java index fadb7e82166..34f728cc232 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/language/LanguageDistributionDecoratorTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/language/LanguageDistributionDecoratorTest.java @@ -40,7 +40,10 @@ import java.util.Collections; import static com.google.common.collect.Lists.newArrayList; import static org.fest.assertions.Assertions.assertThat; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; @RunWith(MockitoJUnitRunner.class) public class LanguageDistributionDecoratorTest { @@ -63,12 +66,12 @@ public class LanguageDistributionDecoratorTest { @Test public void depended_upon_metric() { - assertThat(decorator.generatesMetrics()).hasSize(1); + assertThat(decorator.generatesMetric()).isEqualTo(CoreMetrics.NCLOC_LANGUAGE_DISTRIBUTION); } @Test public void depens_upon_metric() { - assertThat(decorator.dependsUponMetrics()).hasSize(1); + assertThat(decorator.dependsUponMetric()).isEqualTo(CoreMetrics.LINES); } @Test @@ -96,7 +99,7 @@ public class LanguageDistributionDecoratorTest { new Measure(CoreMetrics.NCLOC_LANGUAGE_DISTRIBUTION, KeyValueFormat.format(ImmutableMap.of("java", 20))), new Measure(CoreMetrics.NCLOC_LANGUAGE_DISTRIBUTION, KeyValueFormat.format(ImmutableMap.of("xoo", 150))), new Measure(CoreMetrics.NCLOC_LANGUAGE_DISTRIBUTION, KeyValueFormat.format(ImmutableMap.of("xoo", 50))) - )); + )); decorator.decorate(resource, context); diff --git a/sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractFileComplexityDecorator.java b/sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractFileComplexityDecorator.java index 16406c7afdf..9099c22a495 100644 --- a/sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractFileComplexityDecorator.java +++ b/sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractFileComplexityDecorator.java @@ -58,7 +58,7 @@ public abstract class AbstractFileComplexityDecorator implements Decorator { */ @DependsUpon public List<Metric> dependsUponFileAndComplexityMetrics() { - return Arrays.asList(CoreMetrics.FILES, CoreMetrics.COMPLEXITY); + return Arrays.<Metric>asList(CoreMetrics.FILES, CoreMetrics.COMPLEXITY); } /** diff --git a/sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractFunctionComplexityDecorator.java b/sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractFunctionComplexityDecorator.java index e2a995935c8..ab7103bf6d2 100644 --- a/sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractFunctionComplexityDecorator.java +++ b/sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractFunctionComplexityDecorator.java @@ -57,7 +57,7 @@ public abstract class AbstractFunctionComplexityDecorator implements Decorator { */ @DependsUpon public List<Metric> dependsUponFileAndComplexityMetrics() { - return Arrays.asList(CoreMetrics.FUNCTIONS, CoreMetrics.COMPLEXITY); + return Arrays.<Metric>asList(CoreMetrics.FUNCTIONS, CoreMetrics.COMPLEXITY); } /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/AnalyzerDescriptor.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/AnalyzerDescriptor.java index 8038bac43ce..1a06563949d 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/AnalyzerDescriptor.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/AnalyzerDescriptor.java @@ -19,10 +19,9 @@ */ package org.sonar.api.batch.analyzer; -import org.sonar.api.batch.measure.Metric; - import com.google.common.annotations.Beta; import org.sonar.api.batch.fs.InputFile; +import org.sonar.api.batch.measure.Metric; /** * Describe what an {@link Analyzer} is doing. Information may be used by the platform @@ -57,7 +56,7 @@ public interface AnalyzerDescriptor { /** * List {@link InputFile.Type} this {@link Analyzer} work on. May be used by the platform to skip execution of the {@link Analyzer} when * no file for given type are present in the project. - * If not type is provided then t will be executed for all types. + * If not type is provided then it will be executed for all types. */ AnalyzerDescriptor runOnTypes(InputFile.Type... types); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/issue/AnalyzerIssueBuilder.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/issue/AnalyzerIssueBuilder.java index 0955c953725..12969a5f574 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/issue/AnalyzerIssueBuilder.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/issue/AnalyzerIssueBuilder.java @@ -49,12 +49,12 @@ public interface AnalyzerIssueBuilder { AnalyzerIssueBuilder onProject(); /** - * Line of the issue. + * Line of the issue. If no line is specified then issue is supposed to be global to the file. */ AnalyzerIssueBuilder atLine(int line); /** - * Effort to fix for the issue. + * Effort to fix the issue. */ AnalyzerIssueBuilder effortToFix(@Nullable Double effortToFix); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/issue/internal/DefaultAnalyzerIssue.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/issue/internal/DefaultAnalyzerIssue.java index 7b10db79945..92a51acd100 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/issue/internal/DefaultAnalyzerIssue.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/issue/internal/DefaultAnalyzerIssue.java @@ -19,6 +19,7 @@ */ package org.sonar.api.batch.analyzer.issue.internal; +import com.google.common.base.Preconditions; import org.sonar.api.batch.analyzer.issue.AnalyzerIssue; import org.sonar.api.batch.fs.InputFile; import org.sonar.api.rule.RuleKey; @@ -36,6 +37,7 @@ public class DefaultAnalyzerIssue implements AnalyzerIssue, Serializable { private final Double effortToFix; DefaultAnalyzerIssue(DefaultAnalyzerIssueBuilder builder) { + Preconditions.checkNotNull(builder.ruleKey, "ruleKey is mandatory on issue"); this.inputFile = builder.file; this.ruleKey = builder.ruleKey; this.message = builder.message; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/issue/internal/DefaultAnalyzerIssueBuilder.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/issue/internal/DefaultAnalyzerIssueBuilder.java index 7092caa368d..d56ecaf1bca 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/issue/internal/DefaultAnalyzerIssueBuilder.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/issue/internal/DefaultAnalyzerIssueBuilder.java @@ -44,21 +44,24 @@ public class DefaultAnalyzerIssueBuilder implements AnalyzerIssueBuilder { @Override public DefaultAnalyzerIssueBuilder onFile(InputFile file) { - Preconditions.checkState(onProject == null, "onFile or onProject can be called only once"); + onProject(false); Preconditions.checkNotNull(file, "InputFile should be non null"); this.file = file; - this.onProject = false; return this; } @Override public DefaultAnalyzerIssueBuilder onProject() { - Preconditions.checkState(onProject == null, "onFile or onProject can be called only once"); + onProject(true); this.file = null; - this.onProject = true; return this; } + private void onProject(boolean isOnProject) { + Preconditions.checkState(this.onProject == null, "onFile or onProject can be called only once"); + this.onProject = isOnProject; + } + @Override public DefaultAnalyzerIssueBuilder atLine(int line) { this.line = line; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/issue/internal/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/issue/internal/package-info.java index 382a419c6d7..61cb3773bcf 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/issue/internal/package-info.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/issue/internal/package-info.java @@ -17,11 +17,5 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -/** - * - */ -/** - * @author julien - * - */ +@javax.annotation.ParametersAreNonnullByDefault package org.sonar.api.batch.analyzer.issue.internal;
\ No newline at end of file diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/measure/internal/DefaultAnalyzerMeasureBuilder.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/measure/internal/DefaultAnalyzerMeasureBuilder.java index c482d1f5166..e47c949ff52 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/measure/internal/DefaultAnalyzerMeasureBuilder.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/measure/internal/DefaultAnalyzerMeasureBuilder.java @@ -19,12 +19,11 @@ */ package org.sonar.api.batch.analyzer.measure.internal; -import org.sonar.api.batch.measure.Metric; - import com.google.common.base.Preconditions; import org.sonar.api.batch.analyzer.measure.AnalyzerMeasure; import org.sonar.api.batch.analyzer.measure.AnalyzerMeasureBuilder; import org.sonar.api.batch.fs.InputFile; +import org.sonar.api.batch.measure.Metric; import java.io.Serializable; @@ -37,21 +36,24 @@ public class DefaultAnalyzerMeasureBuilder<G extends Serializable> implements An @Override public AnalyzerMeasureBuilder<G> onFile(InputFile inputFile) { - Preconditions.checkState(onProject == null, "onFile or onProject can be called only once"); + onProject(false); Preconditions.checkNotNull(inputFile, "inputFile should be non null"); this.file = inputFile; - this.onProject = false; return this; } @Override public AnalyzerMeasureBuilder<G> onProject() { - Preconditions.checkState(onProject == null, "onFile or onProject can be called only once"); + onProject(true); this.file = null; - this.onProject = true; return this; } + private void onProject(boolean isOnProject) { + Preconditions.checkState(this.onProject == null, "onFile or onProject can be called only once"); + this.onProject = isOnProject; + } + @Override public AnalyzerMeasureBuilder<G> forMetric(Metric<G> metric) { Preconditions.checkState(metric != null, "Metric already defined"); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java index f94a4345af2..eb0c7ccb409 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java @@ -70,7 +70,7 @@ public final class CoreMetrics { .create(); public static final String GENERATED_LINES_KEY = "generated_lines"; - public static final Metric GENERATED_LINES = new Metric.Builder(GENERATED_LINES_KEY, "Generated Lines", Metric.ValueType.INT) + public static final Metric<Integer> GENERATED_LINES = new Metric.Builder(GENERATED_LINES_KEY, "Generated Lines", Metric.ValueType.INT) .setDescription("Number of generated lines") .setDirection(Metric.DIRECTION_WORST) .setQualitative(false) @@ -81,7 +81,7 @@ public final class CoreMetrics { .create(); public static final String NCLOC_KEY = "ncloc"; - public static final Metric NCLOC = new Metric.Builder(NCLOC_KEY, "Lines of code", Metric.ValueType.INT) + public static final Metric<Integer> NCLOC = new Metric.Builder(NCLOC_KEY, "Lines of code", Metric.ValueType.INT) .setDescription("Non Commenting Lines of Code") .setDirection(Metric.DIRECTION_WORST) .setQualitative(false) @@ -97,7 +97,7 @@ public final class CoreMetrics { /** * @since 4.4 */ - public static final Metric NCLOC_LANGUAGE_DISTRIBUTION = new Metric.Builder(NCLOC_LANGUAGE_DISTRIBUTION_KEY, "Lines of code per language", Metric.ValueType.DATA) + public static final Metric<String> NCLOC_LANGUAGE_DISTRIBUTION = new Metric.Builder(NCLOC_LANGUAGE_DISTRIBUTION_KEY, "Lines of code per language", Metric.ValueType.DATA) .setDescription("Non Commenting Lines of Code Distributed By Language") .setDirection(Metric.DIRECTION_WORST) .setQualitative(false) @@ -105,7 +105,7 @@ public final class CoreMetrics { .create(); public static final String GENERATED_NCLOC_KEY = "generated_ncloc"; - public static final Metric GENERATED_NCLOC = new Metric.Builder(GENERATED_NCLOC_KEY, "Generated lines of code", Metric.ValueType.INT) + public static final Metric<Integer> GENERATED_NCLOC = new Metric.Builder(GENERATED_NCLOC_KEY, "Generated lines of code", Metric.ValueType.INT) .setDescription("Generated non Commenting Lines of Code") .setDirection(Metric.DIRECTION_WORST) .setQualitative(false) @@ -116,7 +116,7 @@ public final class CoreMetrics { .create(); public static final String CLASSES_KEY = "classes"; - public static final Metric CLASSES = new Metric.Builder(CLASSES_KEY, "Classes", Metric.ValueType.INT) + public static final Metric<Integer> CLASSES = new Metric.Builder(CLASSES_KEY, "Classes", Metric.ValueType.INT) .setDescription("Classes") .setDirection(Metric.DIRECTION_WORST) .setQualitative(false) @@ -125,7 +125,7 @@ public final class CoreMetrics { .create(); public static final String FILES_KEY = "files"; - public static final Metric FILES = new Metric.Builder(FILES_KEY, "Files", Metric.ValueType.INT) + public static final Metric<Integer> FILES = new Metric.Builder(FILES_KEY, "Files", Metric.ValueType.INT) .setDescription("Number of files") .setDirection(Metric.DIRECTION_WORST) .setQualitative(false) @@ -133,7 +133,7 @@ public final class CoreMetrics { .create(); public static final String DIRECTORIES_KEY = "directories"; - public static final Metric DIRECTORIES = new Metric.Builder(DIRECTORIES_KEY, "Directories", Metric.ValueType.INT) + public static final Metric<Integer> DIRECTORIES = new Metric.Builder(DIRECTORIES_KEY, "Directories", Metric.ValueType.INT) .setDescription("Directories") .setDirection(Metric.DIRECTION_WORST) .setQualitative(false) @@ -149,7 +149,7 @@ public final class CoreMetrics { * @deprecated since 4.2 there is now only directory */ @Deprecated - public static final Metric PACKAGES = new Metric.Builder(PACKAGES_KEY, "Packages", Metric.ValueType.INT) + public static final Metric<Integer> PACKAGES = new Metric.Builder(PACKAGES_KEY, "Packages", Metric.ValueType.INT) .setDescription("Packages") .setDirection(Metric.DIRECTION_WORST) .setQualitative(false) @@ -159,7 +159,7 @@ public final class CoreMetrics { .create(); public static final String FUNCTIONS_KEY = "functions"; - public static final Metric FUNCTIONS = new Metric.Builder(FUNCTIONS_KEY, "Functions", Metric.ValueType.INT) + public static final Metric<Integer> FUNCTIONS = new Metric.Builder(FUNCTIONS_KEY, "Functions", Metric.ValueType.INT) .setDescription("Functions") .setDirection(Metric.DIRECTION_WORST) .setQualitative(false) @@ -168,7 +168,7 @@ public final class CoreMetrics { .create(); public static final String ACCESSORS_KEY = "accessors"; - public static final Metric ACCESSORS = new Metric.Builder(ACCESSORS_KEY, "Accessors", Metric.ValueType.INT) + public static final Metric<Integer> ACCESSORS = new Metric.Builder(ACCESSORS_KEY, "Accessors", Metric.ValueType.INT) .setDescription("Accessors") .setDirection(Metric.DIRECTION_WORST) .setQualitative(false) @@ -177,7 +177,7 @@ public final class CoreMetrics { .create(); public static final String STATEMENTS_KEY = "statements"; - public static final Metric STATEMENTS = new Metric.Builder(STATEMENTS_KEY, "Statements", Metric.ValueType.INT) + public static final Metric<Integer> STATEMENTS = new Metric.Builder(STATEMENTS_KEY, "Statements", Metric.ValueType.INT) .setDescription("Number of statements") .setDirection(Metric.DIRECTION_WORST) .setQualitative(false) @@ -186,7 +186,7 @@ public final class CoreMetrics { .create(); public static final String PUBLIC_API_KEY = "public_api"; - public static final Metric PUBLIC_API = new Metric.Builder(PUBLIC_API_KEY, "Public API", Metric.ValueType.INT) + public static final Metric<Integer> PUBLIC_API = new Metric.Builder(PUBLIC_API_KEY, "Public API", Metric.ValueType.INT) .setDescription("Public API") .setDirection(Metric.DIRECTION_WORST) .setQualitative(false) @@ -202,7 +202,7 @@ public final class CoreMetrics { /** * @since 3.0 */ - public static final Metric PROJECTS = new Metric.Builder(PROJECTS_KEY, "Projects", Metric.ValueType.INT) + public static final Metric<Integer> PROJECTS = new Metric.Builder(PROJECTS_KEY, "Projects", Metric.ValueType.INT) .setDescription("Number of projects") .setDirection(Metric.DIRECTION_WORST) .setQualitative(false) @@ -216,7 +216,7 @@ public final class CoreMetrics { // -------------------------------------------------------------------------------------------------------------------- public static final String COMMENT_LINES_KEY = "comment_lines"; - public static final Metric COMMENT_LINES = new Metric.Builder(COMMENT_LINES_KEY, "Comment lines", Metric.ValueType.INT) + public static final Metric<Integer> COMMENT_LINES = new Metric.Builder(COMMENT_LINES_KEY, "Comment lines", Metric.ValueType.INT) .setDescription("Number of comment lines") .setDirection(Metric.DIRECTION_BETTER) .setQualitative(false) @@ -225,7 +225,7 @@ public final class CoreMetrics { .create(); public static final String COMMENT_LINES_DENSITY_KEY = "comment_lines_density"; - public static final Metric COMMENT_LINES_DENSITY = new Metric.Builder(COMMENT_LINES_DENSITY_KEY, "Comments (%)", Metric.ValueType.PERCENT) + public static final Metric<Double> COMMENT_LINES_DENSITY = new Metric.Builder(COMMENT_LINES_DENSITY_KEY, "Comments (%)", Metric.ValueType.PERCENT) .setDescription("Comments balanced by ncloc + comment lines") .setDirection(Metric.DIRECTION_BETTER) .setQualitative(true) @@ -242,7 +242,7 @@ public final class CoreMetrics { * @deprecated since 3.3 - see SONAR-3768 */ @Deprecated - public static final Metric COMMENT_BLANK_LINES = new Metric.Builder(COMMENT_BLANK_LINES_KEY, "Blank comments", Metric.ValueType.INT) + public static final Metric<Integer> COMMENT_BLANK_LINES = new Metric.Builder(COMMENT_BLANK_LINES_KEY, "Blank comments", Metric.ValueType.INT) .setDescription("Comments that do not contain comments") .setDirection(Metric.DIRECTION_WORST) .setQualitative(false) @@ -254,7 +254,7 @@ public final class CoreMetrics { .create(); public static final String PUBLIC_DOCUMENTED_API_DENSITY_KEY = "public_documented_api_density"; - public static final Metric PUBLIC_DOCUMENTED_API_DENSITY = new Metric.Builder(PUBLIC_DOCUMENTED_API_DENSITY_KEY, "Public documented API (%)", Metric.ValueType.PERCENT) + public static final Metric<Double> PUBLIC_DOCUMENTED_API_DENSITY = new Metric.Builder(PUBLIC_DOCUMENTED_API_DENSITY_KEY, "Public documented API (%)", Metric.ValueType.PERCENT) .setDescription("Public documented classes and functions balanced by ncloc") .setDirection(Metric.DIRECTION_BETTER) .setQualitative(true) @@ -265,7 +265,7 @@ public final class CoreMetrics { .create(); public static final String PUBLIC_UNDOCUMENTED_API_KEY = "public_undocumented_api"; - public static final Metric PUBLIC_UNDOCUMENTED_API = new Metric.Builder(PUBLIC_UNDOCUMENTED_API_KEY, "Public undocumented API", Metric.ValueType.INT) + public static final Metric<Integer> PUBLIC_UNDOCUMENTED_API = new Metric.Builder(PUBLIC_UNDOCUMENTED_API_KEY, "Public undocumented API", Metric.ValueType.INT) .setDescription("Public undocumented classes, functions and variables") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -286,7 +286,7 @@ public final class CoreMetrics { * @deprecated since 4.2 - see SONAR-4990 */ @Deprecated - public static final Metric COMMENTED_OUT_CODE_LINES = new Metric.Builder(COMMENTED_OUT_CODE_LINES_KEY, "Commented-out LOC", Metric.ValueType.INT) + public static final Metric<Integer> COMMENTED_OUT_CODE_LINES = new Metric.Builder(COMMENTED_OUT_CODE_LINES_KEY, "Commented-out LOC", Metric.ValueType.INT) .setDescription("Commented lines of code") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -304,7 +304,7 @@ public final class CoreMetrics { // -------------------------------------------------------------------------------------------------------------------- public static final String COMPLEXITY_KEY = "complexity"; - public static final Metric COMPLEXITY = new Metric.Builder(COMPLEXITY_KEY, "Complexity", Metric.ValueType.INT) + public static final Metric<Integer> COMPLEXITY = new Metric.Builder(COMPLEXITY_KEY, "Complexity", Metric.ValueType.INT) .setDescription("Cyclomatic complexity") .setDirection(Metric.DIRECTION_WORST) .setQualitative(false) @@ -313,7 +313,7 @@ public final class CoreMetrics { .create(); public static final String FILE_COMPLEXITY_KEY = "file_complexity"; - public static final Metric FILE_COMPLEXITY = new Metric.Builder(FILE_COMPLEXITY_KEY, "Complexity /file", Metric.ValueType.FLOAT) + public static final Metric<Double> FILE_COMPLEXITY = new Metric.Builder(FILE_COMPLEXITY_KEY, "Complexity /file", Metric.ValueType.FLOAT) .setDescription("Complexity average by file") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -329,7 +329,7 @@ public final class CoreMetrics { /** * @since 3.6 */ - public static final Metric COMPLEXITY_IN_CLASSES = new Metric.Builder(COMPLEXITY_IN_CLASSES_KEY, "Complexity in classes", Metric.ValueType.INT) + public static final Metric<Integer> COMPLEXITY_IN_CLASSES = new Metric.Builder(COMPLEXITY_IN_CLASSES_KEY, "Complexity in classes", Metric.ValueType.INT) .setDescription("Cyclomatic complexity in classes") .setHidden(true) .setDirection(Metric.DIRECTION_WORST) @@ -345,7 +345,7 @@ public final class CoreMetrics { * Information about the cyclomatic complexity per class, calculated by divided the complexity in classes by the number of classes. * If the complexity in classes is not available, the complexity of the file is used. */ - public static final Metric CLASS_COMPLEXITY = new Metric.Builder(CLASS_COMPLEXITY_KEY, "Complexity /class", Metric.ValueType.FLOAT) + public static final Metric<Double> CLASS_COMPLEXITY = new Metric.Builder(CLASS_COMPLEXITY_KEY, "Complexity /class", Metric.ValueType.FLOAT) .setDescription("Complexity average by class") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -361,7 +361,7 @@ public final class CoreMetrics { /** * @since 3.6 */ - public static final Metric COMPLEXITY_IN_FUNCTIONS = new Metric.Builder(COMPLEXITY_IN_FUNCTIONS_KEY, "Complexity in functions", Metric.ValueType.INT) + public static final Metric<Integer> COMPLEXITY_IN_FUNCTIONS = new Metric.Builder(COMPLEXITY_IN_FUNCTIONS_KEY, "Complexity in functions", Metric.ValueType.INT) .setDescription("Cyclomatic complexity in functions") .setHidden(true) .setDirection(Metric.DIRECTION_WORST) @@ -377,7 +377,7 @@ public final class CoreMetrics { * Information about the cyclomatic complexity per function, calculated by divided the complexity in functions by the number of functions. * If the complexity in functions is not available, the complexity of the file is used. */ - public static final Metric FUNCTION_COMPLEXITY = new Metric.Builder(FUNCTION_COMPLEXITY_KEY, "Complexity /function", Metric.ValueType.FLOAT) + public static final Metric<Double> FUNCTION_COMPLEXITY = new Metric.Builder(FUNCTION_COMPLEXITY_KEY, "Complexity /function", Metric.ValueType.FLOAT) .setDescription("Complexity average by function") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -395,7 +395,8 @@ public final class CoreMetrics { * @deprecated in 3.0 - see SONAR-3289 */ @Deprecated - public static final Metric CLASS_COMPLEXITY_DISTRIBUTION = new Metric.Builder(CLASS_COMPLEXITY_DISTRIBUTION_KEY, "Classes distribution /complexity", Metric.ValueType.DISTRIB) + public static final Metric<String> CLASS_COMPLEXITY_DISTRIBUTION = new Metric.Builder(CLASS_COMPLEXITY_DISTRIBUTION_KEY, "Classes distribution /complexity", + Metric.ValueType.DISTRIB) .setDescription("Classes distribution /complexity") .setDirection(Metric.DIRECTION_NONE) .setQualitative(true) @@ -405,7 +406,7 @@ public final class CoreMetrics { .create(); public static final String FUNCTION_COMPLEXITY_DISTRIBUTION_KEY = "function_complexity_distribution"; - public static final Metric FUNCTION_COMPLEXITY_DISTRIBUTION = new Metric.Builder(FUNCTION_COMPLEXITY_DISTRIBUTION_KEY, "Functions distribution /complexity", + public static final Metric<String> FUNCTION_COMPLEXITY_DISTRIBUTION = new Metric.Builder(FUNCTION_COMPLEXITY_DISTRIBUTION_KEY, "Functions distribution /complexity", Metric.ValueType.DISTRIB) .setDescription("Functions distribution /complexity") .setDirection(Metric.DIRECTION_NONE) @@ -415,7 +416,7 @@ public final class CoreMetrics { .create(); public static final String FILE_COMPLEXITY_DISTRIBUTION_KEY = "file_complexity_distribution"; - public static final Metric FILE_COMPLEXITY_DISTRIBUTION = new Metric.Builder(FILE_COMPLEXITY_DISTRIBUTION_KEY, "Files distribution /complexity", Metric.ValueType.DISTRIB) + public static final Metric<String> FILE_COMPLEXITY_DISTRIBUTION = new Metric.Builder(FILE_COMPLEXITY_DISTRIBUTION_KEY, "Files distribution /complexity", Metric.ValueType.DISTRIB) .setDescription("Files distribution /complexity") .setDirection(Metric.DIRECTION_NONE) .setQualitative(true) @@ -440,7 +441,7 @@ public final class CoreMetrics { * <li>Should include {@link #TEST_FAILURES} and {@link #TEST_ERRORS}, but should not include {@link #SKIPPED_TESTS}.</li> * </ul> */ - public static final Metric TESTS = new Metric.Builder(TESTS_KEY, "Unit tests", Metric.ValueType.INT) + public static final Metric<Integer> TESTS = new Metric.Builder(TESTS_KEY, "Unit tests", Metric.ValueType.INT) .setDescription("Number of unit tests") .setDirection(Metric.DIRECTION_WORST) .setQualitative(false) @@ -448,7 +449,7 @@ public final class CoreMetrics { .create(); public static final String TEST_EXECUTION_TIME_KEY = "test_execution_time"; - public static final Metric TEST_EXECUTION_TIME = new Metric.Builder(TEST_EXECUTION_TIME_KEY, "Unit tests duration", Metric.ValueType.MILLISEC) + public static final Metric<Integer> TEST_EXECUTION_TIME = new Metric.Builder(TEST_EXECUTION_TIME_KEY, "Unit tests duration", Metric.ValueType.MILLISEC) .setDescription("Execution duration of unit tests") .setDirection(Metric.DIRECTION_WORST) .setQualitative(false) @@ -456,7 +457,7 @@ public final class CoreMetrics { .create(); public static final String TEST_ERRORS_KEY = "test_errors"; - public static final Metric TEST_ERRORS = new Metric.Builder(TEST_ERRORS_KEY, "Unit test errors", Metric.ValueType.INT) + public static final Metric<Integer> TEST_ERRORS = new Metric.Builder(TEST_ERRORS_KEY, "Unit test errors", Metric.ValueType.INT) .setDescription("Number of unit test errors") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -466,7 +467,7 @@ public final class CoreMetrics { .create(); public static final String SKIPPED_TESTS_KEY = "skipped_tests"; - public static final Metric SKIPPED_TESTS = new Metric.Builder(SKIPPED_TESTS_KEY, "Skipped unit tests", Metric.ValueType.INT) + public static final Metric<Integer> SKIPPED_TESTS = new Metric.Builder(SKIPPED_TESTS_KEY, "Skipped unit tests", Metric.ValueType.INT) .setDescription("Number of skipped unit tests") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -476,7 +477,7 @@ public final class CoreMetrics { .create(); public static final String TEST_FAILURES_KEY = "test_failures"; - public static final Metric TEST_FAILURES = new Metric.Builder(TEST_FAILURES_KEY, "Unit test failures", Metric.ValueType.INT) + public static final Metric<Integer> TEST_FAILURES = new Metric.Builder(TEST_FAILURES_KEY, "Unit test failures", Metric.ValueType.INT) .setDescription("Number of unit test failures") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -486,7 +487,7 @@ public final class CoreMetrics { .create(); public static final String TEST_SUCCESS_DENSITY_KEY = "test_success_density"; - public static final Metric TEST_SUCCESS_DENSITY = new Metric.Builder(TEST_SUCCESS_DENSITY_KEY, "Unit test success (%)", Metric.ValueType.PERCENT) + public static final Metric<Double> TEST_SUCCESS_DENSITY = new Metric.Builder(TEST_SUCCESS_DENSITY_KEY, "Unit test success (%)", Metric.ValueType.PERCENT) .setDescription("Density of successful unit tests") .setDirection(Metric.DIRECTION_BETTER) .setQualitative(true) @@ -497,14 +498,14 @@ public final class CoreMetrics { .create(); public static final String TEST_DATA_KEY = "test_data"; - public static final Metric TEST_DATA = new Metric.Builder(TEST_DATA_KEY, "Unit tests details", Metric.ValueType.DATA) + public static final Metric<String> TEST_DATA = new Metric.Builder(TEST_DATA_KEY, "Unit tests details", Metric.ValueType.DATA) .setDescription("Unit tests details") .setDirection(Metric.DIRECTION_WORST) .setDomain(DOMAIN_TESTS) .create(); public static final String COVERAGE_KEY = "coverage"; - public static final Metric COVERAGE = new Metric.Builder(COVERAGE_KEY, "Coverage", Metric.ValueType.PERCENT) + public static final Metric<Double> COVERAGE = new Metric.Builder(COVERAGE_KEY, "Coverage", Metric.ValueType.PERCENT) .setDescription("Coverage by unit tests") .setDirection(Metric.DIRECTION_BETTER) .setQualitative(true) @@ -514,7 +515,7 @@ public final class CoreMetrics { .create(); public static final String NEW_COVERAGE_KEY = "new_coverage"; - public static final Metric NEW_COVERAGE = new Metric.Builder(NEW_COVERAGE_KEY, "Coverage on new code", Metric.ValueType.PERCENT) + public static final Metric<Double> NEW_COVERAGE = new Metric.Builder(NEW_COVERAGE_KEY, "Coverage on new code", Metric.ValueType.PERCENT) .setDescription("Coverage of new/changed code") .setDirection(Metric.DIRECTION_BETTER) .setQualitative(true) @@ -529,7 +530,7 @@ public final class CoreMetrics { /** * Use {@link CoverageMeasuresBuilder} to build measure for this metric. */ - public static final Metric LINES_TO_COVER = new Metric.Builder(LINES_TO_COVER_KEY, "Lines to cover", Metric.ValueType.INT) + public static final Metric<Integer> LINES_TO_COVER = new Metric.Builder(LINES_TO_COVER_KEY, "Lines to cover", Metric.ValueType.INT) .setDescription("Lines to cover") .setDirection(Metric.DIRECTION_BETTER) .setQualitative(false) @@ -538,7 +539,7 @@ public final class CoreMetrics { .create(); public static final String NEW_LINES_TO_COVER_KEY = "new_lines_to_cover"; - public static final Metric NEW_LINES_TO_COVER = new Metric.Builder(NEW_LINES_TO_COVER_KEY, "Lines to cover on new code", Metric.ValueType.INT) + public static final Metric<Integer> NEW_LINES_TO_COVER = new Metric.Builder(NEW_LINES_TO_COVER_KEY, "Lines to cover on new code", Metric.ValueType.INT) .setDescription("Lines to cover on new code") .setDirection(Metric.DIRECTION_WORST) .setQualitative(false) @@ -552,7 +553,7 @@ public final class CoreMetrics { /** * Use {@link CoverageMeasuresBuilder} to build measure for this metric. */ - public static final Metric UNCOVERED_LINES = new Metric.Builder(UNCOVERED_LINES_KEY, "Uncovered lines", Metric.ValueType.INT) + public static final Metric<Integer> UNCOVERED_LINES = new Metric.Builder(UNCOVERED_LINES_KEY, "Uncovered lines", Metric.ValueType.INT) .setDescription("Uncovered lines") .setDirection(Metric.DIRECTION_WORST) .setDomain(DOMAIN_TESTS) @@ -561,7 +562,7 @@ public final class CoreMetrics { .create(); public static final String NEW_UNCOVERED_LINES_KEY = "new_uncovered_lines"; - public static final Metric NEW_UNCOVERED_LINES = new Metric.Builder(NEW_UNCOVERED_LINES_KEY, "Uncovered lines on new code", Metric.ValueType.INT) + public static final Metric<Integer> NEW_UNCOVERED_LINES = new Metric.Builder(NEW_UNCOVERED_LINES_KEY, "Uncovered lines on new code", Metric.ValueType.INT) .setDescription("Uncovered lines on new code") .setDirection(Metric.DIRECTION_WORST) .setDomain(DOMAIN_TESTS) @@ -571,7 +572,7 @@ public final class CoreMetrics { .create(); public static final String LINE_COVERAGE_KEY = "line_coverage"; - public static final Metric LINE_COVERAGE = new Metric.Builder(LINE_COVERAGE_KEY, "Line coverage", Metric.ValueType.PERCENT) + public static final Metric<Double> LINE_COVERAGE = new Metric.Builder(LINE_COVERAGE_KEY, "Line coverage", Metric.ValueType.PERCENT) .setDescription("Line coverage") .setDirection(Metric.DIRECTION_BETTER) .setQualitative(true) @@ -581,7 +582,7 @@ public final class CoreMetrics { .create(); public static final String NEW_LINE_COVERAGE_KEY = "new_line_coverage"; - public static final Metric NEW_LINE_COVERAGE = new Metric.Builder(NEW_LINE_COVERAGE_KEY, "Line coverage on new code", Metric.ValueType.PERCENT) + public static final Metric<Double> NEW_LINE_COVERAGE = new Metric.Builder(NEW_LINE_COVERAGE_KEY, "Line coverage on new code", Metric.ValueType.PERCENT) .setDescription("Line coverage of added/changed code") .setDirection(Metric.DIRECTION_BETTER) .setQualitative(true) @@ -597,7 +598,7 @@ public final class CoreMetrics { * Key-value pairs, where key - is a number of line, and value - is a number of hits for this line. * Use {@link CoverageMeasuresBuilder} to build measure for this metric. */ - public static final Metric COVERAGE_LINE_HITS_DATA = new Metric.Builder(COVERAGE_LINE_HITS_DATA_KEY, "Coverage hits by line", Metric.ValueType.DATA) + public static final Metric<String> COVERAGE_LINE_HITS_DATA = new Metric.Builder(COVERAGE_LINE_HITS_DATA_KEY, "Coverage hits by line", Metric.ValueType.DATA) .setDomain(DOMAIN_TESTS) .setDeleteHistoricalData(true) .create(); @@ -607,7 +608,7 @@ public final class CoreMetrics { /** * Use {@link CoverageMeasuresBuilder} to build measure for this metric. */ - public static final Metric CONDITIONS_TO_COVER = new Metric.Builder(CONDITIONS_TO_COVER_KEY, "Branches to cover", Metric.ValueType.INT) + public static final Metric<Integer> CONDITIONS_TO_COVER = new Metric.Builder(CONDITIONS_TO_COVER_KEY, "Branches to cover", Metric.ValueType.INT) .setDescription("Branches to cover") .setDomain(DOMAIN_TESTS) .setFormula(new SumChildValuesFormula(false)) @@ -615,7 +616,7 @@ public final class CoreMetrics { .create(); public static final String NEW_CONDITIONS_TO_COVER_KEY = "new_conditions_to_cover"; - public static final Metric NEW_CONDITIONS_TO_COVER = new Metric.Builder(NEW_CONDITIONS_TO_COVER_KEY, "Branches to cover on new code", Metric.ValueType.INT) + public static final Metric<Integer> NEW_CONDITIONS_TO_COVER = new Metric.Builder(NEW_CONDITIONS_TO_COVER_KEY, "Branches to cover on new code", Metric.ValueType.INT) .setDescription("Branches to cover on new code") .setDomain(DOMAIN_TESTS) .setFormula(new SumChildValuesFormula(false)) @@ -628,7 +629,7 @@ public final class CoreMetrics { /** * Use {@link CoverageMeasuresBuilder} to build measure for this metric. */ - public static final Metric UNCOVERED_CONDITIONS = new Metric.Builder(UNCOVERED_CONDITIONS_KEY, "Uncovered branches", Metric.ValueType.INT) + public static final Metric<Integer> UNCOVERED_CONDITIONS = new Metric.Builder(UNCOVERED_CONDITIONS_KEY, "Uncovered branches", Metric.ValueType.INT) .setDescription("Uncovered branches") .setDirection(Metric.DIRECTION_WORST) .setDomain(DOMAIN_TESTS) @@ -637,7 +638,7 @@ public final class CoreMetrics { .create(); public static final String NEW_UNCOVERED_CONDITIONS_KEY = "new_uncovered_conditions"; - public static final Metric NEW_UNCOVERED_CONDITIONS = new Metric.Builder(NEW_UNCOVERED_CONDITIONS_KEY, "Uncovered branches on new code", Metric.ValueType.INT) + public static final Metric<Integer> NEW_UNCOVERED_CONDITIONS = new Metric.Builder(NEW_UNCOVERED_CONDITIONS_KEY, "Uncovered branches on new code", Metric.ValueType.INT) .setDescription("Uncovered branches on new code") .setDirection(Metric.DIRECTION_WORST) .setDomain(DOMAIN_TESTS) @@ -647,7 +648,7 @@ public final class CoreMetrics { .create(); public static final String BRANCH_COVERAGE_KEY = "branch_coverage"; - public static final Metric BRANCH_COVERAGE = new Metric.Builder(BRANCH_COVERAGE_KEY, "Branch coverage", Metric.ValueType.PERCENT) + public static final Metric<Double> BRANCH_COVERAGE = new Metric.Builder(BRANCH_COVERAGE_KEY, "Branch coverage", Metric.ValueType.PERCENT) .setDescription("Branch coverage") .setDirection(Metric.DIRECTION_BETTER) .setQualitative(true) @@ -657,7 +658,7 @@ public final class CoreMetrics { .create(); public static final String NEW_BRANCH_COVERAGE_KEY = "new_branch_coverage"; - public static final Metric NEW_BRANCH_COVERAGE = new Metric.Builder(NEW_BRANCH_COVERAGE_KEY, "Branch coverage on new code", Metric.ValueType.PERCENT) + public static final Metric<Double> NEW_BRANCH_COVERAGE = new Metric.Builder(NEW_BRANCH_COVERAGE_KEY, "Branch coverage on new code", Metric.ValueType.PERCENT) .setDescription("Branch coverage of new/changed code") .setDirection(Metric.DIRECTION_BETTER) .setQualitative(true) @@ -674,7 +675,7 @@ public final class CoreMetrics { * * @since 2.7 */ - public static final Metric CONDITIONS_BY_LINE = new Metric.Builder(CONDITIONS_BY_LINE_KEY, "Conditions by line", Metric.ValueType.DATA) + public static final Metric<String> CONDITIONS_BY_LINE = new Metric.Builder(CONDITIONS_BY_LINE_KEY, "Conditions by line", Metric.ValueType.DATA) .setDomain(DOMAIN_TESTS) .setDeleteHistoricalData(true) .create(); @@ -686,7 +687,7 @@ public final class CoreMetrics { * * @since 2.7 */ - public static final Metric COVERED_CONDITIONS_BY_LINE = new Metric.Builder(COVERED_CONDITIONS_BY_LINE_KEY, "Covered conditions by line", Metric.ValueType.DATA) + public static final Metric<String> COVERED_CONDITIONS_BY_LINE = new Metric.Builder(COVERED_CONDITIONS_BY_LINE_KEY, "Covered conditions by line", Metric.ValueType.DATA) .setDomain(DOMAIN_TESTS) .setDeleteHistoricalData(true) .create(); @@ -705,7 +706,7 @@ public final class CoreMetrics { /** * @since 2.12 */ - public static final Metric IT_COVERAGE = new Metric.Builder(IT_COVERAGE_KEY, "IT coverage", Metric.ValueType.PERCENT) + public static final Metric<Double> IT_COVERAGE = new Metric.Builder(IT_COVERAGE_KEY, "IT coverage", Metric.ValueType.PERCENT) .setDescription("Coverage by integration tests") .setDirection(Metric.DIRECTION_BETTER) .setQualitative(true) @@ -722,7 +723,7 @@ public final class CoreMetrics { /** * @since 2.12 */ - public static final Metric NEW_IT_COVERAGE = new Metric.Builder(NEW_IT_COVERAGE_KEY, "Coverage by IT on new code", Metric.ValueType.PERCENT) + public static final Metric<Double> NEW_IT_COVERAGE = new Metric.Builder(NEW_IT_COVERAGE_KEY, "Coverage by IT on new code", Metric.ValueType.PERCENT) .setDescription("Integration Tests Coverage of new/changed code") .setDirection(Metric.DIRECTION_BETTER) .setQualitative(true) @@ -740,7 +741,7 @@ public final class CoreMetrics { /** * @since 2.12 */ - public static final Metric IT_LINES_TO_COVER = new Metric.Builder(IT_LINES_TO_COVER_KEY, "IT lines to cover", Metric.ValueType.INT) + public static final Metric<Integer> IT_LINES_TO_COVER = new Metric.Builder(IT_LINES_TO_COVER_KEY, "IT lines to cover", Metric.ValueType.INT) .setDescription("Lines to cover by Integration Tests") .setDirection(Metric.DIRECTION_BETTER) .setDomain(DOMAIN_INTEGRATION_TESTS) @@ -758,7 +759,7 @@ public final class CoreMetrics { /** * @since 2.12 */ - public static final Metric NEW_IT_LINES_TO_COVER = new Metric.Builder(NEW_IT_LINES_TO_COVER_KEY, "Lines to cover by IT on new code", Metric.ValueType.INT) + public static final Metric<Integer> NEW_IT_LINES_TO_COVER = new Metric.Builder(NEW_IT_LINES_TO_COVER_KEY, "Lines to cover by IT on new code", Metric.ValueType.INT) .setDescription("Lines to cover by Integration Tests on new code") .setDirection(Metric.DIRECTION_WORST) .setQualitative(false) @@ -775,7 +776,7 @@ public final class CoreMetrics { /** * @since 2.12 */ - public static final Metric IT_UNCOVERED_LINES = new Metric.Builder(IT_UNCOVERED_LINES_KEY, "IT uncovered lines", Metric.ValueType.INT) + public static final Metric<Integer> IT_UNCOVERED_LINES = new Metric.Builder(IT_UNCOVERED_LINES_KEY, "IT uncovered lines", Metric.ValueType.INT) .setDescription("IT uncovered lines") .setDirection(Metric.DIRECTION_WORST) .setQualitative(false) @@ -791,7 +792,7 @@ public final class CoreMetrics { /** * @since 2.12 */ - public static final Metric NEW_IT_UNCOVERED_LINES = new Metric.Builder(NEW_IT_UNCOVERED_LINES_KEY, "Uncovered lines by IT on new code", Metric.ValueType.INT) + public static final Metric<Integer> NEW_IT_UNCOVERED_LINES = new Metric.Builder(NEW_IT_UNCOVERED_LINES_KEY, "Uncovered lines by IT on new code", Metric.ValueType.INT) .setDescription("Uncovered lines by IT on new code") .setDirection(Metric.DIRECTION_WORST) .setDomain(DOMAIN_INTEGRATION_TESTS) @@ -808,7 +809,7 @@ public final class CoreMetrics { /** * @since 2.12 */ - public static final Metric IT_LINE_COVERAGE = new Metric.Builder(IT_LINE_COVERAGE_KEY, "IT line coverage", Metric.ValueType.PERCENT) + public static final Metric<Double> IT_LINE_COVERAGE = new Metric.Builder(IT_LINE_COVERAGE_KEY, "IT line coverage", Metric.ValueType.PERCENT) .setDescription("IT line coverage") .setDirection(Metric.DIRECTION_BETTER) .setQualitative(true) @@ -823,7 +824,7 @@ public final class CoreMetrics { /** * @since 2.12 */ - public static final Metric NEW_IT_LINE_COVERAGE = new Metric.Builder(NEW_IT_LINE_COVERAGE_KEY, "Line coverage by IT on new code", Metric.ValueType.PERCENT) + public static final Metric<Double> NEW_IT_LINE_COVERAGE = new Metric.Builder(NEW_IT_LINE_COVERAGE_KEY, "Line coverage by IT on new code", Metric.ValueType.PERCENT) .setDescription("Line Coverage by Integration Tests of added/changed code") .setDirection(Metric.DIRECTION_BETTER) .setQualitative(true) @@ -841,7 +842,7 @@ public final class CoreMetrics { /** * @since 2.12 */ - public static final Metric IT_COVERAGE_LINE_HITS_DATA = new Metric.Builder(IT_COVERAGE_LINE_HITS_DATA_KEY, "IT coverage hits data", Metric.ValueType.DATA) + public static final Metric<String> IT_COVERAGE_LINE_HITS_DATA = new Metric.Builder(IT_COVERAGE_LINE_HITS_DATA_KEY, "IT coverage hits data", Metric.ValueType.DATA) .setDescription("Integration Tests Code coverage line hits data") .setDirection(Metric.DIRECTION_NONE) .setQualitative(false) @@ -857,7 +858,7 @@ public final class CoreMetrics { /** * @since 2.12 */ - public static final Metric IT_CONDITIONS_TO_COVER = new Metric.Builder(IT_CONDITIONS_TO_COVER_KEY, "IT branches to cover", Metric.ValueType.INT) + public static final Metric<Integer> IT_CONDITIONS_TO_COVER = new Metric.Builder(IT_CONDITIONS_TO_COVER_KEY, "IT branches to cover", Metric.ValueType.INT) .setDescription("Integration Tests conditions to cover") .setDirection(Metric.DIRECTION_BETTER) .setQualitative(false) @@ -874,7 +875,7 @@ public final class CoreMetrics { /** * @since 2.12 */ - public static final Metric NEW_IT_CONDITIONS_TO_COVER = new Metric.Builder(NEW_IT_CONDITIONS_TO_COVER_KEY, "Branches to cover by IT on new code", Metric.ValueType.INT) + public static final Metric<Integer> NEW_IT_CONDITIONS_TO_COVER = new Metric.Builder(NEW_IT_CONDITIONS_TO_COVER_KEY, "Branches to cover by IT on new code", Metric.ValueType.INT) .setDescription("Branches to cover by Integration Tests on new code") .setDomain(DOMAIN_INTEGRATION_TESTS) .setFormula(new SumChildValuesFormula(false)) @@ -890,7 +891,7 @@ public final class CoreMetrics { /** * @since 2.12 */ - public static final Metric IT_UNCOVERED_CONDITIONS = new Metric.Builder(IT_UNCOVERED_CONDITIONS_KEY, "IT uncovered branches", Metric.ValueType.INT) + public static final Metric<Integer> IT_UNCOVERED_CONDITIONS = new Metric.Builder(IT_UNCOVERED_CONDITIONS_KEY, "IT uncovered branches", Metric.ValueType.INT) .setDescription("Integration Tests uncovered conditions") .setDirection(Metric.DIRECTION_WORST) .setDomain(DOMAIN_INTEGRATION_TESTS) @@ -905,7 +906,8 @@ public final class CoreMetrics { /** * @since 2.12 */ - public static final Metric NEW_IT_UNCOVERED_CONDITIONS = new Metric.Builder(NEW_IT_UNCOVERED_CONDITIONS_KEY, "Uncovered branches by IT on new code", Metric.ValueType.INT) + public static final Metric<Integer> NEW_IT_UNCOVERED_CONDITIONS = new Metric.Builder(NEW_IT_UNCOVERED_CONDITIONS_KEY, "Uncovered branches by IT on new code", + Metric.ValueType.INT) .setDescription("Uncovered branches by Integration Tests on new code") .setDirection(Metric.DIRECTION_WORST) .setDomain(DOMAIN_INTEGRATION_TESTS) @@ -922,7 +924,7 @@ public final class CoreMetrics { /** * @since 2.12 */ - public static final Metric IT_BRANCH_COVERAGE = new Metric.Builder(IT_BRANCH_COVERAGE_KEY, "IT branch coverage", Metric.ValueType.PERCENT) + public static final Metric<Double> IT_BRANCH_COVERAGE = new Metric.Builder(IT_BRANCH_COVERAGE_KEY, "IT branch coverage", Metric.ValueType.PERCENT) .setDescription("IT Branch coverage") .setDirection(Metric.DIRECTION_BETTER) .setQualitative(true) @@ -939,7 +941,7 @@ public final class CoreMetrics { /** * @since 2.12 */ - public static final Metric NEW_IT_BRANCH_COVERAGE = new Metric.Builder(NEW_IT_BRANCH_COVERAGE_KEY, "Branch coverage by IT on new code", Metric.ValueType.PERCENT) + public static final Metric<Double> NEW_IT_BRANCH_COVERAGE = new Metric.Builder(NEW_IT_BRANCH_COVERAGE_KEY, "Branch coverage by IT on new code", Metric.ValueType.PERCENT) .setDescription("Branch coverage by Integration Tests of new/changed code") .setDirection(Metric.DIRECTION_BETTER) .setQualitative(true) @@ -957,7 +959,7 @@ public final class CoreMetrics { /** * @since 2.12 */ - public static final Metric IT_CONDITIONS_BY_LINE = new Metric.Builder(IT_CONDITIONS_BY_LINE_KEY, "IT branches by line", Metric.ValueType.DATA) + public static final Metric<String> IT_CONDITIONS_BY_LINE = new Metric.Builder(IT_CONDITIONS_BY_LINE_KEY, "IT branches by line", Metric.ValueType.DATA) .setDomain(DOMAIN_INTEGRATION_TESTS) .setDeleteHistoricalData(true) .create(); @@ -970,7 +972,7 @@ public final class CoreMetrics { /** * @since 2.12 */ - public static final Metric IT_COVERED_CONDITIONS_BY_LINE = new Metric.Builder(IT_COVERED_CONDITIONS_BY_LINE_KEY, "IT covered branches by line", Metric.ValueType.DATA) + public static final Metric<String> IT_COVERED_CONDITIONS_BY_LINE = new Metric.Builder(IT_COVERED_CONDITIONS_BY_LINE_KEY, "IT covered branches by line", Metric.ValueType.DATA) .setDomain(DOMAIN_INTEGRATION_TESTS) .setDeleteHistoricalData(true) .create(); @@ -989,7 +991,7 @@ public final class CoreMetrics { /** * @since 3.3 */ - public static final Metric OVERALL_COVERAGE = new Metric.Builder(OVERALL_COVERAGE_KEY, "Overall coverage", Metric.ValueType.PERCENT) + public static final Metric<Double> OVERALL_COVERAGE = new Metric.Builder(OVERALL_COVERAGE_KEY, "Overall coverage", Metric.ValueType.PERCENT) .setDescription("Overall test coverage") .setDirection(Metric.DIRECTION_BETTER) .setQualitative(true) @@ -1006,7 +1008,7 @@ public final class CoreMetrics { /** * @since 3.3 */ - public static final Metric NEW_OVERALL_COVERAGE = new Metric.Builder(NEW_OVERALL_COVERAGE_KEY, "Overall coverage on new code", Metric.ValueType.PERCENT) + public static final Metric<Double> NEW_OVERALL_COVERAGE = new Metric.Builder(NEW_OVERALL_COVERAGE_KEY, "Overall coverage on new code", Metric.ValueType.PERCENT) .setDescription("Overall coverage of new/changed code") .setDirection(Metric.DIRECTION_BETTER) .setQualitative(true) @@ -1024,7 +1026,7 @@ public final class CoreMetrics { /** * @since 3.3 */ - public static final Metric OVERALL_LINES_TO_COVER = new Metric.Builder(OVERALL_LINES_TO_COVER_KEY, "Overall lines to cover", Metric.ValueType.INT) + public static final Metric<Integer> OVERALL_LINES_TO_COVER = new Metric.Builder(OVERALL_LINES_TO_COVER_KEY, "Overall lines to cover", Metric.ValueType.INT) .setDescription("Overall lines to cover by all tests") .setDirection(Metric.DIRECTION_BETTER) .setDomain(DOMAIN_OVERALL_TESTS) @@ -1042,7 +1044,7 @@ public final class CoreMetrics { /** * @since 3.3 */ - public static final Metric NEW_OVERALL_LINES_TO_COVER = new Metric.Builder(NEW_OVERALL_LINES_TO_COVER_KEY, "Overall lines to cover on new code", Metric.ValueType.INT) + public static final Metric<Integer> NEW_OVERALL_LINES_TO_COVER = new Metric.Builder(NEW_OVERALL_LINES_TO_COVER_KEY, "Overall lines to cover on new code", Metric.ValueType.INT) .setDescription("New lines to cover by all tests") .setDirection(Metric.DIRECTION_WORST) .setQualitative(false) @@ -1059,7 +1061,7 @@ public final class CoreMetrics { /** * @since 3.3 */ - public static final Metric OVERALL_UNCOVERED_LINES = new Metric.Builder(OVERALL_UNCOVERED_LINES_KEY, "Overall uncovered lines", Metric.ValueType.INT) + public static final Metric<Integer> OVERALL_UNCOVERED_LINES = new Metric.Builder(OVERALL_UNCOVERED_LINES_KEY, "Overall uncovered lines", Metric.ValueType.INT) .setDescription("Uncovered lines by all tests") .setDirection(Metric.DIRECTION_WORST) .setQualitative(false) @@ -1075,7 +1077,7 @@ public final class CoreMetrics { /** * @since 3.3 */ - public static final Metric NEW_OVERALL_UNCOVERED_LINES = new Metric.Builder(NEW_OVERALL_UNCOVERED_LINES_KEY, "Overall uncovered lines on new code", Metric.ValueType.INT) + public static final Metric<Integer> NEW_OVERALL_UNCOVERED_LINES = new Metric.Builder(NEW_OVERALL_UNCOVERED_LINES_KEY, "Overall uncovered lines on new code", Metric.ValueType.INT) .setDescription("New lines that are not covered by any tests") .setDirection(Metric.DIRECTION_WORST) .setDomain(DOMAIN_OVERALL_TESTS) @@ -1092,7 +1094,7 @@ public final class CoreMetrics { /** * @since 3.3 */ - public static final Metric OVERALL_LINE_COVERAGE = new Metric.Builder(OVERALL_LINE_COVERAGE_KEY, "Overall line coverage", Metric.ValueType.PERCENT) + public static final Metric<Double> OVERALL_LINE_COVERAGE = new Metric.Builder(OVERALL_LINE_COVERAGE_KEY, "Overall line coverage", Metric.ValueType.PERCENT) .setDescription("Line coverage by all tests") .setDirection(Metric.DIRECTION_BETTER) .setQualitative(true) @@ -1107,7 +1109,7 @@ public final class CoreMetrics { /** * @since 3.3 */ - public static final Metric NEW_OVERALL_LINE_COVERAGE = new Metric.Builder(NEW_OVERALL_LINE_COVERAGE_KEY, "Overall line coverage on new code", Metric.ValueType.PERCENT) + public static final Metric<Double> NEW_OVERALL_LINE_COVERAGE = new Metric.Builder(NEW_OVERALL_LINE_COVERAGE_KEY, "Overall line coverage on new code", Metric.ValueType.PERCENT) .setDescription("Line coverage of added/changed code by all tests") .setDirection(Metric.DIRECTION_BETTER) .setQualitative(true) @@ -1125,7 +1127,8 @@ public final class CoreMetrics { /** * @since 3.3 */ - public static final Metric OVERALL_COVERAGE_LINE_HITS_DATA = new Metric.Builder(OVERALL_COVERAGE_LINE_HITS_DATA_KEY, "Overall coverage hits by line", Metric.ValueType.DATA) + public static final Metric<String> OVERALL_COVERAGE_LINE_HITS_DATA = new Metric.Builder(OVERALL_COVERAGE_LINE_HITS_DATA_KEY, "Overall coverage hits by line", + Metric.ValueType.DATA) .setDescription("Coverage hits by all tests and by line") .setDirection(Metric.DIRECTION_NONE) .setQualitative(false) @@ -1141,7 +1144,7 @@ public final class CoreMetrics { /** * @since 3.3 */ - public static final Metric OVERALL_CONDITIONS_TO_COVER = new Metric.Builder(OVERALL_CONDITIONS_TO_COVER_KEY, "Overall branches to cover", Metric.ValueType.INT) + public static final Metric<Integer> OVERALL_CONDITIONS_TO_COVER = new Metric.Builder(OVERALL_CONDITIONS_TO_COVER_KEY, "Overall branches to cover", Metric.ValueType.INT) .setDescription("Branches to cover by all tests") .setDirection(Metric.DIRECTION_BETTER) .setQualitative(false) @@ -1158,7 +1161,7 @@ public final class CoreMetrics { /** * @since 3.3 */ - public static final Metric NEW_OVERALL_CONDITIONS_TO_COVER = new Metric.Builder(NEW_OVERALL_CONDITIONS_TO_COVER_KEY, "Overall branches to cover on new code", + public static final Metric<Integer> NEW_OVERALL_CONDITIONS_TO_COVER = new Metric.Builder(NEW_OVERALL_CONDITIONS_TO_COVER_KEY, "Overall branches to cover on new code", Metric.ValueType.INT) .setDescription("New branches to cover by all tests") .setDomain(DOMAIN_OVERALL_TESTS) @@ -1175,7 +1178,7 @@ public final class CoreMetrics { /** * @since 3.3 */ - public static final Metric OVERALL_UNCOVERED_CONDITIONS = new Metric.Builder(OVERALL_UNCOVERED_CONDITIONS_KEY, "Overall uncovered branches", Metric.ValueType.INT) + public static final Metric<Integer> OVERALL_UNCOVERED_CONDITIONS = new Metric.Builder(OVERALL_UNCOVERED_CONDITIONS_KEY, "Overall uncovered branches", Metric.ValueType.INT) .setDescription("Uncovered branches by all tests") .setDirection(Metric.DIRECTION_WORST) .setDomain(DOMAIN_OVERALL_TESTS) @@ -1190,7 +1193,7 @@ public final class CoreMetrics { /** * @since 3.3 */ - public static final Metric NEW_OVERALL_UNCOVERED_CONDITIONS = new Metric.Builder(NEW_OVERALL_UNCOVERED_CONDITIONS_KEY, "Overall uncovered branches on new code", + public static final Metric<Integer> NEW_OVERALL_UNCOVERED_CONDITIONS = new Metric.Builder(NEW_OVERALL_UNCOVERED_CONDITIONS_KEY, "Overall uncovered branches on new code", Metric.ValueType.INT) .setDescription("New branches that are not covered by any test") .setDirection(Metric.DIRECTION_WORST) @@ -1208,7 +1211,7 @@ public final class CoreMetrics { /** * @since 3.3 */ - public static final Metric OVERALL_BRANCH_COVERAGE = new Metric.Builder(OVERALL_BRANCH_COVERAGE_KEY, "Overall branch coverage", Metric.ValueType.PERCENT) + public static final Metric<Double> OVERALL_BRANCH_COVERAGE = new Metric.Builder(OVERALL_BRANCH_COVERAGE_KEY, "Overall branch coverage", Metric.ValueType.PERCENT) .setDescription("Branch coverage by all tests") .setDirection(Metric.DIRECTION_BETTER) .setQualitative(true) @@ -1225,7 +1228,8 @@ public final class CoreMetrics { /** * @since 3.3 */ - public static final Metric NEW_OVERALL_BRANCH_COVERAGE = new Metric.Builder(NEW_OVERALL_BRANCH_COVERAGE_KEY, "Overall branch coverage on new code", Metric.ValueType.PERCENT) + public static final Metric<Double> NEW_OVERALL_BRANCH_COVERAGE = new Metric.Builder(NEW_OVERALL_BRANCH_COVERAGE_KEY, "Overall branch coverage on new code", + Metric.ValueType.PERCENT) .setDescription("Branch coverage of new/changed code by all tests") .setDirection(Metric.DIRECTION_BETTER) .setQualitative(true) @@ -1243,7 +1247,7 @@ public final class CoreMetrics { /** * @since 3.3 */ - public static final Metric OVERALL_CONDITIONS_BY_LINE = new Metric.Builder(OVERALL_CONDITIONS_BY_LINE_KEY, "Overall branches by line", Metric.ValueType.DATA) + public static final Metric<String> OVERALL_CONDITIONS_BY_LINE = new Metric.Builder(OVERALL_CONDITIONS_BY_LINE_KEY, "Overall branches by line", Metric.ValueType.DATA) .setDescription("Overall branches by all tests and by line") .setDomain(DOMAIN_OVERALL_TESTS) .setDeleteHistoricalData(true) @@ -1257,7 +1261,7 @@ public final class CoreMetrics { /** * @since 3.3 */ - public static final Metric OVERALL_COVERED_CONDITIONS_BY_LINE = new Metric.Builder(OVERALL_COVERED_CONDITIONS_BY_LINE_KEY, "Overall covered branches by line", + public static final Metric<String> OVERALL_COVERED_CONDITIONS_BY_LINE = new Metric.Builder(OVERALL_COVERED_CONDITIONS_BY_LINE_KEY, "Overall covered branches by line", Metric.ValueType.DATA) .setDescription("Overall covered branches by all tests and by line") .setDomain(DOMAIN_OVERALL_TESTS) @@ -1271,7 +1275,7 @@ public final class CoreMetrics { // -------------------------------------------------------------------------------------------------------------------- public static final String DUPLICATED_LINES_KEY = "duplicated_lines"; - public static final Metric DUPLICATED_LINES = new Metric.Builder(DUPLICATED_LINES_KEY, "Duplicated lines", Metric.ValueType.INT) + public static final Metric<Integer> DUPLICATED_LINES = new Metric.Builder(DUPLICATED_LINES_KEY, "Duplicated lines", Metric.ValueType.INT) .setDescription("Duplicated lines") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -1281,7 +1285,7 @@ public final class CoreMetrics { .create(); public static final String DUPLICATED_BLOCKS_KEY = "duplicated_blocks"; - public static final Metric DUPLICATED_BLOCKS = new Metric.Builder(DUPLICATED_BLOCKS_KEY, "Duplicated blocks", Metric.ValueType.INT) + public static final Metric<Integer> DUPLICATED_BLOCKS = new Metric.Builder(DUPLICATED_BLOCKS_KEY, "Duplicated blocks", Metric.ValueType.INT) .setDescription("Duplicated blocks") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -1296,7 +1300,7 @@ public final class CoreMetrics { * For files: if it contains duplicates, then 1, otherwise 0. * For other resources: amount of files under this resource with duplicates. */ - public static final Metric DUPLICATED_FILES = new Metric.Builder(DUPLICATED_FILES_KEY, "Duplicated files", Metric.ValueType.INT) + public static final Metric<Integer> DUPLICATED_FILES = new Metric.Builder(DUPLICATED_FILES_KEY, "Duplicated files", Metric.ValueType.INT) .setDescription("Duplicated files") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -1306,7 +1310,7 @@ public final class CoreMetrics { .create(); public static final String DUPLICATED_LINES_DENSITY_KEY = "duplicated_lines_density"; - public static final Metric DUPLICATED_LINES_DENSITY = new Metric.Builder(DUPLICATED_LINES_DENSITY_KEY, "Duplicated lines (%)", Metric.ValueType.PERCENT) + public static final Metric<Double> DUPLICATED_LINES_DENSITY = new Metric.Builder(DUPLICATED_LINES_DENSITY_KEY, "Duplicated lines (%)", Metric.ValueType.PERCENT) .setDescription("Duplicated lines balanced by statements") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -1335,7 +1339,7 @@ public final class CoreMetrics { * </pre> * </p> */ - public static final Metric DUPLICATIONS_DATA = new Metric.Builder(DUPLICATIONS_DATA_KEY, "Duplications details", Metric.ValueType.DATA) + public static final Metric<String> DUPLICATIONS_DATA = new Metric.Builder(DUPLICATIONS_DATA_KEY, "Duplications details", Metric.ValueType.DATA) .setDescription("Duplications details") .setDirection(Metric.DIRECTION_NONE) .setQualitative(false) @@ -1351,7 +1355,7 @@ public final class CoreMetrics { public static final String WEIGHTED_VIOLATIONS_KEY = "weighted_violations"; - public static final Metric WEIGHTED_VIOLATIONS = new Metric.Builder(WEIGHTED_VIOLATIONS_KEY, "Weighted issues", Metric.ValueType.INT) + public static final Metric<Integer> WEIGHTED_VIOLATIONS = new Metric.Builder(WEIGHTED_VIOLATIONS_KEY, "Weighted issues", Metric.ValueType.INT) .setDescription("Weighted Issues") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -1370,7 +1374,7 @@ public final class CoreMetrics { * @deprecated since 4.0. See SONAR-4755 */ @Deprecated - public static final Metric VIOLATIONS_DENSITY = new Metric.Builder(VIOLATIONS_DENSITY_KEY, "Rules compliance", Metric.ValueType.PERCENT) + public static final Metric<Double> VIOLATIONS_DENSITY = new Metric.Builder(VIOLATIONS_DENSITY_KEY, "Rules compliance", Metric.ValueType.PERCENT) .setDescription("Rules compliance") .setDirection(Metric.DIRECTION_BETTER) .setQualitative(true) @@ -1379,7 +1383,7 @@ public final class CoreMetrics { .create(); public static final String VIOLATIONS_KEY = "violations"; - public static final Metric VIOLATIONS = new Metric.Builder(VIOLATIONS_KEY, "Issues", Metric.ValueType.INT) + public static final Metric<Integer> VIOLATIONS = new Metric.Builder(VIOLATIONS_KEY, "Issues", Metric.ValueType.INT) .setDescription("Issues") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -1389,7 +1393,7 @@ public final class CoreMetrics { .create(); public static final String BLOCKER_VIOLATIONS_KEY = "blocker_violations"; - public static final Metric BLOCKER_VIOLATIONS = new Metric.Builder(BLOCKER_VIOLATIONS_KEY, "Blocker issues", Metric.ValueType.INT) + public static final Metric<Integer> BLOCKER_VIOLATIONS = new Metric.Builder(BLOCKER_VIOLATIONS_KEY, "Blocker issues", Metric.ValueType.INT) .setDescription("Blocker issues") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -1399,7 +1403,7 @@ public final class CoreMetrics { .create(); public static final String CRITICAL_VIOLATIONS_KEY = "critical_violations"; - public static final Metric CRITICAL_VIOLATIONS = new Metric.Builder(CRITICAL_VIOLATIONS_KEY, "Critical issues", Metric.ValueType.INT) + public static final Metric<Integer> CRITICAL_VIOLATIONS = new Metric.Builder(CRITICAL_VIOLATIONS_KEY, "Critical issues", Metric.ValueType.INT) .setDescription("Critical issues") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -1409,7 +1413,7 @@ public final class CoreMetrics { .create(); public static final String MAJOR_VIOLATIONS_KEY = "major_violations"; - public static final Metric MAJOR_VIOLATIONS = new Metric.Builder(MAJOR_VIOLATIONS_KEY, "Major issues", Metric.ValueType.INT) + public static final Metric<Integer> MAJOR_VIOLATIONS = new Metric.Builder(MAJOR_VIOLATIONS_KEY, "Major issues", Metric.ValueType.INT) .setDescription("Major issues") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -1419,7 +1423,7 @@ public final class CoreMetrics { .create(); public static final String MINOR_VIOLATIONS_KEY = "minor_violations"; - public static final Metric MINOR_VIOLATIONS = new Metric.Builder(MINOR_VIOLATIONS_KEY, "Minor issues", Metric.ValueType.INT) + public static final Metric<Integer> MINOR_VIOLATIONS = new Metric.Builder(MINOR_VIOLATIONS_KEY, "Minor issues", Metric.ValueType.INT) .setDescription("Minor issues") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -1429,7 +1433,7 @@ public final class CoreMetrics { .create(); public static final String INFO_VIOLATIONS_KEY = "info_violations"; - public static final Metric INFO_VIOLATIONS = new Metric.Builder(INFO_VIOLATIONS_KEY, "Info issues", Metric.ValueType.INT) + public static final Metric<Integer> INFO_VIOLATIONS = new Metric.Builder(INFO_VIOLATIONS_KEY, "Info issues", Metric.ValueType.INT) .setDescription("Info issues") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -1439,7 +1443,7 @@ public final class CoreMetrics { .create(); public static final String NEW_VIOLATIONS_KEY = "new_violations"; - public static final Metric NEW_VIOLATIONS = new Metric.Builder(NEW_VIOLATIONS_KEY, "New issues", Metric.ValueType.INT) + public static final Metric<Integer> NEW_VIOLATIONS = new Metric.Builder(NEW_VIOLATIONS_KEY, "New issues", Metric.ValueType.INT) .setDescription("New Issues") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -1450,7 +1454,7 @@ public final class CoreMetrics { .create(); public static final String NEW_BLOCKER_VIOLATIONS_KEY = "new_blocker_violations"; - public static final Metric NEW_BLOCKER_VIOLATIONS = new Metric.Builder(NEW_BLOCKER_VIOLATIONS_KEY, "New Blocker issues", Metric.ValueType.INT) + public static final Metric<Integer> NEW_BLOCKER_VIOLATIONS = new Metric.Builder(NEW_BLOCKER_VIOLATIONS_KEY, "New Blocker issues", Metric.ValueType.INT) .setDescription("New Blocker issues") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -1461,7 +1465,7 @@ public final class CoreMetrics { .create(); public static final String NEW_CRITICAL_VIOLATIONS_KEY = "new_critical_violations"; - public static final Metric NEW_CRITICAL_VIOLATIONS = new Metric.Builder(NEW_CRITICAL_VIOLATIONS_KEY, "New Critical issues", Metric.ValueType.INT) + public static final Metric<Integer> NEW_CRITICAL_VIOLATIONS = new Metric.Builder(NEW_CRITICAL_VIOLATIONS_KEY, "New Critical issues", Metric.ValueType.INT) .setDescription("New Critical issues") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -1472,7 +1476,7 @@ public final class CoreMetrics { .create(); public static final String NEW_MAJOR_VIOLATIONS_KEY = "new_major_violations"; - public static final Metric NEW_MAJOR_VIOLATIONS = new Metric.Builder(NEW_MAJOR_VIOLATIONS_KEY, "New Major issues", Metric.ValueType.INT) + public static final Metric<Integer> NEW_MAJOR_VIOLATIONS = new Metric.Builder(NEW_MAJOR_VIOLATIONS_KEY, "New Major issues", Metric.ValueType.INT) .setDescription("New Major issues") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -1483,7 +1487,7 @@ public final class CoreMetrics { .create(); public static final String NEW_MINOR_VIOLATIONS_KEY = "new_minor_violations"; - public static final Metric NEW_MINOR_VIOLATIONS = new Metric.Builder(NEW_MINOR_VIOLATIONS_KEY, "New Minor issues", Metric.ValueType.INT) + public static final Metric<Integer> NEW_MINOR_VIOLATIONS = new Metric.Builder(NEW_MINOR_VIOLATIONS_KEY, "New Minor issues", Metric.ValueType.INT) .setDescription("New Minor issues") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -1494,7 +1498,7 @@ public final class CoreMetrics { .create(); public static final String NEW_INFO_VIOLATIONS_KEY = "new_info_violations"; - public static final Metric NEW_INFO_VIOLATIONS = new Metric.Builder(NEW_INFO_VIOLATIONS_KEY, "New Info issues", Metric.ValueType.INT) + public static final Metric<Integer> NEW_INFO_VIOLATIONS = new Metric.Builder(NEW_INFO_VIOLATIONS_KEY, "New Info issues", Metric.ValueType.INT) .setDescription("New Info issues") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -1512,7 +1516,7 @@ public final class CoreMetrics { /** * @since 3.6 */ - public static final Metric FALSE_POSITIVE_ISSUES = new Metric.Builder(FALSE_POSITIVE_ISSUES_KEY, "False positive issues", Metric.ValueType.INT) + public static final Metric<Integer> FALSE_POSITIVE_ISSUES = new Metric.Builder(FALSE_POSITIVE_ISSUES_KEY, "False positive issues", Metric.ValueType.INT) .setDescription("False positive issues") .setDirection(Metric.DIRECTION_WORST) .setDomain(DOMAIN_ISSUES) @@ -1528,7 +1532,7 @@ public final class CoreMetrics { /** * @since 3.6 */ - public static final Metric OPEN_ISSUES = new Metric.Builder(OPEN_ISSUES_KEY, "Open issues", Metric.ValueType.INT) + public static final Metric<Integer> OPEN_ISSUES = new Metric.Builder(OPEN_ISSUES_KEY, "Open issues", Metric.ValueType.INT) .setDescription("Open issues") .setDirection(Metric.DIRECTION_WORST) .setDomain(DOMAIN_ISSUES) @@ -1544,7 +1548,7 @@ public final class CoreMetrics { /** * @since 3.6 */ - public static final Metric REOPENED_ISSUES = new Metric.Builder(REOPENED_ISSUES_KEY, "Reopened issues", Metric.ValueType.INT) + public static final Metric<Integer> REOPENED_ISSUES = new Metric.Builder(REOPENED_ISSUES_KEY, "Reopened issues", Metric.ValueType.INT) .setDescription("Reopened issues") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -1561,7 +1565,7 @@ public final class CoreMetrics { /** * @since 3.6 */ - public static final Metric CONFIRMED_ISSUES = new Metric.Builder(CONFIRMED_ISSUES_KEY, "Confirmed issues", Metric.ValueType.INT) + public static final Metric<Integer> CONFIRMED_ISSUES = new Metric.Builder(CONFIRMED_ISSUES_KEY, "Confirmed issues", Metric.ValueType.INT) .setDescription("Confirmed issues") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -1585,7 +1589,7 @@ public final class CoreMetrics { * @deprecated since 3.7.1 */ @Deprecated - public static final Metric ABSTRACTNESS = new Metric.Builder(ABSTRACTNESS_KEY, "Abstractness", Metric.ValueType.PERCENT) + public static final Metric<Double> ABSTRACTNESS = new Metric.Builder(ABSTRACTNESS_KEY, "Abstractness", Metric.ValueType.PERCENT) .setDescription("Abstractness") .setDirection(Metric.DIRECTION_NONE) .setQualitative(false) @@ -1602,7 +1606,7 @@ public final class CoreMetrics { * @deprecated since 3.7.1 */ @Deprecated - public static final Metric INSTABILITY = new Metric.Builder(INSTABILITY_KEY, "Instability", Metric.ValueType.PERCENT) + public static final Metric<Double> INSTABILITY = new Metric.Builder(INSTABILITY_KEY, "Instability", Metric.ValueType.PERCENT) .setDescription("Instability") .setDirection(Metric.DIRECTION_NONE) .setQualitative(false) @@ -1619,7 +1623,7 @@ public final class CoreMetrics { * @deprecated since 3.7.1 */ @Deprecated - public static final Metric DISTANCE = new Metric.Builder(DISTANCE_KEY, "Distance", Metric.ValueType.FLOAT) + public static final Metric<Double> DISTANCE = new Metric.Builder(DISTANCE_KEY, "Distance", Metric.ValueType.FLOAT) .setDescription("Distance") .setDirection(Metric.DIRECTION_NONE) .setQualitative(false) @@ -1636,7 +1640,7 @@ public final class CoreMetrics { * @deprecated since 4.0. See SONAR-4643 */ @Deprecated - public static final Metric DEPTH_IN_TREE = new Metric.Builder(DEPTH_IN_TREE_KEY, "Depth in Tree", Metric.ValueType.INT) + public static final Metric<Integer> DEPTH_IN_TREE = new Metric.Builder(DEPTH_IN_TREE_KEY, "Depth in Tree", Metric.ValueType.INT) .setDescription("Depth in Inheritance Tree") .setDirection(Metric.DIRECTION_NONE) .setQualitative(false) @@ -1653,7 +1657,7 @@ public final class CoreMetrics { * @deprecated since 4.0. See SONAR-4643 */ @Deprecated - public static final Metric NUMBER_OF_CHILDREN = new Metric.Builder(NUMBER_OF_CHILDREN_KEY, "Number of Children", Metric.ValueType.INT) + public static final Metric<Integer> NUMBER_OF_CHILDREN = new Metric.Builder(NUMBER_OF_CHILDREN_KEY, "Number of Children", Metric.ValueType.INT) .setDescription("Number of Children") .setDirection(Metric.DIRECTION_NONE) .setQualitative(false) @@ -1671,7 +1675,7 @@ public final class CoreMetrics { * @deprecated since 4.2. See SONAR-5042 */ @Deprecated - public static final Metric RFC = new Metric.Builder(RFC_KEY, "RFC", Metric.ValueType.INT) + public static final Metric<Integer> RFC = new Metric.Builder(RFC_KEY, "RFC", Metric.ValueType.INT) .setDescription("Response for Class") .setDirection(Metric.DIRECTION_WORST) .setQualitative(false) @@ -1690,7 +1694,7 @@ public final class CoreMetrics { * @deprecated since 4.2. See SONAR-5042 */ @Deprecated - public static final Metric RFC_DISTRIBUTION = new Metric.Builder(RFC_DISTRIBUTION_KEY, "Class distribution /RFC", Metric.ValueType.DISTRIB) + public static final Metric<String> RFC_DISTRIBUTION = new Metric.Builder(RFC_DISTRIBUTION_KEY, "Class distribution /RFC", Metric.ValueType.DISTRIB) .setDescription("Class distribution /RFC") .setDirection(Metric.DIRECTION_NONE) .setQualitative(true) @@ -1709,7 +1713,7 @@ public final class CoreMetrics { * @deprecated in 4.1. See http://jira.codehaus.org/browse/SONAR-4853 */ @Deprecated - public static final Metric LCOM4 = new Metric.Builder(LCOM4_KEY, "LCOM4", Metric.ValueType.FLOAT) + public static final Metric<Double> LCOM4 = new Metric.Builder(LCOM4_KEY, "LCOM4", Metric.ValueType.FLOAT) .setDescription("Lack of Cohesion of Functions") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -1728,7 +1732,7 @@ public final class CoreMetrics { * @deprecated in 4.1. See http://jira.codehaus.org/browse/SONAR-4853 */ @Deprecated - public static final Metric LCOM4_BLOCKS = new Metric.Builder(LCOM4_BLOCKS_KEY, "LCOM4 blocks", Metric.ValueType.DATA) + public static final Metric<String> LCOM4_BLOCKS = new Metric.Builder(LCOM4_BLOCKS_KEY, "LCOM4 blocks", Metric.ValueType.DATA) .setDescription("LCOM4 blocks") .setDirection(Metric.DIRECTION_NONE) .setQualitative(false) @@ -1747,7 +1751,7 @@ public final class CoreMetrics { * @deprecated in 4.1. See http://jira.codehaus.org/browse/SONAR-4853 */ @Deprecated - public static final Metric LCOM4_DISTRIBUTION = new Metric.Builder(LCOM4_DISTRIBUTION_KEY, "Class distribution /LCOM4", Metric.ValueType.DISTRIB) + public static final Metric<String> LCOM4_DISTRIBUTION = new Metric.Builder(LCOM4_DISTRIBUTION_KEY, "Class distribution /LCOM4", Metric.ValueType.DISTRIB) .setDescription("Class distribution /LCOM4") .setDirection(Metric.DIRECTION_NONE) .setQualitative(true) @@ -1766,7 +1770,7 @@ public final class CoreMetrics { * @deprecated in 4.1. See http://jira.codehaus.org/browse/SONAR-4853 */ @Deprecated - public static final Metric SUSPECT_LCOM4_DENSITY = new Metric.Builder(SUSPECT_LCOM4_DENSITY_KEY, "Suspect LCOM4 density", Metric.ValueType.PERCENT) + public static final Metric<Double> SUSPECT_LCOM4_DENSITY = new Metric.Builder(SUSPECT_LCOM4_DENSITY_KEY, "Suspect LCOM4 density", Metric.ValueType.PERCENT) .setDescription("Density of classes having LCOM4>1") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -1783,7 +1787,7 @@ public final class CoreMetrics { * @deprecated since 3.7.1 */ @Deprecated - public static final Metric AFFERENT_COUPLINGS = new Metric.Builder(AFFERENT_COUPLINGS_KEY, "Afferent couplings", Metric.ValueType.INT) + public static final Metric<Integer> AFFERENT_COUPLINGS = new Metric.Builder(AFFERENT_COUPLINGS_KEY, "Afferent couplings", Metric.ValueType.INT) .setDescription("Afferent couplings") .setDirection(Metric.DIRECTION_WORST) .setQualitative(false) @@ -1800,7 +1804,7 @@ public final class CoreMetrics { * @deprecated since 3.7.1 */ @Deprecated - public static final Metric EFFERENT_COUPLINGS = new Metric.Builder(EFFERENT_COUPLINGS_KEY, "Efferent couplings", Metric.ValueType.INT) + public static final Metric<Integer> EFFERENT_COUPLINGS = new Metric.Builder(EFFERENT_COUPLINGS_KEY, "Efferent couplings", Metric.ValueType.INT) .setDescription("Efferent couplings") .setDirection(Metric.DIRECTION_WORST) .setQualitative(false) @@ -1809,7 +1813,7 @@ public final class CoreMetrics { .create(); public static final String DEPENDENCY_MATRIX_KEY = "dsm"; - public static final Metric DEPENDENCY_MATRIX = new Metric.Builder(DEPENDENCY_MATRIX_KEY, "Dependency Matrix", Metric.ValueType.DATA) + public static final Metric<String> DEPENDENCY_MATRIX = new Metric.Builder(DEPENDENCY_MATRIX_KEY, "Dependency Matrix", Metric.ValueType.DATA) .setDescription("Dependency Matrix") .setDirection(Metric.DIRECTION_NONE) .setQualitative(false) @@ -1818,7 +1822,7 @@ public final class CoreMetrics { .create(); public static final String PACKAGE_CYCLES_KEY = "package_cycles"; - public static final Metric PACKAGE_CYCLES = new Metric.Builder(PACKAGE_CYCLES_KEY, "Package cycles", Metric.ValueType.INT) + public static final Metric<Integer> PACKAGE_CYCLES = new Metric.Builder(PACKAGE_CYCLES_KEY, "Package cycles", Metric.ValueType.INT) .setDescription("Package cycles") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -1828,7 +1832,7 @@ public final class CoreMetrics { .create(); public static final String PACKAGE_TANGLE_INDEX_KEY = "package_tangle_index"; - public static final Metric PACKAGE_TANGLE_INDEX = new Metric.Builder(PACKAGE_TANGLE_INDEX_KEY, "Package tangle index", Metric.ValueType.PERCENT) + public static final Metric<Double> PACKAGE_TANGLE_INDEX = new Metric.Builder(PACKAGE_TANGLE_INDEX_KEY, "Package tangle index", Metric.ValueType.PERCENT) .setDescription("Package tangle index") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -1837,7 +1841,7 @@ public final class CoreMetrics { .create(); public static final String PACKAGE_TANGLES_KEY = "package_tangles"; - public static final Metric PACKAGE_TANGLES = new Metric.Builder(PACKAGE_TANGLES_KEY, "File dependencies to cut", Metric.ValueType.INT) + public static final Metric<Integer> PACKAGE_TANGLES = new Metric.Builder(PACKAGE_TANGLES_KEY, "File dependencies to cut", Metric.ValueType.INT) .setDescription("File dependencies to cut") .setDirection(Metric.DIRECTION_WORST) .setQualitative(false) @@ -1846,7 +1850,7 @@ public final class CoreMetrics { .create(); public static final String PACKAGE_FEEDBACK_EDGES_KEY = "package_feedback_edges"; - public static final Metric PACKAGE_FEEDBACK_EDGES = new Metric.Builder(PACKAGE_FEEDBACK_EDGES_KEY, "Package dependencies to cut", Metric.ValueType.INT) + public static final Metric<Integer> PACKAGE_FEEDBACK_EDGES = new Metric.Builder(PACKAGE_FEEDBACK_EDGES_KEY, "Package dependencies to cut", Metric.ValueType.INT) .setDescription("Package dependencies to cut") .setDirection(Metric.DIRECTION_WORST) .setQualitative(false) @@ -1856,7 +1860,7 @@ public final class CoreMetrics { .create(); public static final String PACKAGE_EDGES_WEIGHT_KEY = "package_edges_weight"; - public static final Metric PACKAGE_EDGES_WEIGHT = new Metric.Builder(PACKAGE_EDGES_WEIGHT_KEY, "Package edges weight", Metric.ValueType.INT) + public static final Metric<Integer> PACKAGE_EDGES_WEIGHT = new Metric.Builder(PACKAGE_EDGES_WEIGHT_KEY, "Package edges weight", Metric.ValueType.INT) .setDescription("Package edges weight") .setDirection(Metric.DIRECTION_BETTER) .setQualitative(false) @@ -1867,7 +1871,7 @@ public final class CoreMetrics { .create(); public static final String FILE_CYCLES_KEY = "file_cycles"; - public static final Metric FILE_CYCLES = new Metric.Builder(FILE_CYCLES_KEY, "File cycles", Metric.ValueType.INT) + public static final Metric<Integer> FILE_CYCLES = new Metric.Builder(FILE_CYCLES_KEY, "File cycles", Metric.ValueType.INT) .setDescription("File cycles") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -1878,7 +1882,7 @@ public final class CoreMetrics { .create(); public static final String FILE_TANGLE_INDEX_KEY = "file_tangle_index"; - public static final Metric FILE_TANGLE_INDEX = new Metric.Builder(FILE_TANGLE_INDEX_KEY, "File tangle index", Metric.ValueType.PERCENT) + public static final Metric<Double> FILE_TANGLE_INDEX = new Metric.Builder(FILE_TANGLE_INDEX_KEY, "File tangle index", Metric.ValueType.PERCENT) .setDescription("File tangle index") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -1889,7 +1893,7 @@ public final class CoreMetrics { .create(); public static final String FILE_TANGLES_KEY = "file_tangles"; - public static final Metric FILE_TANGLES = new Metric.Builder(FILE_TANGLES_KEY, "File tangles", Metric.ValueType.INT) + public static final Metric<Integer> FILE_TANGLES = new Metric.Builder(FILE_TANGLES_KEY, "File tangles", Metric.ValueType.INT) .setDescription("Files tangles") .setDirection(Metric.DIRECTION_WORST) .setQualitative(false) @@ -1899,7 +1903,7 @@ public final class CoreMetrics { .create(); public static final String FILE_FEEDBACK_EDGES_KEY = "file_feedback_edges"; - public static final Metric FILE_FEEDBACK_EDGES = new Metric.Builder(FILE_FEEDBACK_EDGES_KEY, "Suspect file dependencies", Metric.ValueType.INT) + public static final Metric<Integer> FILE_FEEDBACK_EDGES = new Metric.Builder(FILE_FEEDBACK_EDGES_KEY, "Suspect file dependencies", Metric.ValueType.INT) .setDescription("Suspect file dependencies") .setDirection(Metric.DIRECTION_WORST) .setQualitative(false) @@ -1910,7 +1914,7 @@ public final class CoreMetrics { .create(); public static final String FILE_EDGES_WEIGHT_KEY = "file_edges_weight"; - public static final Metric FILE_EDGES_WEIGHT = new Metric.Builder(FILE_EDGES_WEIGHT_KEY, "File edges weight", Metric.ValueType.INT) + public static final Metric<Integer> FILE_EDGES_WEIGHT = new Metric.Builder(FILE_EDGES_WEIGHT_KEY, "File edges weight", Metric.ValueType.INT) .setDescription("File edges weight") .setDirection(Metric.DIRECTION_BETTER) .setQualitative(false) @@ -1938,7 +1942,7 @@ public final class CoreMetrics { * @see org.sonar.api.utils.KeyValueFormat#parseIntString(String) * @since 2.7 */ - public static final Metric SCM_AUTHORS_BY_LINE = new Metric.Builder(SCM_AUTHORS_BY_LINE_KEY, "Authors by line", Metric.ValueType.DATA) + public static final Metric<String> SCM_AUTHORS_BY_LINE = new Metric.Builder(SCM_AUTHORS_BY_LINE_KEY, "Authors by line", Metric.ValueType.DATA) .setDomain(DOMAIN_SCM) .create(); @@ -1954,7 +1958,7 @@ public final class CoreMetrics { * @see org.sonar.api.utils.KeyValueFormat#parseIntString(String) * @since 2.7 */ - public static final Metric SCM_REVISIONS_BY_LINE = new Metric.Builder(SCM_REVISIONS_BY_LINE_KEY, "Revisions by line", Metric.ValueType.DATA) + public static final Metric<String> SCM_REVISIONS_BY_LINE = new Metric.Builder(SCM_REVISIONS_BY_LINE_KEY, "Revisions by line", Metric.ValueType.DATA) .setDomain(DOMAIN_SCM) .create(); @@ -1970,7 +1974,8 @@ public final class CoreMetrics { * @see org.sonar.api.utils.KeyValueFormat#parseIntDateTime(String) * @since 2.7 */ - public static final Metric SCM_LAST_COMMIT_DATETIMES_BY_LINE = new Metric.Builder(SCM_LAST_COMMIT_DATETIMES_BY_LINE_KEY, "Last commit dates by line", Metric.ValueType.DATA) + public static final Metric<String> SCM_LAST_COMMIT_DATETIMES_BY_LINE = new Metric.Builder(SCM_LAST_COMMIT_DATETIMES_BY_LINE_KEY, "Last commit dates by line", + Metric.ValueType.DATA) .setDomain(DOMAIN_SCM) .create(); @@ -1992,7 +1997,7 @@ public final class CoreMetrics { * @deprecated in 3.6. This measure is not fed anymore since introduction of issues. */ @Deprecated - public static final Metric UNREVIEWED_VIOLATIONS = new Metric.Builder(UNREVIEWED_VIOLATIONS_KEY, "Unreviewed violations", Metric.ValueType.INT) + public static final Metric<Integer> UNREVIEWED_VIOLATIONS = new Metric.Builder(UNREVIEWED_VIOLATIONS_KEY, "Unreviewed violations", Metric.ValueType.INT) .setDescription("Violations that have not been reviewed yet") .setDirection(Metric.DIRECTION_WORST) .setDomain(DOMAIN_REVIEWS) @@ -2013,7 +2018,7 @@ public final class CoreMetrics { * @deprecated in 3.6. This measure is not fed anymore since introduction of issues. */ @Deprecated - public static final Metric NEW_UNREVIEWED_VIOLATIONS = new Metric.Builder(NEW_UNREVIEWED_VIOLATIONS_KEY, "New unreviewed violations", Metric.ValueType.INT) + public static final Metric<Integer> NEW_UNREVIEWED_VIOLATIONS = new Metric.Builder(NEW_UNREVIEWED_VIOLATIONS_KEY, "New unreviewed violations", Metric.ValueType.INT) .setDescription("New violations that have not been reviewed yet") .setDirection(Metric.DIRECTION_WORST) .setQualitative(true) @@ -2036,7 +2041,7 @@ public final class CoreMetrics { * @deprecated in 3.6. This measure is replaced by {@link #FALSE_POSITIVE_ISSUES}. */ @Deprecated - public static final Metric FALSE_POSITIVE_REVIEWS = new Metric.Builder(FALSE_POSITIVE_REVIEWS_KEY, "False-positive reviews", Metric.ValueType.INT) + public static final Metric<Integer> FALSE_POSITIVE_REVIEWS = new Metric.Builder(FALSE_POSITIVE_REVIEWS_KEY, "False-positive reviews", Metric.ValueType.INT) .setDescription("Active false-positive reviews") .setDirection(Metric.DIRECTION_WORST) .setDomain(DOMAIN_REVIEWS) @@ -2057,7 +2062,7 @@ public final class CoreMetrics { * @deprecated in 3.6. This measure is not fed anymore since introduction of issues. */ @Deprecated - public static final Metric ACTIVE_REVIEWS = new Metric.Builder(ACTIVE_REVIEWS_KEY, "Active reviews", Metric.ValueType.INT) + public static final Metric<Integer> ACTIVE_REVIEWS = new Metric.Builder(ACTIVE_REVIEWS_KEY, "Active reviews", Metric.ValueType.INT) .setDescription("Active open and reopened reviews") .setDirection(Metric.DIRECTION_WORST) .setDomain(DOMAIN_REVIEWS) @@ -2078,7 +2083,7 @@ public final class CoreMetrics { * @deprecated in 3.6. This measure is not fed anymore since introduction of issues. */ @Deprecated - public static final Metric UNASSIGNED_REVIEWS = new Metric.Builder(UNASSIGNED_REVIEWS_KEY, "Unassigned reviews", Metric.ValueType.INT) + public static final Metric<Integer> UNASSIGNED_REVIEWS = new Metric.Builder(UNASSIGNED_REVIEWS_KEY, "Unassigned reviews", Metric.ValueType.INT) .setDescription("Active unassigned reviews") .setDirection(Metric.DIRECTION_WORST) .setDomain(DOMAIN_REVIEWS) @@ -2099,7 +2104,7 @@ public final class CoreMetrics { * @deprecated in 3.6. This measure is not fed anymore since introduction of issues. */ @Deprecated - public static final Metric UNPLANNED_REVIEWS = new Metric.Builder(UNPLANNED_REVIEWS_KEY, "Unplanned reviews", Metric.ValueType.INT) + public static final Metric<Integer> UNPLANNED_REVIEWS = new Metric.Builder(UNPLANNED_REVIEWS_KEY, "Unplanned reviews", Metric.ValueType.INT) .setDescription("Active unplanned reviews") .setDirection(Metric.DIRECTION_WORST) .setDomain(DOMAIN_REVIEWS) @@ -2122,7 +2127,7 @@ public final class CoreMetrics { /** * @since 4.0 */ - public static final Metric TECHNICAL_DEBT = new Metric.Builder(TECHNICAL_DEBT_KEY, "Technical Debt", Metric.ValueType.WORK_DUR) + public static final Metric<Long> TECHNICAL_DEBT = new Metric.Builder(TECHNICAL_DEBT_KEY, "Technical Debt", Metric.ValueType.WORK_DUR) .setDomain(DOMAIN_TECHNICAL_DEBT) .setDirection(Metric.DIRECTION_WORST) .setOptimizedBestValue(true) @@ -2138,7 +2143,7 @@ public final class CoreMetrics { /** * @since 4.1 */ - public static final Metric NEW_TECHNICAL_DEBT = new Metric.Builder(NEW_TECHNICAL_DEBT_KEY, "Technical Debt on new code", Metric.ValueType.WORK_DUR) + public static final Metric<Long> NEW_TECHNICAL_DEBT = new Metric.Builder(NEW_TECHNICAL_DEBT_KEY, "Technical Debt on new code", Metric.ValueType.WORK_DUR) .setDescription("Technical Debt of new code") .setDomain(DOMAIN_TECHNICAL_DEBT) .setDirection(Metric.DIRECTION_WORST) @@ -2168,7 +2173,7 @@ public final class CoreMetrics { * @since 2.14 */ @Beta - public static final Metric NCLOC_DATA = new Metric.Builder(NCLOC_DATA_KEY, "ncloc_data", Metric.ValueType.DATA) + public static final Metric<String> NCLOC_DATA = new Metric.Builder(NCLOC_DATA_KEY, "ncloc_data", Metric.ValueType.DATA) .setHidden(true) .setDomain(DOMAIN_SIZE) .create(); @@ -2187,7 +2192,7 @@ public final class CoreMetrics { * @since 2.14 */ @Beta - public static final Metric COMMENT_LINES_DATA = new Metric.Builder(COMMENT_LINES_DATA_KEY, "comment_lines_data", Metric.ValueType.DATA) + public static final Metric<String> COMMENT_LINES_DATA = new Metric.Builder(COMMENT_LINES_DATA_KEY, "comment_lines_data", Metric.ValueType.DATA) .setHidden(true) .setDomain(DOMAIN_DOCUMENTATION) .create(); @@ -2199,7 +2204,7 @@ public final class CoreMetrics { // -------------------------------------------------------------------------------------------------------------------- public static final String ALERT_STATUS_KEY = "alert_status"; - public static final Metric ALERT_STATUS = new Metric.Builder(ALERT_STATUS_KEY, "Quality Gate Status", Metric.ValueType.LEVEL) + public static final Metric<Metric.Level> ALERT_STATUS = new Metric.Builder(ALERT_STATUS_KEY, "Quality Gate Status", Metric.ValueType.LEVEL) .setDescription("The project status with regard to its quality gate.") .setDirection(Metric.DIRECTION_BETTER) .setQualitative(true) @@ -2215,7 +2220,7 @@ public final class CoreMetrics { * Storing the global quality gate status, along with all evaluated conditions, into a JSON object. * @since 4.4 */ - public static final Metric QUALITY_GATE_DETAILS = new Metric.Builder(QUALITY_GATE_DETAILS_KEY, "Quality Gate Details", Metric.ValueType.DATA) + public static final Metric<String> QUALITY_GATE_DETAILS = new Metric.Builder(QUALITY_GATE_DETAILS_KEY, "Quality Gate Details", Metric.ValueType.DATA) .setDescription("The project detailed status with regard to its quality gate.") .setDomain(DOMAIN_GENERAL) .create(); @@ -2229,7 +2234,7 @@ public final class CoreMetrics { * @deprecated since 4.4 doesn't support multi-language. See {@link #QUALITY_PROFILES_KEY} */ @Deprecated - public static final Metric PROFILE = new Metric.Builder(PROFILE_KEY, "Profile", Metric.ValueType.DATA) + public static final Metric<String> PROFILE = new Metric.Builder(PROFILE_KEY, "Profile", Metric.ValueType.DATA) .setDescription("Selected quality profile") .setDomain(DOMAIN_GENERAL) .create(); @@ -2245,7 +2250,7 @@ public final class CoreMetrics { * @deprecated since 4.4 doesn't support multi-language. See {@link #QUALITY_PROFILES_KEY} */ @Deprecated - public static final Metric PROFILE_VERSION = new Metric.Builder(PROFILE_VERSION_KEY, "Profile version", Metric.ValueType.INT) + public static final Metric<Integer> PROFILE_VERSION = new Metric.Builder(PROFILE_VERSION_KEY, "Profile version", Metric.ValueType.INT) .setDescription("Selected quality profile version") .setQualitative(false) .setDomain(DOMAIN_GENERAL) @@ -2260,7 +2265,7 @@ public final class CoreMetrics { /** * @since 4.4 */ - public static final Metric QUALITY_PROFILES = new Metric.Builder(QUALITY_PROFILES_KEY, "Profiles", Metric.ValueType.DATA) + public static final Metric<String> QUALITY_PROFILES = new Metric.Builder(QUALITY_PROFILES_KEY, "Profiles", Metric.ValueType.DATA) .setDescription("Details of quality profiles used during analysis") .setQualitative(false) .setDomain(DOMAIN_GENERAL) 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 4c729d71125..92b832e2993 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 @@ -37,12 +37,11 @@ public final class CoverageMeasuresBuilder { /** * Metrics of generated measures */ - public static final List<Metric> METRICS = Arrays.asList( + 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(); private SortedMap<Integer, Integer> conditionsByLine = Maps.newTreeMap(); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java index 4f5493f88a9..dcb8120d196 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java @@ -69,7 +69,7 @@ public class Metric<G extends Serializable> implements ServerExtension, BatchExt STRING(String.class), MILLISEC(Integer.class), DATA(String.class), - LEVEL(String.class), + LEVEL(Metric.Level.class), DISTRIB(String.class), RATING(String.class), WORK_DUR(Long.class); diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/analyzer/internal/DefaultAnalyzerDescriptorTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/analyzer/internal/DefaultAnalyzerDescriptorTest.java new file mode 100644 index 00000000000..0c63dd2167c --- /dev/null +++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/analyzer/internal/DefaultAnalyzerDescriptorTest.java @@ -0,0 +1,47 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.api.batch.analyzer.internal; + +import org.junit.Test; +import org.sonar.api.batch.fs.InputFile; +import org.sonar.api.measures.CoreMetrics; + +import static org.fest.assertions.Assertions.assertThat; + +public class DefaultAnalyzerDescriptorTest { + + @Test + public void describe() { + DefaultAnalyzerDescriptor descriptor = new DefaultAnalyzerDescriptor(); + descriptor + .name("Foo") + .dependsOn(CoreMetrics.NCLOC) + .provides(CoreMetrics.BLOCKER_VIOLATIONS) + .runOnLanguages("java", "php") + .runOnTypes(InputFile.Type.MAIN); + + assertThat(descriptor.name()).isEqualTo("Foo"); + assertThat(descriptor.dependsOn()).containsOnly(CoreMetrics.NCLOC); + assertThat(descriptor.provides()).containsOnly(CoreMetrics.BLOCKER_VIOLATIONS); + assertThat(descriptor.languages()).containsOnly("java", "php"); + assertThat(descriptor.types()).containsOnly(InputFile.Type.MAIN); + } + +} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/analyzer/issue/internal/DefaultAnalyzerIssueTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/analyzer/issue/internal/DefaultAnalyzerIssueTest.java new file mode 100644 index 00000000000..1ec42281afc --- /dev/null +++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/analyzer/issue/internal/DefaultAnalyzerIssueTest.java @@ -0,0 +1,85 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.api.batch.analyzer.issue.internal; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.batch.analyzer.issue.AnalyzerIssue; +import org.sonar.api.batch.fs.internal.DefaultInputFile; +import org.sonar.api.rule.RuleKey; + +import static org.fest.assertions.Assertions.assertThat; + +public class DefaultAnalyzerIssueTest { + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Test + public void build_file_issue() { + AnalyzerIssue issue = new DefaultAnalyzerIssueBuilder() + .onFile(new DefaultInputFile("src/Foo.php")) + .ruleKey(RuleKey.of("repo", "rule")) + .atLine(1) + .effortToFix(10.0) + .message("Wrong way!") + .build(); + + assertThat(issue.inputFile()).isEqualTo(new DefaultInputFile("src/Foo.php")); + assertThat(issue.ruleKey()).isEqualTo(RuleKey.of("repo", "rule")); + assertThat(issue.line()).isEqualTo(1); + assertThat(issue.effortToFix()).isEqualTo(10.0); + assertThat(issue.message()).isEqualTo("Wrong way!"); + } + + @Test + public void build_project_issue() { + AnalyzerIssue issue = new DefaultAnalyzerIssueBuilder() + .onProject() + .ruleKey(RuleKey.of("repo", "rule")) + .atLine(1) + .effortToFix(10.0) + .message("Wrong way!") + .build(); + + assertThat(issue.inputFile()).isNull(); + assertThat(issue.ruleKey()).isEqualTo(RuleKey.of("repo", "rule")); + assertThat(issue.line()).isEqualTo(1); + assertThat(issue.effortToFix()).isEqualTo(10.0); + assertThat(issue.message()).isEqualTo("Wrong way!"); + } + + @Test + public void not_allowed_to_call_onFile_and_onProject() { + thrown.expect(IllegalStateException.class); + thrown.expectMessage("onFile or onProject can be called only once"); + new DefaultAnalyzerIssueBuilder() + .onProject() + .onFile(new DefaultInputFile("src/Foo.php")) + .ruleKey(RuleKey.of("repo", "rule")) + .atLine(1) + .effortToFix(10.0) + .message("Wrong way!") + .build(); + + } + +} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/analyzer/measure/internal/DefaultAnalyzerMeasureTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/analyzer/measure/internal/DefaultAnalyzerMeasureTest.java new file mode 100644 index 00000000000..1e27f766ae3 --- /dev/null +++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/analyzer/measure/internal/DefaultAnalyzerMeasureTest.java @@ -0,0 +1,73 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.api.batch.analyzer.measure.internal; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.batch.analyzer.measure.AnalyzerMeasure; +import org.sonar.api.batch.fs.internal.DefaultInputFile; +import org.sonar.api.measures.CoreMetrics; + +import static org.fest.assertions.Assertions.assertThat; + +public class DefaultAnalyzerMeasureTest { + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Test + public void build_file_measure() { + AnalyzerMeasure<Integer> issue = new DefaultAnalyzerMeasureBuilder<Integer>() + .forMetric(CoreMetrics.LINES) + .onFile(new DefaultInputFile("src/Foo.php")) + .withValue(3) + .build(); + + assertThat(issue.inputFile()).isEqualTo(new DefaultInputFile("src/Foo.php")); + assertThat(issue.metric()).isEqualTo(CoreMetrics.LINES); + assertThat(issue.value()).isEqualTo(3); + } + + @Test + public void build_project_measure() { + AnalyzerMeasure<Integer> issue = new DefaultAnalyzerMeasureBuilder<Integer>() + .forMetric(CoreMetrics.LINES) + .onProject() + .withValue(3) + .build(); + + assertThat(issue.inputFile()).isNull(); + assertThat(issue.metric()).isEqualTo(CoreMetrics.LINES); + assertThat(issue.value()).isEqualTo(3); + } + + @Test + public void not_allowed_to_call_onFile_and_onProject() { + thrown.expect(IllegalStateException.class); + thrown.expectMessage("onFile or onProject can be called only once"); + new DefaultAnalyzerMeasureBuilder<Integer>() + .onProject() + .onFile(new DefaultInputFile("src/Foo.php")) + .withValue(3) + .build(); + } + +} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/measures/SumChildValuesFormulaTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/measures/SumChildValuesFormulaTest.java index 829e75f3fc2..b91276358d8 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/measures/SumChildValuesFormulaTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/measures/SumChildValuesFormulaTest.java @@ -19,17 +19,16 @@ */ package org.sonar.api.measures; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; import org.junit.Before; import org.junit.Test; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; import java.util.Arrays; import java.util.Collections; +import static org.fest.assertions.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + public class SumChildValuesFormulaTest { private FormulaContext context; private FormulaData data; @@ -44,12 +43,12 @@ public class SumChildValuesFormulaTest { public void sumChildValues() { when(context.getTargetMetric()).thenReturn(CoreMetrics.NCLOC); when(data.getChildrenMeasures(CoreMetrics.NCLOC)).thenReturn( - Arrays.<Measure>asList(new Measure(CoreMetrics.NCLOC, 100.0), new Measure(CoreMetrics.NCLOC, 50.0))); + Arrays.<Measure>asList(new Measure(CoreMetrics.NCLOC, 100.0), new Measure(CoreMetrics.NCLOC, 50.0))); Measure measure = new SumChildValuesFormula(true).calculate(data, context); - assertThat(measure.getMetric(), is(CoreMetrics.NCLOC)); - assertThat(measure.getValue(), is(150.0)); + assertThat(measure.getMetric()).isEqualTo(CoreMetrics.NCLOC); + assertThat(measure.getValue()).isEqualTo(150.0); } @Test @@ -59,7 +58,7 @@ public class SumChildValuesFormulaTest { Measure measure = new SumChildValuesFormula(false).calculate(data, context); - assertThat(measure, nullValue()); + assertThat(measure).isNull(); } @Test @@ -69,7 +68,7 @@ public class SumChildValuesFormulaTest { Measure measure = new SumChildValuesFormula(true).calculate(data, context); - assertThat(measure.getMetric(), is(CoreMetrics.NCLOC)); - assertThat(measure.getValue(), is(0.0)); + assertThat(measure.getMetric()).isEqualTo(CoreMetrics.NCLOC); + assertThat(measure.getValue()).isEqualTo(0.0); } } |