diff --git a/build.gradle b/build.gradle index a750f6a3..989fb77b 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ plugins { id "com.diffplug.gradle.spotless" version "3.10.0" id "com.github.hierynomus.license" version "0.14.0" id "com.jfrog.bintray" version "1.8.0" - id 'net.ltgt.errorprone' version '0.0.13' + id 'net.ltgt.errorprone' version '0.0.14' } apply plugin: 'java-library' @@ -93,7 +93,11 @@ tasks.withType(JavaCompile) { '-Xlint:finally', '-Xlint:static', '-Werror', - '-Xep:FutureReturnValueIgnored:OFF' + '-Xep:FutureReturnValueIgnored:OFF', + '-Xep:InsecureCryptoUsage:WARN', + '-Xep:FieldCanBeFinal:WARN', + '-Xep:WildcardImport:WARN', + '-Xep:TestExceptionChecker:WARN' ] } diff --git a/src/main/java/net/consensys/orion/cmd/Orion.java b/src/main/java/net/consensys/orion/cmd/Orion.java index 0f4fb916..27580408 100644 --- a/src/main/java/net/consensys/orion/cmd/Orion.java +++ b/src/main/java/net/consensys/orion/cmd/Orion.java @@ -169,7 +169,7 @@ public Orion(Vertx vertx) { this.vertx = vertx; } - private AtomicBoolean isRunning = new AtomicBoolean(false); + private final AtomicBoolean isRunning = new AtomicBoolean(false); public void stop() { if (!isRunning.compareAndSet(true, false)) { diff --git a/src/main/java/net/consensys/orion/enclave/sodium/SodiumEnclave.java b/src/main/java/net/consensys/orion/enclave/sodium/SodiumEnclave.java index 02eb7340..93fe627e 100644 --- a/src/main/java/net/consensys/orion/enclave/sodium/SodiumEnclave.java +++ b/src/main/java/net/consensys/orion/enclave/sodium/SodiumEnclave.java @@ -33,7 +33,7 @@ public class SodiumEnclave implements Enclave { private static final Nonce ZERO_NONCE = Nonce.fromBytes(new byte[Nonce.length()]); - private KeyStore keyStore; + private final KeyStore keyStore; private final Box.PublicKey[] alwaysSendTo; private final Box.PublicKey[] nodeKeys; diff --git a/src/main/java/net/consensys/orion/network/NetworkDiscovery.java b/src/main/java/net/consensys/orion/network/NetworkDiscovery.java index 43307a24..4fed4cba 100644 --- a/src/main/java/net/consensys/orion/network/NetworkDiscovery.java +++ b/src/main/java/net/consensys/orion/network/NetworkDiscovery.java @@ -101,7 +101,7 @@ public Map discoverers() { * Its job is to call /partyInfo periodically on a specified URL and merge results if needed in NetworkDiscovery state */ class Discoverer implements Handler { - private URL nodeUrl; + private final URL nodeUrl; long currentRefreshDelay; Instant lastUpdate = Instant.MIN; long attempts = 0; diff --git a/src/test/java/net/consensys/orion/cmd/OrionTest.java b/src/test/java/net/consensys/orion/cmd/OrionTest.java index 3a897ace..30875886 100644 --- a/src/test/java/net/consensys/orion/cmd/OrionTest.java +++ b/src/test/java/net/consensys/orion/cmd/OrionTest.java @@ -41,7 +41,7 @@ @ExtendWith(TempDirectoryExtension.class) class OrionTest { - private Orion orion = new Orion(); + private final Orion orion = new Orion(); @Test void generateUnlockedKeysWithArgumentProvided(@TempDirectory Path tempDir) throws Exception { diff --git a/src/test/java/net/consensys/orion/http/CAOrTofuSecurityTest.java b/src/test/java/net/consensys/orion/http/CAOrTofuSecurityTest.java index 97bb029f..0349b75d 100644 --- a/src/test/java/net/consensys/orion/http/CAOrTofuSecurityTest.java +++ b/src/test/java/net/consensys/orion/http/CAOrTofuSecurityTest.java @@ -49,7 +49,7 @@ @ExtendWith(TempDirectoryExtension.class) class CAOrTofuSecurityTest { - private static Vertx vertx = vertx(); + private final static Vertx vertx = vertx(); private static Path knownClientsFile; private static String exampleComFingerprint; private static HttpClient nonCAhttpClient; diff --git a/src/test/java/net/consensys/orion/http/CertificateAuthoritySecurityTest.java b/src/test/java/net/consensys/orion/http/CertificateAuthoritySecurityTest.java index f7cad693..d56a3c51 100644 --- a/src/test/java/net/consensys/orion/http/CertificateAuthoritySecurityTest.java +++ b/src/test/java/net/consensys/orion/http/CertificateAuthoritySecurityTest.java @@ -45,7 +45,7 @@ @ExtendWith(TempDirectoryExtension.class) class CertificateAuthoritySecurityTest { - private static Vertx vertx = vertx(); + private final static Vertx vertx = vertx(); private static HttpClient httpClient; private static int nodePort; private static Orion orion; diff --git a/src/test/java/net/consensys/orion/http/InsecureSecurityTest.java b/src/test/java/net/consensys/orion/http/InsecureSecurityTest.java index f807318b..6c3a5457 100644 --- a/src/test/java/net/consensys/orion/http/InsecureSecurityTest.java +++ b/src/test/java/net/consensys/orion/http/InsecureSecurityTest.java @@ -49,7 +49,7 @@ @ExtendWith(TempDirectoryExtension.class) class InsecureSecurityTest { - private static Vertx vertx = vertx(); + private final static Vertx vertx = vertx(); private static Path knownClientsFile; private static String exampleComFingerprint; private static HttpClient httpClient; diff --git a/src/test/java/net/consensys/orion/http/TofuSecurityTest.java b/src/test/java/net/consensys/orion/http/TofuSecurityTest.java index 70d7a193..49dd98ed 100644 --- a/src/test/java/net/consensys/orion/http/TofuSecurityTest.java +++ b/src/test/java/net/consensys/orion/http/TofuSecurityTest.java @@ -50,7 +50,7 @@ @ExtendWith(TempDirectoryExtension.class) class TofuSecurityTest { - private Vertx vertx = vertx(); + private final Vertx vertx = vertx(); private Path knownClientsFile; private String exampleComFingerprint; private HttpClient httpClient; diff --git a/src/test/java/net/consensys/orion/http/WhiteListSecurityTest.java b/src/test/java/net/consensys/orion/http/WhiteListSecurityTest.java index 8acd67b6..423bcdaa 100644 --- a/src/test/java/net/consensys/orion/http/WhiteListSecurityTest.java +++ b/src/test/java/net/consensys/orion/http/WhiteListSecurityTest.java @@ -49,7 +49,7 @@ @ExtendWith(TempDirectoryExtension.class) class WhiteListSecurityTest { - private static Vertx vertx = vertx(); + private final static Vertx vertx = vertx(); private static HttpClient httpClient; private static HttpClient httpClientWithUnregisteredCert; private static HttpClient httpClientWithImproperCertificate; diff --git a/src/test/java/net/consensys/orion/network/CaOrTofuNodeClientTest.java b/src/test/java/net/consensys/orion/network/CaOrTofuNodeClientTest.java index 1a3f4806..aea9dd91 100644 --- a/src/test/java/net/consensys/orion/network/CaOrTofuNodeClientTest.java +++ b/src/test/java/net/consensys/orion/network/CaOrTofuNodeClientTest.java @@ -51,7 +51,7 @@ @ExtendWith(TempDirectoryExtension.class) class CaOrTofuNodeClientTest { - private static Vertx vertx = Vertx.vertx(); + private final static Vertx vertx = Vertx.vertx(); private static HttpServer caValidServer; private static HttpServer tofuServer; private static String fooFingerprint; diff --git a/src/test/java/net/consensys/orion/network/CertificateAuthorityNodeClientTest.java b/src/test/java/net/consensys/orion/network/CertificateAuthorityNodeClientTest.java index 3992a761..20464cba 100644 --- a/src/test/java/net/consensys/orion/network/CertificateAuthorityNodeClientTest.java +++ b/src/test/java/net/consensys/orion/network/CertificateAuthorityNodeClientTest.java @@ -52,7 +52,7 @@ @ExtendWith(TempDirectoryExtension.class) class CertificateAuthorityNodeClientTest { - private static Vertx vertx = Vertx.vertx(); + private final static Vertx vertx = Vertx.vertx(); private static HttpServer caValidServer; private static HttpServer unknownServer; private static HttpClient client; diff --git a/src/test/java/net/consensys/orion/network/InsecureNodeClientTest.java b/src/test/java/net/consensys/orion/network/InsecureNodeClientTest.java index b3050cb7..0dd9782d 100644 --- a/src/test/java/net/consensys/orion/network/InsecureNodeClientTest.java +++ b/src/test/java/net/consensys/orion/network/InsecureNodeClientTest.java @@ -50,7 +50,7 @@ @ExtendWith(TempDirectoryExtension.class) class InsecureNodeClientTest { - private static Vertx vertx = Vertx.vertx(); + private final static Vertx vertx = Vertx.vertx(); private static HttpServer insecureServer; private static HttpServer foobarComServer; private static Path knownServersFile; diff --git a/src/test/java/net/consensys/orion/network/TofuNodeClientTest.java b/src/test/java/net/consensys/orion/network/TofuNodeClientTest.java index 22bd4269..02d4d346 100644 --- a/src/test/java/net/consensys/orion/network/TofuNodeClientTest.java +++ b/src/test/java/net/consensys/orion/network/TofuNodeClientTest.java @@ -56,7 +56,7 @@ @ExtendWith(TempDirectoryExtension.class) class TofuNodeClientTest { - private static Vertx vertx = Vertx.vertx(); + private final static Vertx vertx = Vertx.vertx(); private static Config config; private static Path knownServersFile; diff --git a/src/test/java/net/consensys/orion/network/WhitelistNodeClientTest.java b/src/test/java/net/consensys/orion/network/WhitelistNodeClientTest.java index 015b919f..e9af7e17 100644 --- a/src/test/java/net/consensys/orion/network/WhitelistNodeClientTest.java +++ b/src/test/java/net/consensys/orion/network/WhitelistNodeClientTest.java @@ -53,7 +53,7 @@ @ExtendWith(TempDirectoryExtension.class) class WhitelistNodeClientTest { - private static Vertx vertx = Vertx.vertx(); + private final static Vertx vertx = Vertx.vertx(); private static HttpServer whitelistedServer; private static HttpServer unknownServer; private static HttpClient client; diff --git a/src/test/java/net/consensys/orion/storage/EncryptedPayloadStorageTest.java b/src/test/java/net/consensys/orion/storage/EncryptedPayloadStorageTest.java index d582393c..78825c27 100644 --- a/src/test/java/net/consensys/orion/storage/EncryptedPayloadStorageTest.java +++ b/src/test/java/net/consensys/orion/storage/EncryptedPayloadStorageTest.java @@ -31,9 +31,10 @@ class EncryptedPayloadStorageTest { Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); } - private Enclave enclave = new SodiumEnclaveStub(); - private StorageKeyBuilder keyBuilder = new Sha512_256StorageKeyBuilder(); - private Storage payloadStorage = new EncryptedPayloadStorage(new MapKeyValueStore(), keyBuilder); + private final Enclave enclave = new SodiumEnclaveStub(); + private final StorageKeyBuilder keyBuilder = new Sha512_256StorageKeyBuilder(); + private final Storage payloadStorage = + new EncryptedPayloadStorage(new MapKeyValueStore(), keyBuilder); @Test void storeAndRetrieve() throws Exception {