Showing 24 of 54 total issues
File Util.java
has 497 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*
* Copyright 2017 Patrick Favre-Bulle
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Method decode
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
static byte[] decode(CharSequence in) {
// Ignore trailing '=' padding and whitespace from the input.
int limit = in.length();
for (; limit > 0; limit--) {
char c = in.charAt(limit - 1);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method shiftRight
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
static byte[] shiftRight(byte[] byteArray, int shiftBitCount, ByteOrder byteOrder) {
final int shiftMod = shiftBitCount % 8;
final byte carryMask = (byte) (0xFF << (8 - shiftMod));
final int offsetBytes = (shiftBitCount / 8);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method shiftLeft
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
static byte[] shiftLeft(byte[] byteArray, int shiftBitCount, ByteOrder byteOrder) {
final int shiftMod = shiftBitCount % 8;
final byte carryMask = (byte) ((1 << shiftMod) - 1);
final int offsetBytes = (shiftBitCount / 8);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method decode
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
@Override
public byte[] decode(CharSequence hexString) {
int start;
if (Objects.requireNonNull(hexString).length() > 2 &&
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method decode
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
static byte[] decode(CharSequence in) {
// Ignore trailing '=' padding and whitespace from the input.
int limit = in.length();
for (; limit > 0; limit--) {
char c = in.charAt(limit - 1);
Method countByteArray
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
static int countByteArray(byte[] array, byte[] pattern) {
Objects.requireNonNull(pattern, "pattern must not be null");
if (pattern.length == 0 || array.length == 0) {
return 0;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method indexOf
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
static int indexOf(byte[] array, byte[] target, int start, int end) {
Objects.requireNonNull(array, "array must not be null");
Objects.requireNonNull(target, "target must not be null");
if (target.length == 0 || start < 0) {
return -1;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method shiftRight
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
static byte[] shiftRight(byte[] byteArray, int shiftBitCount, ByteOrder byteOrder) {
final int shiftMod = shiftBitCount % 8;
final byte carryMask = (byte) (0xFF << (8 - shiftMod));
final int offsetBytes = (shiftBitCount / 8);
Method shiftLeft
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
static byte[] shiftLeft(byte[] byteArray, int shiftBitCount, ByteOrder byteOrder) {
final int shiftMod = shiftBitCount % 8;
final byte carryMask = (byte) ((1 << shiftMod) - 1);
final int offsetBytes = (shiftBitCount / 8);
Method decode
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public byte[] decode(CharSequence hexString) {
int start;
if (Objects.requireNonNull(hexString).length() > 2 &&
Method validate
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
@Override
public boolean validate(byte[] byteArrayToValidate) {
for (byte b : byteArrayToValidate) {
if (mode == Mode.NONE_OF && b == refByte) {
return false;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method encode
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static byte[] encode(byte[] in, byte[] map, boolean usePadding) {
int length = outLength(in.length, usePadding);
byte[] out = new byte[length];
int index = 0, end = in.length - in.length % 3;
for (int i = 0; i < end; i += 3) {
Method charToByteArray
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
static byte[] charToByteArray(char[] charArray, Charset charset, int offset, int length) {
if (offset < 0 || offset > charArray.length)
throw new IllegalArgumentException("offset must be gt 0 and smaller than array length");
if (length < 0 || length > charArray.length)
throw new IllegalArgumentException("length must be at least 1 and less than array length");
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method decodeTo
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private int decodeTo(byte[] target, CharSequence chars) {
Objects.requireNonNull(target);
chars = trimTrailingPadding(chars);
int bytesWritten = 0;
for (int charIdx = 0; charIdx < chars.length(); charIdx += alphabet.charsPerChunk) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method validate
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
@Override
public boolean validate(byte[] byteArrayToValidate) {
if (pfix.length > byteArrayToValidate.length) {
return false;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method readFromStream
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
static byte[] readFromStream(InputStream inputStream, final int maxLengthToRead) {
final boolean readWholeStream = maxLengthToRead == -1;
int remaining = maxLengthToRead;
try {
ByteArrayOutputStream out = new ByteArrayOutputStream(readWholeStream ? 32 : maxLengthToRead);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method transform
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
@Override
public byte[] transform(byte[] currentArray, boolean inPlace) {
if (currentArray.length == newSize) {
return currentArray;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method validate
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
@Override
public boolean validate(byte[] byteArrayToValidate) {
if (operator == NOT) {
return !validatorList.get(0).validate(byteArrayToValidate);
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method equals
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
static boolean equals(byte[] obj, java.lang.Byte[] anotherArray) {
if (anotherArray == null) return false;
if (obj.length != anotherArray.length) return false;
for (int i = 0; i < obj.length; i++) {
if (anotherArray[i] == null || obj[i] != anotherArray[i]) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"