Skip to content

Commit

Permalink
Code smell fix: Remove redundant casts
Browse files Browse the repository at this point in the history
  • Loading branch information
artsmandev authored and sonartech committed Jul 12, 2021
1 parent ae5711e commit 24327c1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
Expand Up @@ -43,17 +43,17 @@ protected final U setField(String fieldName, Object attributes) {

@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) {
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Expand Up @@ -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<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);
}

/**
Expand Down

0 comments on commit 24327c1

Please sign in to comment.