]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5388 Some refactoring
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Thu, 10 Jul 2014 09:09:26 +0000 (11:09 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Thu, 10 Jul 2014 09:09:26 +0000 (11:09 +0200)
sonar-batch/src/main/java/org/sonar/batch/debt/SqaleRatingDecorator.java
sonar-batch/src/main/java/org/sonar/batch/debt/SqaleRatingGrid.java

index dc973dd109ccf0b57ff27f95098105c766aa0d14..84f0267b59990c2a41c11b98ff6b8bc230e45348 100644 (file)
@@ -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;
   }
index 5db6ab6e2ab902586d484e8841e3bb8209af3ba9..ef4e5cd1fcafc02c447ababe77c8687b98005be9 100644 (file)
@@ -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;