aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/AbstractCoverageDecorator.java40
1 files changed, 22 insertions, 18 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/AbstractCoverageDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/AbstractCoverageDecorator.java
index d5a6e95c047..da22d828c36 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/AbstractCoverageDecorator.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/AbstractCoverageDecorator.java
@@ -50,32 +50,36 @@ public abstract class AbstractCoverageDecorator implements Decorator {
}
protected boolean shouldDecorate(final Resource resource, final DecoratorContext context) {
- return context.getMeasure(getGeneratedMetric()) == null && !ResourceUtils.isUnitTestClass(resource);
+ return !ResourceUtils.isUnitTestClass(resource);
}
private void computeMeasure(DecoratorContext context) {
- Long elements = countElements(context);
- if (elements != null && elements > 0L) {
- Long coveredElements = countCoveredElements(context);
- context.saveMeasure(getGeneratedMetric(), calculateCoverage(coveredElements, elements));
+ if (context.getMeasure(getGeneratedMetric()) == null) {
+ Long elements = countElements(context);
+ if (elements != null && elements > 0L) {
+ Long coveredElements = countCoveredElements(context);
+ context.saveMeasure(getGeneratedMetric(), calculateCoverage(coveredElements, elements));
+ }
}
}
private void computeMeasureForNewCode(DecoratorContext context) {
- Measure measure = new Measure(getGeneratedMetricForNewCode());
- boolean hasValue = false;
- /* TODO remove this magic number */
- for (int periodIndex = 1; periodIndex <= 5; periodIndex++) {
- Long elements = countElementsForNewCode(context, periodIndex);
-
- if (elements != null && elements > 0L) {
- long coveredElements = countCoveredElementsForNewCode(context, periodIndex);
- measure.setVariation(periodIndex, calculateCoverage(coveredElements, elements));
- hasValue = true;
+ if (context.getMeasure(getGeneratedMetricForNewCode()) == null) {
+ Measure measure = new Measure(getGeneratedMetricForNewCode());
+ boolean hasValue = false;
+ /* TODO remove this magic number */
+ for (int periodIndex = 1; periodIndex <= 5; periodIndex++) {
+ Long elements = countElementsForNewCode(context, periodIndex);
+
+ if (elements != null && elements > 0L) {
+ long coveredElements = countCoveredElementsForNewCode(context, periodIndex);
+ measure.setVariation(periodIndex, calculateCoverage(coveredElements, elements));
+ hasValue = true;
+ }
+ }
+ if (hasValue) {
+ context.saveMeasure(measure);
}
- }
- if (hasValue) {
- context.saveMeasure(measure);
}
}