diff --git a/checkstyle.xml b/checkstyle.xml
new file mode 100644
index 0000000..78ea3ce
--- /dev/null
+++ b/checkstyle.xml
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/client/src/main/java/info/frostfs/sdk/jdo/ClientEnvironment.java b/client/src/main/java/info/frostfs/sdk/jdo/ClientEnvironment.java
index 6b140d3..6e17947 100644
--- a/client/src/main/java/info/frostfs/sdk/jdo/ClientEnvironment.java
+++ b/client/src/main/java/info/frostfs/sdk/jdo/ClientEnvironment.java
@@ -1,8 +1,8 @@
package info.frostfs.sdk.jdo;
+import info.frostfs.sdk.FrostFSClient;
import info.frostfs.sdk.dto.OwnerId;
import info.frostfs.sdk.dto.Version;
-import info.frostfs.sdk.FrostFSClient;
import io.grpc.Channel;
import org.apache.commons.lang3.StringUtils;
diff --git a/client/src/main/java/info/frostfs/sdk/services/impl/NetmapClientImpl.java b/client/src/main/java/info/frostfs/sdk/services/impl/NetmapClientImpl.java
index b38624c..3a3d1ca 100644
--- a/client/src/main/java/info/frostfs/sdk/services/impl/NetmapClientImpl.java
+++ b/client/src/main/java/info/frostfs/sdk/services/impl/NetmapClientImpl.java
@@ -40,7 +40,7 @@ public class NetmapClientImpl extends ContextAccessor implements NetmapClient {
private static long getLongValue(byte[] bytes) {
long val = 0;
for (var i = bytes.length - 1; i >= 0; i--) {
- val = (val << 8) + bytes[i];
+ val = (val << Byte.SIZE) + bytes[i];
}
return val;
diff --git a/client/src/main/java/info/frostfs/sdk/services/impl/ObjectToolsImpl.java b/client/src/main/java/info/frostfs/sdk/services/impl/ObjectToolsImpl.java
index b68a26e..2fb3b42 100644
--- a/client/src/main/java/info/frostfs/sdk/services/impl/ObjectToolsImpl.java
+++ b/client/src/main/java/info/frostfs/sdk/services/impl/ObjectToolsImpl.java
@@ -49,7 +49,11 @@ public class ObjectToolsImpl extends ContextAccessor implements ToolsClient {
var split = objectFrostFs.getHeader().getSplit();
if (nonNull(split)) {
var splitGrpc = Types.Header.Split.newBuilder()
- .setSplitId(nonNull(split.getSplitId()) ? ByteString.copyFrom(split.getSplitId().toBinary()) : null);
+ .setSplitId(
+ nonNull(split.getSplitId())
+ ? ByteString.copyFrom(split.getSplitId().toBinary())
+ : null
+ );
ListUtils.emptyIfNull(split.getChildren()).stream()
.map(ObjectIdMapper::toGrpcMessage)
diff --git a/client/src/main/java/info/frostfs/sdk/tools/RequestSigner.java b/client/src/main/java/info/frostfs/sdk/tools/RequestSigner.java
index ea7d828..5cd178f 100644
--- a/client/src/main/java/info/frostfs/sdk/tools/RequestSigner.java
+++ b/client/src/main/java/info/frostfs/sdk/tools/RequestSigner.java
@@ -23,12 +23,13 @@ import static org.bouncycastle.util.BigIntegers.asUnsignedByteArray;
public class RequestSigner {
public static final String ERROR_UNSUPPORTED_TYPE_TEMPLATE = "Unsupported message type: %s";
public static final int RFC6979_SIGNATURE_SIZE = 64;
+ public static final int HASH_SIGNATURE_SIZE = 65;
private RequestSigner() {
}
public static byte[] signData(ECDsa key, byte[] data) {
- var hash = new byte[65];
+ var hash = new byte[HASH_SIGNATURE_SIZE];
hash[0] = 0x04;
try {
Signature signature = Signature.getInstance(CryptoConst.SIGNATURE_ALGORITHM);
diff --git a/client/src/main/java/info/frostfs/sdk/tools/Verifier.java b/client/src/main/java/info/frostfs/sdk/tools/Verifier.java
index 48a2afc..f0cd408 100644
--- a/client/src/main/java/info/frostfs/sdk/tools/Verifier.java
+++ b/client/src/main/java/info/frostfs/sdk/tools/Verifier.java
@@ -82,7 +82,8 @@ public class Verifier {
public static boolean verify(Message response) {
var body = MessageHelper.getField(response, BODY_FIELD_NAME);
var metaHeader = (Types.ResponseMetaHeader) MessageHelper.getField(response, META_HEADER_FIELD_NAME);
- var verifyHeader = (Types.ResponseVerificationHeader) MessageHelper.getField(response, VERIFY_HEADER_FIELD_NAME);
+ var verifyHeader = (Types.ResponseVerificationHeader)
+ MessageHelper.getField(response, VERIFY_HEADER_FIELD_NAME);
return verifyMatryoshkaLevel(body, metaHeader, verifyHeader);
}
diff --git a/cryptography/src/main/java/info/frostfs/sdk/Base58.java b/cryptography/src/main/java/info/frostfs/sdk/Base58.java
index 6321d58..860299d 100644
--- a/cryptography/src/main/java/info/frostfs/sdk/Base58.java
+++ b/cryptography/src/main/java/info/frostfs/sdk/Base58.java
@@ -10,8 +10,12 @@ import static java.util.Objects.isNull;
public class Base58 {
public static final char[] ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".toCharArray();
+ public static final int BASE58_SYMBOL_COUNT = 58;
+ public static final int BASE256_SYMBOL_COUNT = 256;
+ private static final int BYTE_DIVISION = 0xFF;
private static final char ENCODED_ZERO = ALPHABET[0];
- private static final int[] INDEXES = new int[128];
+ private static final char BASE58_ASCII_MAX_VALUE = 128;
+ private static final int[] INDEXES = new int[BASE58_ASCII_MAX_VALUE];
static {
Arrays.fill(INDEXES, -1);
@@ -69,7 +73,7 @@ public class Base58 {
char[] encoded = new char[input.length * 2]; // upper bound
int outputStart = encoded.length;
for (int inputStart = zeros; inputStart < input.length; ) {
- encoded[--outputStart] = ALPHABET[divmod(input, inputStart, 256, 58)];
+ encoded[--outputStart] = ALPHABET[divmod(input, inputStart, BASE256_SYMBOL_COUNT, BASE58_SYMBOL_COUNT)];
if (input[inputStart] == 0) {
++inputStart; // optimization - skip leading zeros
}
@@ -93,7 +97,7 @@ public class Base58 {
byte[] input58 = new byte[input.length()];
for (int i = 0; i < input.length(); ++i) {
char c = input.charAt(i);
- int digit = c < 128 ? INDEXES[c] : -1;
+ int digit = c < BASE58_ASCII_MAX_VALUE ? INDEXES[c] : -1;
if (digit < 0) {
throw new IllegalArgumentException(String.format("Invalid character in Base58: 0x%04x", (int) c));
}
@@ -108,7 +112,7 @@ public class Base58 {
byte[] decoded = new byte[input.length()];
int outputStart = decoded.length;
for (int inputStart = zeros; inputStart < input58.length; ) {
- decoded[--outputStart] = divmod(input58, inputStart, 58, 256);
+ decoded[--outputStart] = divmod(input58, inputStart, BASE58_SYMBOL_COUNT, BASE256_SYMBOL_COUNT);
if (input58[inputStart] == 0) {
++inputStart; // optimization - skip leading zeros
}
@@ -125,7 +129,7 @@ public class Base58 {
// this is just long division which accounts for the base of the input digits
int remainder = 0;
for (int i = firstDigit; i < number.length; i++) {
- int digit = (int) number[i] & 0xFF;
+ int digit = (int) number[i] & BYTE_DIVISION;
int temp = remainder * base + digit;
number[i] = (byte) (temp / divisor);
remainder = temp % divisor;
diff --git a/cryptography/src/main/java/info/frostfs/sdk/Helper.java b/cryptography/src/main/java/info/frostfs/sdk/Helper.java
index 58b8c1e..a864301 100644
--- a/cryptography/src/main/java/info/frostfs/sdk/Helper.java
+++ b/cryptography/src/main/java/info/frostfs/sdk/Helper.java
@@ -11,15 +11,17 @@ import java.security.NoSuchAlgorithmException;
import static java.util.Objects.isNull;
public class Helper {
+ private static final int RIPEMD_160_HASH_BYTE_LENGTH = 20;
+
private Helper() {
}
- public static byte[] getRIPEMD160(byte[] value) {
+ public static byte[] getRipemd160(byte[] value) {
if (isNull(value)) {
throw new IllegalArgumentException("Input value is missing");
}
- var hash = new byte[20];
+ var hash = new byte[RIPEMD_160_HASH_BYTE_LENGTH];
var digest = new RIPEMD160Digest();
digest.update(value, 0, value.length);
digest.doFinal(hash, 0);
diff --git a/cryptography/src/main/java/info/frostfs/sdk/KeyExtension.java b/cryptography/src/main/java/info/frostfs/sdk/KeyExtension.java
index 40affe5..f3cf7de 100644
--- a/cryptography/src/main/java/info/frostfs/sdk/KeyExtension.java
+++ b/cryptography/src/main/java/info/frostfs/sdk/KeyExtension.java
@@ -24,13 +24,14 @@ import java.security.spec.ECPublicKeySpec;
import java.security.spec.InvalidKeySpecException;
import java.util.Arrays;
-import static info.frostfs.sdk.Helper.getRIPEMD160;
+import static info.frostfs.sdk.Helper.getRipemd160;
import static info.frostfs.sdk.Helper.getSha256;
import static java.util.Objects.isNull;
import static org.bouncycastle.util.BigIntegers.fromUnsignedByteArray;
public class KeyExtension {
public static final byte NEO_ADDRESS_VERSION = 0x35;
+ private static final int PS_IN_HASH160 = 0x0C;
private static final int DECODE_ADDRESS_LENGTH = 21;
private static final int COMPRESSED_PUBLIC_KEY_LENGTH = 33;
private static final int UNCOMPRESSED_PUBLIC_KEY_LENGTH = 65;
@@ -134,7 +135,7 @@ public class KeyExtension {
checkInputValue(publicKey);
var script = createSignatureRedeemScript(publicKey);
- return getRIPEMD160(getSha256(script));
+ return getRipemd160(getSha256(script));
}
public static String publicKeyToAddress(byte[] publicKey) {
@@ -161,7 +162,7 @@ public class KeyExtension {
byte[] buffer = new byte[4];
for (int i = 0; i < buffer.length; i++) {
- buffer[i] = (byte) (value >> i * 8);
+ buffer[i] = (byte) (value >> i * Byte.SIZE);
}
return buffer;
@@ -176,10 +177,10 @@ public class KeyExtension {
);
}
- var script = new byte[]{0x0c, COMPRESSED_PUBLIC_KEY_LENGTH}; //PUSHDATA1 33
+ var script = new byte[]{PS_IN_HASH160, COMPRESSED_PUBLIC_KEY_LENGTH}; //PUSHDATA1 33
script = ArrayHelper.concat(script, publicKey);
- script = ArrayHelper.concat(script, new byte[]{0x41}); //SYSCALL
+ script = ArrayHelper.concat(script, new byte[]{UNCOMPRESSED_PUBLIC_KEY_LENGTH}); //SYSCALL
script = ArrayHelper.concat(script, getBytes(CHECK_SIG_DESCRIPTOR)); //Neo_Crypto_CheckSig
return script;
}
diff --git a/models/src/main/java/info/frostfs/sdk/UUIDExtension.java b/models/src/main/java/info/frostfs/sdk/UuidExtension.java
similarity index 87%
rename from models/src/main/java/info/frostfs/sdk/UUIDExtension.java
rename to models/src/main/java/info/frostfs/sdk/UuidExtension.java
index 730a1a5..dc4c6ff 100644
--- a/models/src/main/java/info/frostfs/sdk/UUIDExtension.java
+++ b/models/src/main/java/info/frostfs/sdk/UuidExtension.java
@@ -5,10 +5,10 @@ import java.util.UUID;
import static java.util.Objects.isNull;
-public class UUIDExtension {
+public class UuidExtension {
private static final int UUID_BYTE_ARRAY_LENGTH = 16;
- private UUIDExtension() {
+ private UuidExtension() {
}
public static UUID asUuid(byte[] bytes) {
@@ -27,7 +27,7 @@ public class UUIDExtension {
throw new IllegalArgumentException("Uuid is not present");
}
- ByteBuffer bb = ByteBuffer.allocate(16);
+ ByteBuffer bb = ByteBuffer.allocate(UUID_BYTE_ARRAY_LENGTH);
bb.putLong(uuid.getMostSignificantBits());
bb.putLong(uuid.getLeastSignificantBits());
return bb.array();
diff --git a/models/src/main/java/info/frostfs/sdk/constants/AppConst.java b/models/src/main/java/info/frostfs/sdk/constants/AppConst.java
index a823466..d535ee7 100644
--- a/models/src/main/java/info/frostfs/sdk/constants/AppConst.java
+++ b/models/src/main/java/info/frostfs/sdk/constants/AppConst.java
@@ -3,7 +3,11 @@ package info.frostfs.sdk.constants;
public class AppConst {
public static final int DEFAULT_MAJOR_VERSION = 2;
public static final int DEFAULT_MINOR_VERSION = 13;
- public static final int OBJECT_CHUNK_SIZE = 3 * (1 << 20);
+ public static final int BYTE_SHIFT = 10;
+ public static final int BYTE = 1;
+ public static final int KIB = BYTE << BYTE_SHIFT;
+ public static final int MIB = KIB << BYTE_SHIFT;
+ public static final int OBJECT_CHUNK_SIZE = 3 * MIB;
public static final int SHA256_HASH_LENGTH = 32;
private AppConst() {
diff --git a/models/src/main/java/info/frostfs/sdk/dto/SplitId.java b/models/src/main/java/info/frostfs/sdk/dto/SplitId.java
index 3ced690..29ed2d0 100644
--- a/models/src/main/java/info/frostfs/sdk/dto/SplitId.java
+++ b/models/src/main/java/info/frostfs/sdk/dto/SplitId.java
@@ -2,8 +2,8 @@ package info.frostfs.sdk.dto;
import java.util.UUID;
-import static info.frostfs.sdk.UUIDExtension.asBytes;
-import static info.frostfs.sdk.UUIDExtension.asUuid;
+import static info.frostfs.sdk.UuidExtension.asBytes;
+import static info.frostfs.sdk.UuidExtension.asUuid;
import static java.util.Objects.isNull;
public class SplitId {
diff --git a/models/src/main/java/info/frostfs/sdk/mappers/container/ContainerMapper.java b/models/src/main/java/info/frostfs/sdk/mappers/container/ContainerMapper.java
index 9aa1741..becfb22 100644
--- a/models/src/main/java/info/frostfs/sdk/mappers/container/ContainerMapper.java
+++ b/models/src/main/java/info/frostfs/sdk/mappers/container/ContainerMapper.java
@@ -7,8 +7,8 @@ import info.frostfs.sdk.enums.BasicAcl;
import info.frostfs.sdk.mappers.VersionMapper;
import info.frostfs.sdk.mappers.netmap.PlacementPolicyMapper;
-import static info.frostfs.sdk.UUIDExtension.asBytes;
-import static info.frostfs.sdk.UUIDExtension.asUuid;
+import static info.frostfs.sdk.UuidExtension.asBytes;
+import static info.frostfs.sdk.UuidExtension.asUuid;
import static java.util.Objects.isNull;
public class ContainerMapper {
diff --git a/pom.xml b/pom.xml
index 561413c..16dc005 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,5 +19,28 @@
11
11
UTF-8
+ checkstyle.xml
+
+
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+
+
+ checkstyle
+ validate
+
+ check
+
+
+ true
+
+
+
+ 3.4.0
+
+
+
\ No newline at end of file