]> source.dussan.org Git - sonarqube.git/commitdiff
Code smell fix: Remove redundant casts
authorBruno Andrade <bruno@artsman.dev>
Mon, 12 Jul 2021 12:10:08 +0000 (09:10 -0300)
committersonartech <sonartech@sonarsource.com>
Mon, 12 Jul 2021 20:06:52 +0000 (20:06 +0000)
server/sonar-server-common/src/main/java/org/sonar/server/es/newindex/FieldAware.java
sonar-duplications/src/main/java/org/sonar/duplications/block/ByteArray.java
sonar-plugin-api/src/main/java/org/sonar/api/utils/ZipUtils.java

index 47a30289863abc4d2d8e19e6f46f3000d2cd47d0..27d6a27e771f9f907cad3260a2f713d638bc32f6 100644 (file)
@@ -43,17 +43,17 @@ public abstract class FieldAware<U extends FieldAware<U>> {
 
   @SuppressWarnings("unchecked")
   public KeywordFieldBuilder<U> keywordFieldBuilder(String fieldName) {
-    return (KeywordFieldBuilder<U>) new KeywordFieldBuilder(this, fieldName);
+    return new KeywordFieldBuilder(this, fieldName);
   }
 
   @SuppressWarnings("unchecked")
   public TextFieldBuilder<U> textFieldBuilder(String fieldName) {
-    return (TextFieldBuilder<U>) new TextFieldBuilder(this, fieldName);
+    return new TextFieldBuilder(this, fieldName);
   }
 
   @SuppressWarnings("unchecked")
   public NestedFieldBuilder<U> nestedFieldBuilder(String fieldName) {
-    return (NestedFieldBuilder<U>) new NestedFieldBuilder(this, fieldName);
+    return new NestedFieldBuilder(this, fieldName);
   }
 
   public U createBooleanField(String fieldName) {
index 589cb60758c829dd45919c70b8d273e64e840c2f..2cb7546fd50b8ea6fe43ee191626f9e652e0416b 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.duplications.block;
 
-import java.nio.Buffer;
 import java.nio.ByteBuffer;
 import java.nio.IntBuffer;
 import java.util.Arrays;
@@ -97,7 +96,7 @@ public final class ByteArray {
 
     //This is because the generated byte code includes the static return type of the method, which is not found on Java 8 and lower because
     //the overloaded methods with covariant return types don't exist.
-    ((Buffer) bb).rewind();
+    bb.rewind();
     IntBuffer ib = bb.asIntBuffer();
     int[] result = new int[size];
     ib.get(result);
index 3b311f22cce3e74268a727e18ebf58fa58cfdb35..54f511321c67d8f61086c46c7f14c89ede251683 100644 (file)
@@ -56,11 +56,11 @@ public final class ZipUtils {
    * @return the target directory
    */
   public static File unzip(File zip, File toDir) throws IOException {
-    return unzip(zip, toDir, (Predicate<ZipEntry>) ze -> true);
+    return unzip(zip, toDir, ze -> true);
   }
 
   public static File unzip(InputStream zip, File toDir) throws IOException {
-    return unzip(zip, toDir, (Predicate<ZipEntry>) ze -> true);
+    return unzip(zip, toDir, ze -> true);
   }
 
   /**