File TarUtils.java
has 421 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
Method isEqual
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
public static boolean isEqual(byte[] buffer1, int offset1, int length1, byte[] buffer2, int offset2, int length2,
boolean ignoreTrailingNulls) {
if(buffer1 == null || buffer2 == null) {
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
TarUtils
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
public class TarUtils {
/* CONST */
/** Default record size */
public static final int DEFAULT_RCDSIZE = 512;
Method parseOctal
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public static long parseOctal(byte[] buffer, int offset, int length) {
long result = 0;
int end = offset + length;
int start = offset;
- 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 formatUnsignedOctalString
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public static boolean formatUnsignedOctalString(long value, byte[] buffer, int offset, int length) {
int remaining = length;
remaining--;
if (buffer == null || buffer.length < offset) {
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 isEqual
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static boolean isEqual(byte[] buffer1, int offset1, int length1, byte[] buffer2, int offset2, int length2,
boolean ignoreTrailingNulls) {
if(buffer1 == null || buffer2 == null) {
return false;
}
Method parseOctal
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static long parseOctal(byte[] buffer, int offset, int length) {
long result = 0;
int end = offset + length;
int start = offset;
Method isEqual
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
public static boolean isEqual(byte[] buffer1, int offset1, int length1, byte[] buffer2, int offset2, int length2,
boolean ignoreTrailingNulls) {
Method formatNameBytes
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static int formatNameBytes(String name, byte[] buf, int offset, int length, NioZipEncoding encoding) {
Method formatLongBinary
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private static boolean formatLongBinary(long value, byte[] buf, int offset, int length, boolean negative) {
Method formatBigIntegerBinary
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private static boolean formatBigIntegerBinary(long value, byte[] buf, int offset, int length, boolean negative) {
Method formatLongOctalOrBinaryBytes
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static int formatLongOctalOrBinaryBytes(long value, byte[] buf, int offset, int length) {
if(offset<0) {
return -1;
}
/* Check whether we are dealing with UID/GID or SIZE field */
- 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
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Method formatLongBinary
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private static boolean formatLongBinary(long value, byte[] buf, int offset, int length, boolean negative) {
if(buf == null || length>buf.length) {
return false;
}
final int bits = (length - 1) * 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 formatNameBytes
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static int formatNameBytes(String name, byte[] buf, int offset, int length, NioZipEncoding encoding) {
if (buf == null || name == null) {
return -1;
}
int len = name.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
Do not start a literal by 0 unless its an octal value Open
public static final long MAXSIZE = 077777777777L;
- Read upRead up
- Exclude checks
AvoidUsingOctalValues
Since: PMD 3.9
Priority: Medium
Categories: Style
Remediation Points: 50000
Integer literals should not start with zero since this denotes that the rest of literal will be interpreted as an octal value.
Example:
int i = 012; // set i with 10 not 12
int j = 010; // set j with 8 not 10
k = i * j; // set k with 80 not 120
Do not start a literal by 0 unless its an octal value Open
public static final long MAXID = 07777777L;
- Read upRead up
- Exclude checks
AvoidUsingOctalValues
Since: PMD 3.9
Priority: Medium
Categories: Style
Remediation Points: 50000
Integer literals should not start with zero since this denotes that the rest of literal will be interpreted as an octal value.
Example:
int i = 012; // set i with 10 not 12
int j = 010; // set j with 8 not 10
k = i * j; // set k with 80 not 120