Skip to content

Commit 3814e43

Browse files
authored
fixed several code issues found by sonar (#2113)
* fixed several code issues found by sonar Signed-off-by: Julius Lauterbach <[email protected]> * fix for Bip44WalletUtils Signed-off-by: Julius Lauterbach <[email protected]> --------- Signed-off-by: Julius Lauterbach <[email protected]>
1 parent 47eff8c commit 3814e43

File tree

61 files changed

+568
-641
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+568
-641
lines changed

core/src/main/java/org/web3j/crypto/Wallet.java

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ public class Wallet {
7272
static final String AES_128_CTR = "pbkdf2";
7373
static final String SCRYPT = "scrypt";
7474

75+
private Wallet() {}
76+
7577
public static WalletFile create(String password, ECKeyPair ecKeyPair, int n, int p)
7678
throws CipherException {
7779

core/src/main/java/org/web3j/ens/Contracts.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
/** ENS registry contract addresses. */
1818
public class Contracts {
19-
2019
public static final String MAINNET = "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
2120
public static final String ROPSTEN = "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
2221
public static final String RINKEBY = "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
@@ -26,6 +25,8 @@ public class Contracts {
2625
public static final String LINEA = "0x50130b669B28C339991d8676FA73CF122a121267";
2726
public static final String LINEA_SEPOLIA = "0x5B2636F0f2137B4aE722C01dd5122D7d3e9541f7";
2827

28+
private Contracts() {}
29+
2930
public static String resolveRegistryContract(String chainId) {
3031
final Long chainIdLong = Long.parseLong(chainId);
3132
if (chainIdLong.equals(ChainIdLong.MAINNET)) {

core/src/main/java/org/web3j/ens/NameHash.java

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public static byte[] nameHashAsBytes(String ensName) {
3232
return Numeric.hexStringToByteArray(nameHash(ensName));
3333
}
3434

35+
private NameHash() {}
36+
3537
public static String nameHash(String ensName) {
3638
String normalisedEnsName = normalise(ensName);
3739
return Numeric.toHexString(nameHash(normalisedEnsName.split("\\.")));

core/src/main/java/org/web3j/ens/contracts/generated/ENS.java

+3-8
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,18 @@ public class ENS extends Contract {
6666

6767
public static final Event APPROVALFORALL_EVENT = new Event("ApprovalForAll",
6868
Arrays.<TypeReference<?>>asList(new TypeReference<Address>(true) {}, new TypeReference<Address>(true) {}, new TypeReference<Bool>() {}));
69-
;
7069

7170
public static final Event NEWOWNER_EVENT = new Event("NewOwner",
7271
Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>(true) {}, new TypeReference<Bytes32>(true) {}, new TypeReference<Address>() {}));
73-
;
7472

7573
public static final Event NEWRESOLVER_EVENT = new Event("NewResolver",
7674
Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>(true) {}, new TypeReference<Address>() {}));
77-
;
7875

7976
public static final Event NEWTTL_EVENT = new Event("NewTTL",
8077
Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>(true) {}, new TypeReference<Uint64>() {}));
81-
;
8278

8379
public static final Event TRANSFER_EVENT = new Event("Transfer",
8480
Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>(true) {}, new TypeReference<Address>() {}));
85-
;
8681

8782
@Deprecated
8883
protected ENS(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
@@ -139,7 +134,7 @@ public Flowable<ApprovalForAllEventResponse> approvalForAllEventFlowable(Default
139134

140135
public List<NewOwnerEventResponse> getNewOwnerEvents(TransactionReceipt transactionReceipt) {
141136
List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(NEWOWNER_EVENT, transactionReceipt);
142-
ArrayList<NewOwnerEventResponse> responses = new ArrayList<NewOwnerEventResponse>(valueList.size());
137+
ArrayList<NewOwnerEventResponse> responses = new ArrayList<>(valueList.size());
143138
for (Contract.EventValuesWithLog eventValues : valueList) {
144139
NewOwnerEventResponse typedResponse = new NewOwnerEventResponse();
145140
typedResponse.log = eventValues.getLog();
@@ -174,7 +169,7 @@ public Flowable<NewOwnerEventResponse> newOwnerEventFlowable(DefaultBlockParamet
174169

175170
public List<NewResolverEventResponse> getNewResolverEvents(TransactionReceipt transactionReceipt) {
176171
List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(NEWRESOLVER_EVENT, transactionReceipt);
177-
ArrayList<NewResolverEventResponse> responses = new ArrayList<NewResolverEventResponse>(valueList.size());
172+
ArrayList<NewResolverEventResponse> responses = new ArrayList<>(valueList.size());
178173
for (Contract.EventValuesWithLog eventValues : valueList) {
179174
NewResolverEventResponse typedResponse = new NewResolverEventResponse();
180175
typedResponse.log = eventValues.getLog();
@@ -207,7 +202,7 @@ public Flowable<NewResolverEventResponse> newResolverEventFlowable(DefaultBlockP
207202

208203
public List<NewTTLEventResponse> getNewTTLEvents(TransactionReceipt transactionReceipt) {
209204
List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(NEWTTL_EVENT, transactionReceipt);
210-
ArrayList<NewTTLEventResponse> responses = new ArrayList<NewTTLEventResponse>(valueList.size());
205+
ArrayList<NewTTLEventResponse> responses = new ArrayList<>(valueList.size());
211206
for (Contract.EventValuesWithLog eventValues : valueList) {
212207
NewTTLEventResponse typedResponse = new NewTTLEventResponse();
213208
typedResponse.log = eventValues.getLog();

core/src/main/java/org/web3j/ens/contracts/generated/ENSRegistryWithFallbackContract.java

+5-10
Original file line numberDiff line numberDiff line change
@@ -68,23 +68,18 @@ public class ENSRegistryWithFallbackContract extends Contract {
6868

6969
public static final Event APPROVALFORALL_EVENT = new Event("ApprovalForAll",
7070
Arrays.<TypeReference<?>>asList(new TypeReference<Address>(true) {}, new TypeReference<Address>(true) {}, new TypeReference<Bool>() {}));
71-
;
7271

7372
public static final Event NEWOWNER_EVENT = new Event("NewOwner",
7473
Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>(true) {}, new TypeReference<Bytes32>(true) {}, new TypeReference<Address>() {}));
75-
;
7674

7775
public static final Event NEWRESOLVER_EVENT = new Event("NewResolver",
7876
Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>(true) {}, new TypeReference<Address>() {}));
79-
;
8077

8178
public static final Event NEWTTL_EVENT = new Event("NewTTL",
8279
Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>(true) {}, new TypeReference<Uint64>() {}));
83-
;
8480

8581
public static final Event TRANSFER_EVENT = new Event("Transfer",
8682
Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>(true) {}, new TypeReference<Address>() {}));
87-
;
8883

8984
@Deprecated
9085
protected ENSRegistryWithFallbackContract(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
@@ -106,7 +101,7 @@ protected ENSRegistryWithFallbackContract(String contractAddress, Web3j web3j, T
106101

107102
public List<ApprovalForAllEventResponse> getApprovalForAllEvents(TransactionReceipt transactionReceipt) {
108103
List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(APPROVALFORALL_EVENT, transactionReceipt);
109-
ArrayList<ApprovalForAllEventResponse> responses = new ArrayList<ApprovalForAllEventResponse>(valueList.size());
104+
ArrayList<ApprovalForAllEventResponse> responses = new ArrayList<>(valueList.size());
110105
for (Contract.EventValuesWithLog eventValues : valueList) {
111106
ApprovalForAllEventResponse typedResponse = new ApprovalForAllEventResponse();
112107
typedResponse.log = eventValues.getLog();
@@ -141,7 +136,7 @@ public Flowable<ApprovalForAllEventResponse> approvalForAllEventFlowable(Default
141136

142137
public List<NewOwnerEventResponse> getNewOwnerEvents(TransactionReceipt transactionReceipt) {
143138
List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(NEWOWNER_EVENT, transactionReceipt);
144-
ArrayList<NewOwnerEventResponse> responses = new ArrayList<NewOwnerEventResponse>(valueList.size());
139+
ArrayList<NewOwnerEventResponse> responses = new ArrayList<>(valueList.size());
145140
for (Contract.EventValuesWithLog eventValues : valueList) {
146141
NewOwnerEventResponse typedResponse = new NewOwnerEventResponse();
147142
typedResponse.log = eventValues.getLog();
@@ -176,7 +171,7 @@ public Flowable<NewOwnerEventResponse> newOwnerEventFlowable(DefaultBlockParamet
176171

177172
public List<NewResolverEventResponse> getNewResolverEvents(TransactionReceipt transactionReceipt) {
178173
List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(NEWRESOLVER_EVENT, transactionReceipt);
179-
ArrayList<NewResolverEventResponse> responses = new ArrayList<NewResolverEventResponse>(valueList.size());
174+
ArrayList<NewResolverEventResponse> responses = new ArrayList<>(valueList.size());
180175
for (Contract.EventValuesWithLog eventValues : valueList) {
181176
NewResolverEventResponse typedResponse = new NewResolverEventResponse();
182177
typedResponse.log = eventValues.getLog();
@@ -209,7 +204,7 @@ public Flowable<NewResolverEventResponse> newResolverEventFlowable(DefaultBlockP
209204

210205
public List<NewTTLEventResponse> getNewTTLEvents(TransactionReceipt transactionReceipt) {
211206
List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(NEWTTL_EVENT, transactionReceipt);
212-
ArrayList<NewTTLEventResponse> responses = new ArrayList<NewTTLEventResponse>(valueList.size());
207+
ArrayList<NewTTLEventResponse> responses = new ArrayList<>(valueList.size());
213208
for (Contract.EventValuesWithLog eventValues : valueList) {
214209
NewTTLEventResponse typedResponse = new NewTTLEventResponse();
215210
typedResponse.log = eventValues.getLog();
@@ -242,7 +237,7 @@ public Flowable<NewTTLEventResponse> newTTLEventFlowable(DefaultBlockParameter s
242237

243238
public List<TransferEventResponse> getTransferEvents(TransactionReceipt transactionReceipt) {
244239
List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(TRANSFER_EVENT, transactionReceipt);
245-
ArrayList<TransferEventResponse> responses = new ArrayList<TransferEventResponse>(valueList.size());
240+
ArrayList<TransferEventResponse> responses = new ArrayList<>(valueList.size());
246241
for (Contract.EventValuesWithLog eventValues : valueList) {
247242
TransferEventResponse typedResponse = new TransferEventResponse();
248243
typedResponse.log = eventValues.getLog();

core/src/main/java/org/web3j/ens/contracts/generated/OffchainResolverContract.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ public class OffchainResolverContract extends PublicResolver {
6060

6161
public static final Event NEWSIGNERS_EVENT = new Event("NewSigners",
6262
Arrays.<TypeReference<?>>asList(new TypeReference<DynamicArray<Address>>() {}));
63-
;
6463

6564
public OffchainResolverContract(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
6665
super(contractAddress, web3j, credentials, gasPrice, gasLimit);
@@ -80,7 +79,7 @@ public OffchainResolverContract(String contractAddress, Web3j web3j, Transaction
8079

8180
public List<NewSignersEventResponse> getNewSignersEvents(TransactionReceipt transactionReceipt) {
8281
List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(NEWSIGNERS_EVENT, transactionReceipt);
83-
ArrayList<NewSignersEventResponse> responses = new ArrayList<NewSignersEventResponse>(valueList.size());
82+
ArrayList<NewSignersEventResponse> responses = new ArrayList<>(valueList.size());
8483
for (Contract.EventValuesWithLog eventValues : valueList) {
8584
NewSignersEventResponse typedResponse = new NewSignersEventResponse();
8685
typedResponse.log = eventValues.getLog();

0 commit comments

Comments
 (0)