Adjust to codacy complaints

codacy does not like raw Exceptions ;-(

- Remove unused method
This commit is contained in:
chimp1984 2020-08-31 19:36:19 -05:00
parent 7b3dc54815
commit 4323b417b1
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3
3 changed files with 35 additions and 19 deletions

View File

@ -46,7 +46,7 @@ public class CryptoNoteAddressValidator implements AddressValidator {
}
}
return AddressValidationResult.invalidAddress(String.format("invalid address prefix %x", prefix));
} catch (Exception e) {
} catch (CryptoNoteUtils.CryptoNoteException e) {
return AddressValidationResult.invalidStructure();
}
}

View File

@ -34,7 +34,7 @@ public class CryptoNoteUtils {
// omit the type (1st byte) and checksum (last 4 byte)
byte[] slice = Arrays.copyOfRange(decoded, 1, decoded.length - 4);
return Utils.HEX.encode(slice);
} catch (Exception e) {
} catch (CryptoNoteException e) {
e.printStackTrace();
}
return null;
@ -155,7 +155,7 @@ public class CryptoNoteUtils {
int inputLength,
byte[] decoded,
int decodedOffset,
int decodedLength) throws Exception {
int decodedLength) throws CryptoNoteException {
BigInteger result = BigInteger.ZERO;
@ -164,17 +164,17 @@ public class CryptoNoteUtils {
char character = input.charAt(--index);
int digit = ALPHABET.indexOf(character);
if (digit == -1) {
throw new Exception("invalid character " + character);
throw new CryptoNoteException("invalid character " + character);
}
result = result.add(order.multiply(BigInteger.valueOf(digit)));
if (result.compareTo(UINT64_MAX) > 0) {
throw new Exception("64-bit unsigned integer overflow " + result.toString());
throw new CryptoNoteException("64-bit unsigned integer overflow " + result.toString());
}
}
BigInteger maxCapacity = BigInteger.ONE.shiftLeft(8 * decodedLength);
if (result.compareTo(maxCapacity) >= 0) {
throw new Exception("capacity overflow " + result.toString());
throw new CryptoNoteException("capacity overflow " + result.toString());
}
for (int index = decodedOffset + decodedLength; index != decodedOffset; result = result.shiftRight(8)) {
@ -182,7 +182,7 @@ public class CryptoNoteUtils {
}
}
public static byte[] decode(String input) throws Exception {
public static byte[] decode(String input) throws CryptoNoteException {
if (input.length() == 0) {
return new byte[0];
}
@ -218,12 +218,12 @@ public class CryptoNoteUtils {
return result;
}
static long decodeAddress(String address, boolean validateChecksum) throws Exception {
static long decodeAddress(String address, boolean validateChecksum) throws CryptoNoteException {
byte[] decoded = decode(address);
int checksumSize = 4;
if (decoded.length < checksumSize) {
throw new Exception("invalid length");
throw new CryptoNoteException("invalid length");
}
ByteBuffer decodedAddress = ByteBuffer.wrap(decoded, 0, decoded.length - checksumSize);
@ -237,11 +237,35 @@ public class CryptoNoteUtils {
int checksum = fastHash.getInt();
int expected = ByteBuffer.wrap(decoded, decoded.length - checksumSize, checksumSize).getInt();
if (checksum != expected) {
throw new Exception(String.format("invalid checksum %08X, expected %08X", checksum, expected));
throw new CryptoNoteException(String.format("invalid checksum %08X, expected %08X", checksum, expected));
}
return prefix;
}
}
static class CryptoNoteException extends Exception {
public CryptoNoteException() {
}
public CryptoNoteException(String message) {
super(message);
}
public CryptoNoteException(String message, Throwable cause) {
super(message, cause);
}
public CryptoNoteException(Throwable cause) {
super(cause);
}
public CryptoNoteException(String message,
Throwable cause,
boolean enableSuppression,
boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}
}

View File

@ -43,12 +43,12 @@ import bisq.desktop.util.DisplayUtils;
import bisq.desktop.util.Transitions;
import bisq.core.dao.monitoring.DaoStateMonitoringService;
import bisq.common.BisqException;
import bisq.core.locale.GlobalSettings;
import bisq.core.locale.LanguageUtil;
import bisq.core.locale.Res;
import bisq.core.provider.price.MarketPrice;
import bisq.common.BisqException;
import bisq.common.Timer;
import bisq.common.UserThread;
import bisq.common.app.Version;
@ -77,7 +77,6 @@ import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.text.TextAlignment;
@ -444,13 +443,6 @@ public class MainView extends InitializableView<StackPane, MainViewModel>
return separator;
}
@NotNull
private Region getNavigationSpacer() {
final Region spacer = new Region();
HBox.setHgrow(spacer, Priority.ALWAYS);
return spacer;
}
private Tuple2<Label, VBox> getBalanceBox(String text) {
Label balanceDisplay = new Label();
balanceDisplay.getStyleClass().add("nav-balance-display");