]> source.dussan.org Git - sonarqube.git/commitdiff
Fix Quality flaw
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 11 Jan 2019 08:57:52 +0000 (09:57 +0100)
committersonartech <sonartech@sonarsource.com>
Wed, 16 Jan 2019 08:42:58 +0000 (09:42 +0100)
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/Measure.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MeasureTest.java

index 672517a0315eacbb1ab54aad1d04dbff252ed9d1..d75d00ab4457edb580a47066689de5346aa1b7d2 100644 (file)
@@ -238,7 +238,7 @@ public final class Measure {
    */
   public boolean getBooleanValue() {
     checkValueType(ValueType.BOOLEAN);
-    return value == 1.0D;
+    return value != null && value.intValue() == 1;
   }
 
   /**
index 378ba83bc96a02f708f60c6eea3b601bf3ca2ca2..4351d5e40c7b51c89f73232fd3d9c53fe9ac53aa 100644 (file)
  */
 package org.sonar.ce.task.projectanalysis.measure;
 
-import com.google.common.base.Predicate;
 import com.google.common.collect.ImmutableList;
 import com.tngtech.java.junit.dataprovider.DataProvider;
 import com.tngtech.java.junit.dataprovider.DataProviderRunner;
 import com.tngtech.java.junit.dataprovider.UseDataProvider;
 import java.util.List;
-import javax.annotation.Nonnull;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
@@ -42,7 +40,7 @@ import static org.sonar.ce.task.projectanalysis.measure.Measure.newMeasureBuilde
 @RunWith(DataProviderRunner.class)
 public class MeasureTest {
 
-  private static final Measure INT_MEASURE = newMeasureBuilder().create((int) 1);
+  private static final Measure INT_MEASURE = newMeasureBuilder().create(1);
   private static final Measure LONG_MEASURE = newMeasureBuilder().create(1l);
   private static final Measure DOUBLE_MEASURE = newMeasureBuilder().create(1d, 1);
   private static final Measure STRING_MEASURE = newMeasureBuilder().create("some_sT ring");
@@ -95,12 +93,7 @@ public class MeasureTest {
 
   private static Object[][] getMeasuresExcept(final ValueType valueType) {
     return from(MEASURES)
-      .filter(new Predicate<Measure>() {
-        @Override
-        public boolean apply(@Nonnull Measure input) {
-          return input.getValueType() != valueType;
-        }
-      }).transform(WrapInSingleElementArray.INSTANCE)
+      .filter(input -> input.getValueType() != valueType).transform(WrapInSingleElementArray.INSTANCE)
       .toArray(Object[].class);
   }