Apply code inspection suggestions

This commit is contained in:
chimp1984 2020-09-29 13:08:55 -05:00
parent 11eb24bb53
commit 3242d86321
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3
10 changed files with 9 additions and 11 deletions

View File

@ -47,6 +47,7 @@ public class Capabilities {
// Defines which most recent capability any node need to support. // Defines which most recent capability any node need to support.
// This helps to clean network from very old inactive but still running nodes. // This helps to clean network from very old inactive but still running nodes.
@SuppressWarnings("deprecation")
private static final Capability MANDATORY_CAPABILITY = Capability.DAO_STATE; private static final Capability MANDATORY_CAPABILITY = Capability.DAO_STATE;
protected final Set<Capability> capabilities = new HashSet<>(); protected final Set<Capability> capabilities = new HashSet<>();

View File

@ -39,7 +39,7 @@ public enum BaseCurrencyNetwork {
@Getter @Getter
private final String network; private final String network;
@Getter @Getter
private String currencyName; private final String currencyName;
BaseCurrencyNetwork(NetworkParameters parameters, String currencyCode, String network, String currencyName) { BaseCurrencyNetwork(NetworkParameters parameters, String currencyCode, String network, String currencyName) {
this.parameters = parameters; this.parameters = parameters;

View File

@ -110,7 +110,7 @@ public class BisqHelpFormatter implements HelpFormatter {
// without any spaces (e.g. a URL) are allowed to overflow the 80-char margin. // without any spaces (e.g. a URL) are allowed to overflow the 80-char margin.
while (remainder.length() > 72) { while (remainder.length() > 72) {
int idxFirstSpace = remainder.indexOf(' '); int idxFirstSpace = remainder.indexOf(' ');
int chunkLen = idxFirstSpace == -1 ? remainder.length() : idxFirstSpace > 73 ? idxFirstSpace : 73; int chunkLen = idxFirstSpace == -1 ? remainder.length() : Math.max(idxFirstSpace, 73);
String chunk = remainder.substring(0, chunkLen); String chunk = remainder.substring(0, chunkLen);
int idxLastSpace = chunk.lastIndexOf(' '); int idxLastSpace = chunk.lastIndexOf(' ');
int idxBreak = idxLastSpace > 0 ? idxLastSpace : chunk.length(); int idxBreak = idxLastSpace > 0 ? idxLastSpace : chunk.length();

View File

@ -815,6 +815,7 @@ public class Config {
private static String randomAppName() { private static String randomAppName() {
try { try {
File file = Files.createTempFile("Bisq", "Temp").toFile(); File file = Files.createTempFile("Bisq", "Temp").toFile();
//noinspection ResultOfMethodCallIgnored
file.delete(); file.delete();
return file.toPath().getFileName().toString(); return file.toPath().getFileName().toString();
} catch (IOException ex) { } catch (IOException ex) {

View File

@ -65,8 +65,7 @@ public class Encryption {
try { try {
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(ASYM_KEY_ALGO); KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(ASYM_KEY_ALGO);
keyPairGenerator.initialize(2048); keyPairGenerator.initialize(2048);
KeyPair keyPair = keyPairGenerator.genKeyPair(); return keyPairGenerator.genKeyPair();
return keyPair;
} catch (Throwable e) { } catch (Throwable e) {
log.error("Could not create key.", e); log.error("Could not create key.", e);
throw new RuntimeException("Could not create key."); throw new RuntimeException("Could not create key.");

View File

@ -60,8 +60,7 @@ public class Sig {
try { try {
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(KEY_ALGO); KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(KEY_ALGO);
keyPairGenerator.initialize(1024); keyPairGenerator.initialize(1024);
KeyPair keyPair = keyPairGenerator.genKeyPair(); return keyPairGenerator.genKeyPair();
return keyPair;
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
log.error("Could not create key.", e); log.error("Could not create key.", e);
throw new RuntimeException("Could not create key."); throw new RuntimeException("Could not create key.");

View File

@ -39,7 +39,6 @@ public interface UserThreadMappedPersistableEnvelope extends PersistableEnvelope
default Message toPersistableMessage() { default Message toPersistableMessage() {
FutureTask<Message> toProtoOnUserThread = new FutureTask<>(this::toProtoMessage); FutureTask<Message> toProtoOnUserThread = new FutureTask<>(this::toProtoMessage);
UserThread.execute(toProtoOnUserThread); UserThread.execute(toProtoOnUserThread);
//noinspection UnstableApiUsage
return Futures.getUnchecked(toProtoOnUserThread); return Futures.getUnchecked(toProtoOnUserThread);
} }
} }

View File

@ -239,7 +239,6 @@ public class FileManager<T extends PersistableEnvelope> {
try { try {
if (fileOutputStream != null) if (fileOutputStream != null)
fileOutputStream.close(); fileOutputStream.close();
//noinspection ConstantConditions,ConstantConditions
if (printWriter != null) if (printWriter != null)
printWriter.close(); printWriter.close();
} catch (IOException e) { } catch (IOException e) {

View File

@ -72,7 +72,7 @@ public class MathUtils {
} }
public static long doubleToLong(double value) { public static long doubleToLong(double value) {
return new Double(value).longValue(); return Double.valueOf(value).longValue();
} }
public static double scaleUpByPowerOf10(double value, int exponent) { public static double scaleUpByPowerOf10(double value, int exponent) {

View File

@ -425,13 +425,13 @@ public class Utilities {
return toTruncatedString(message, maxLength, true); return toTruncatedString(message, maxLength, true);
} }
public static String toTruncatedString(Object message, int maxLength, boolean removeLinebreaks) { public static String toTruncatedString(Object message, int maxLength, boolean removeLineBreaks) {
if (message == null) if (message == null)
return "null"; return "null";
String result = StringUtils.abbreviate(message.toString(), maxLength); String result = StringUtils.abbreviate(message.toString(), maxLength);
if (removeLinebreaks) if (removeLineBreaks)
return result.replace("\n", ""); return result.replace("\n", "");
return result; return result;