mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Apply code inspection suggestions
This commit is contained in:
parent
11eb24bb53
commit
3242d86321
@ -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<>();
|
||||||
|
@ -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;
|
||||||
|
@ -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();
|
||||||
|
@ -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) {
|
||||||
|
@ -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.");
|
||||||
|
@ -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.");
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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) {
|
||||||
|
@ -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) {
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user