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.
// This helps to clean network from very old inactive but still running nodes.
@SuppressWarnings("deprecation")
private static final Capability MANDATORY_CAPABILITY = Capability.DAO_STATE;
protected final Set<Capability> capabilities = new HashSet<>();

View File

@ -39,7 +39,7 @@ public enum BaseCurrencyNetwork {
@Getter
private final String network;
@Getter
private String currencyName;
private final String currencyName;
BaseCurrencyNetwork(NetworkParameters parameters, String currencyCode, String network, String currencyName) {
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.
while (remainder.length() > 72) {
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);
int idxLastSpace = chunk.lastIndexOf(' ');
int idxBreak = idxLastSpace > 0 ? idxLastSpace : chunk.length();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -425,13 +425,13 @@ public class Utilities {
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)
return "null";
String result = StringUtils.abbreviate(message.toString(), maxLength);
if (removeLinebreaks)
if (removeLineBreaks)
return result.replace("\n", "");
return result;