aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch/src
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-07-10 11:09:26 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-07-10 11:09:26 +0200
commita197d468f828d98a0cb1a53a1d589dd8d4c44691 (patch)
tree644ae5a042054293156412030a403711daf3d830 /sonar-batch/src
parent9c72b48199e5450b17edacedf04e5f2406b0d5c3 (diff)
downloadsonarqube-a197d468f828d98a0cb1a53a1d589dd8d4c44691.tar.gz
sonarqube-a197d468f828d98a0cb1a53a1d589dd8d4c44691.zip
SONAR-5388 Some refactoring
Diffstat (limited to 'sonar-batch/src')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/debt/SqaleRatingDecorator.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/debt/SqaleRatingGrid.java18
2 files changed, 11 insertions, 9 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/debt/SqaleRatingDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/debt/SqaleRatingDecorator.java
index dc973dd109c..84f0267b599 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/debt/SqaleRatingDecorator.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/debt/SqaleRatingDecorator.java
@@ -97,7 +97,7 @@ public final class SqaleRatingDecorator implements Decorator {
static String toRatingLetter(@Nullable Integer rating) {
if (rating != null) {
- return SqaleRatingGrid.SqaleRating.buildFromIndex(rating).name();
+ return SqaleRatingGrid.SqaleRating.createForIndex(rating).name();
}
return null;
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/debt/SqaleRatingGrid.java b/sonar-batch/src/main/java/org/sonar/batch/debt/SqaleRatingGrid.java
index 5db6ab6e2ab..ef4e5cd1fca 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/debt/SqaleRatingGrid.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/debt/SqaleRatingGrid.java
@@ -20,6 +20,7 @@
package org.sonar.batch.debt;
+import com.google.common.annotations.VisibleForTesting;
import org.sonar.api.utils.MessageException;
import java.util.Arrays;
@@ -32,13 +33,6 @@ class SqaleRatingGrid {
this.gridValues = Arrays.copyOf(gridValues, gridValues.length);
}
- public double getGradeLowerBound(SqaleRating rating) {
- if (rating.getIndex() > 1) {
- return gridValues[rating.getIndex() - 2];
- }
- return 0;
- }
-
public int getRatingForDensity(double density) {
for (SqaleRating sqaleRating : SqaleRating.values()) {
double lowerBound = getGradeLowerBound(sqaleRating);
@@ -49,6 +43,14 @@ class SqaleRatingGrid {
throw MessageException.of("The SQALE density value should be between 0 and " + Double.MAX_VALUE + " and got " + density);
}
+ @VisibleForTesting
+ double getGradeLowerBound(SqaleRating rating) {
+ if (rating.getIndex() > 1) {
+ return gridValues[rating.getIndex() - 2];
+ }
+ return 0;
+ }
+
enum SqaleRating {
E(5),
@@ -67,7 +69,7 @@ class SqaleRatingGrid {
return index;
}
- public static SqaleRating buildFromIndex(int index) {
+ public static SqaleRating createForIndex(int index) {
for (SqaleRating rating : values()) {
if (rating.getIndex() == index) {
return rating;