From 24327c11a52a01d3562eb78a0d4d99533decf543 Mon Sep 17 00:00:00 2001 From: Bruno Andrade Date: Mon, 12 Jul 2021 09:10:08 -0300 Subject: [PATCH] Code smell fix: Remove redundant casts --- .../main/java/org/sonar/server/es/newindex/FieldAware.java | 6 +++--- .../main/java/org/sonar/duplications/block/ByteArray.java | 3 +-- .../src/main/java/org/sonar/api/utils/ZipUtils.java | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/es/newindex/FieldAware.java b/server/sonar-server-common/src/main/java/org/sonar/server/es/newindex/FieldAware.java index 47a30289863a..27d6a27e771f 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/es/newindex/FieldAware.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/es/newindex/FieldAware.java @@ -43,17 +43,17 @@ protected final U setField(String fieldName, Object attributes) { @SuppressWarnings("unchecked") public KeywordFieldBuilder keywordFieldBuilder(String fieldName) { - return (KeywordFieldBuilder) new KeywordFieldBuilder(this, fieldName); + return new KeywordFieldBuilder(this, fieldName); } @SuppressWarnings("unchecked") public TextFieldBuilder textFieldBuilder(String fieldName) { - return (TextFieldBuilder) new TextFieldBuilder(this, fieldName); + return new TextFieldBuilder(this, fieldName); } @SuppressWarnings("unchecked") public NestedFieldBuilder nestedFieldBuilder(String fieldName) { - return (NestedFieldBuilder) new NestedFieldBuilder(this, fieldName); + return new NestedFieldBuilder(this, fieldName); } public U createBooleanField(String fieldName) { diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/block/ByteArray.java b/sonar-duplications/src/main/java/org/sonar/duplications/block/ByteArray.java index 589cb60758c8..2cb7546fd50b 100644 --- a/sonar-duplications/src/main/java/org/sonar/duplications/block/ByteArray.java +++ b/sonar-duplications/src/main/java/org/sonar/duplications/block/ByteArray.java @@ -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 int[] toIntArray() { //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); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/ZipUtils.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/ZipUtils.java index 3b311f22cce3..54f511321c67 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/ZipUtils.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/ZipUtils.java @@ -56,11 +56,11 @@ private ZipUtils() { * @return the target directory */ public static File unzip(File zip, File toDir) throws IOException { - return unzip(zip, toDir, (Predicate) ze -> true); + return unzip(zip, toDir, ze -> true); } public static File unzip(InputStream zip, File toDir) throws IOException { - return unzip(zip, toDir, (Predicate) ze -> true); + return unzip(zip, toDir, ze -> true); } /**