]> source.dussan.org Git - sonarqube.git/commitdiff
Fix quality flaws
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 27 Apr 2015 10:11:55 +0000 (12:11 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 27 Apr 2015 10:11:55 +0000 (12:11 +0200)
server/sonar-server/src/main/java/org/sonar/server/computation/source/DuplicationLineReader.java
server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelOperations.java
server/sonar-server/src/main/java/org/sonar/server/issue/Result.java
server/sonar-server/src/main/java/org/sonar/server/measure/MeasureFilterResult.java
server/sonar-server/src/main/java/org/sonar/server/measure/MeasureFilterSort.java
sonar-batch/src/main/java/org/sonar/batch/debt/DebtDecorator.java
sonar-core/src/main/java/org/sonar/core/issue/db/ActionPlanDto.java
sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/internal/DefaultCharacteristic.java
sonar-plugin-api/src/main/java/org/sonar/api/utils/Durations.java

index bdd1bbea633fc06d72e8dd31ad7456db5c368ed1..275f431da01a5392f17c13b0032f017a60e205fb 100644 (file)
@@ -79,7 +79,7 @@ public class DuplicationLineReader implements LineReader {
   }
 
   private static int length(BatchReport.Range range) {
-    return range.getEndLine() - range.getStartLine() + 1;
+    return (range.getEndLine() - range.getStartLine()) + 1;
   }
 
   private Map<BatchReport.Range, Integer> createDuplicationIdsByRange(List<BatchReport.Duplication> duplications) {
index fcb32e591e83b3905e386c2212cf0d67fa81c897..1a264f90ba516f9e2512826d6bdb97e0cc8f9af6 100644 (file)
@@ -171,8 +171,10 @@ public class DebtModelOperations implements ServerComponent {
         return input != null && input.getKey().equals(dto.getKey());
       }
     });
-    Integer nextPosition = moveUpOrDown ? (currentPosition > 0 ? currentPosition - 1 : null) : (currentPosition < rootCharacteristics.size() - 1 ? currentPosition + 1 : null);
-    return nextPosition != null ? Iterables.get(rootCharacteristics, nextPosition) : null;
+    Integer nextPosition = moveUpOrDown ?
+      ((currentPosition > 0) ? (currentPosition - 1) : null) :
+      ((currentPosition < (rootCharacteristics.size() - 1)) ? (currentPosition + 1) : null);
+    return (nextPosition != null) ? Iterables.get(rootCharacteristics, nextPosition) : null;
   }
 
   /**
index 49d56286d9a7721fedb43babb5db8869ea33b17c..ccf2c867502c655be3172b968c2f849e5cabd9c8 100644 (file)
@@ -23,6 +23,7 @@ import org.apache.commons.lang.builder.ReflectionToStringBuilder;
 
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
+
 import java.util.Arrays;
 import java.util.List;
 
@@ -135,7 +136,7 @@ public class Result<T> {
       if (!Arrays.equals(l10nParams, message.l10nParams)) {
         return false;
       }
-      if (text != null ? !text.equals(message.text) : message.text != null) {
+      if ((text != null) ? !text.equals(message.text) : (message.text != null)) {
         return false;
       }
       return true;
index 80e0612af333bbcfbda371520930e35df4267656..606938c5223c352a3c7d7ca1c9330b8610984503 100644 (file)
@@ -25,7 +25,7 @@ import java.util.List;
 
 public class MeasureFilterResult {
 
-  public static enum Error {
+  public enum Error {
     UNKNOWN, VALUE_SHOULD_BE_A_NUMBER
   }
 
index 584234f1e3acc013bd49e10739dcbd76b7a13369..08f8209bbd1106dc6c88982d02f9e68bdf221928 100644 (file)
@@ -123,7 +123,7 @@ class MeasureFilterSort {
 
   private String getMetricColumn() {
     if (metric.isNumericType()) {
-      return period != null ? "pmsort.variation_value_" + period : "pmsort.value";
+      return (period != null) ? ("pmsort.variation_value_" + period) : "pmsort.value";
     } else {
       return "pmsort.text_value";
     }
index f4521d664a672e8700018df1d754f01c7c2621aa..d9912f45b4bbe1297017ff90c98f65ea4a655ebe 100644 (file)
@@ -202,7 +202,7 @@ public final class DebtDecorator implements Decorator {
     public void add(@Nullable E key, Long value) {
       if (key != null) {
         Long currentValue = sumByKeys.get(key);
-        sumByKeys.put(key, currentValue != null ? currentValue + value : value);
+        sumByKeys.put(key, (currentValue != null) ? (currentValue + value) : value);
       }
     }
 
index fac4c384dab14ca79edca1eff501d0f850269f87..e9179d671513d474bf78bbca63f4bf5ec78f581c 100644 (file)
@@ -163,7 +163,7 @@ public class ActionPlanDto {
     }
 
     ActionPlanDto actionPlanDto = (ActionPlanDto) o;
-    return !(id != null ? !id.equals(actionPlanDto.id) : actionPlanDto.id != null);
+    return !((id != null) ? !id.equals(actionPlanDto.id) : (actionPlanDto.id != null));
   }
 
   @Override
index bdda2b6a865cb4cf953127ebca23fc563c9620b3..06d2c2b53bbb9accab7762c6fbda7d9bb254f05e 100644 (file)
@@ -328,7 +328,7 @@ public class DefaultCharacteristic implements Characteristic {
 
     DefaultCharacteristic that = (DefaultCharacteristic) o;
 
-    if (key != null ? !key.equals(that.key) : that.key != null) {
+    if ((key != null) ? !key.equals(that.key) : (that.key != null)) {
       return false;
     }
     return !(ruleKey != null ? !ruleKey.equals(that.ruleKey) : that.ruleKey != null);
@@ -337,8 +337,8 @@ public class DefaultCharacteristic implements Characteristic {
 
   @Override
   public int hashCode() {
-    int result = key != null ? key.hashCode() : 0;
-    result = 31 * result + (ruleKey != null ? ruleKey.hashCode() : 0);
+    int result = (key != null) ? key.hashCode() : 0;
+    result = 31 * result + ((ruleKey != null) ? ruleKey.hashCode() : 0);
     return result;
   }
 
index a181b788b75a58cecfc1afcaedb89fe38d5ba48f..9089c44183621f403ef43a1c04483818e62bfc4d 100644 (file)
@@ -27,6 +27,7 @@ import org.sonar.api.config.Settings;
 import org.sonar.api.i18n.I18n;
 
 import javax.annotation.CheckForNull;
+
 import java.util.Locale;
 
 /**
@@ -113,15 +114,15 @@ public class Durations implements BatchComponent, ServerComponent {
   private String format(Locale locale, int days, int hours, int minutes, boolean isNegative){
     StringBuilder message = new StringBuilder();
     if (days > 0) {
-      message.append(message(locale, "work_duration.x_days", isNegative ? -1 * days : days));
+      message.append(message(locale, "work_duration.x_days", isNegative ? (-1 * days) : days));
     }
     if (displayHours(days, hours)) {
       addSpaceIfNeeded(message);
-      message.append(message(locale, "work_duration.x_hours", isNegative && message.length() == 0 ? -1 * hours : hours));
+      message.append(message(locale, "work_duration.x_hours", (isNegative && message.length() == 0) ? (-1 * hours) : hours));
     }
     if (displayMinutes(days, hours, minutes)) {
       addSpaceIfNeeded(message);
-      message.append(message(locale, "work_duration.x_minutes", isNegative && message.length() == 0 ? -1 * minutes : minutes));
+      message.append(message(locale, "work_duration.x_minutes", (isNegative && message.length() == 0) ? (-1 * minutes) : minutes));
     }
     return message.toString();
   }