refactor: Tackle a few Semgrep and ErrorProne violations (#1520)

* refactor: Tackle a few Semgrep and ErrorProne violations

* Address comments
This commit is contained in:
Alex
2022-01-07 12:45:53 +01:00
committed by GitHub
parent f27959e49a
commit 64442a8051
22 changed files with 55 additions and 400 deletions

View File

@ -6,7 +6,9 @@ import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface Link {
Class clazz() default Link.class;
//FAWE start - address rawtypes
Class<?> clazz() default Link.class;
//FAWE end
String value();

View File

@ -192,8 +192,8 @@ public class TargetBlock {
*
* @return Block
*/
@SuppressWarnings("StatementWithEmptyBody")
public Location getTargetBlock() {
//noinspection StatementWithEmptyBody
while (getNextBlock() != null && !stopMask.test(targetPos)) {
}
return getCurrentBlock();
@ -205,8 +205,8 @@ public class TargetBlock {
*
* @return Block
*/
@SuppressWarnings("StatementWithEmptyBody")
public Location getSolidTargetBlock() {
//noinspection StatementWithEmptyBody
while (getNextBlock() != null && !solidMask.test(targetPos)) {
}
return getCurrentBlock();

View File

@ -21,6 +21,7 @@ package com.sk89q.worldedit.util.logging;
import javax.annotation.Nullable;
import java.io.UnsupportedEncodingException;
import java.util.Objects;
import java.util.logging.Filter;
import java.util.logging.Formatter;
import java.util.logging.Level;
@ -131,11 +132,7 @@ public class DynamicStreamHandler extends StreamHandler {
Formatter formatter = this.formatter;
if (handler != null) {
return handler.getFormatter();
} else if (formatter != null) {
return formatter;
} else {
return new SimpleFormatter();
}
} else return Objects.requireNonNullElseGet(formatter, SimpleFormatter::new);
}
@Override

View File

@ -340,6 +340,7 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
//FAWE end
@Override
@SuppressWarnings("RedundantCast")
public Map<Property<?>, Object> getStates() {
//FAWE end
BlockType type = this.getBlockType();
@ -348,7 +349,7 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
type.getPropertiesSet(),
(Function<Property<?>, Object>) this::getState
);
//noinspection RedundantCast - This is required for compilation, etc.
//This is required for compilation, etc.
return Collections.unmodifiableMap((Map<Property<?>, Object>) map);
//FAWE end
}