TarArchiveEntry
has 73 methods (exceeds 20 allowed). Consider refactoring. Open
public class TarArchiveEntry {
private static final TarArchiveEntry[] EMPTY_TAR_ARCHIVE_ENTRIES = new TarArchiveEntry[0];
/** The entry is name. */
private String name = "";
File TarArchiveEntry.java
has 605 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 normalizeFileName
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
private static String normalizeFileName(String fileName, boolean preserveAbsolutePath) {
if (preserveAbsolutePath == false) {
final String osname = System.getProperty("os.name").toLowerCase(Locale.ENGLISH);
if (osname != null) {
- 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 parseTarHeader
has 88 lines of code (exceeds 25 allowed). Consider refactoring. Open
private boolean parseTarHeader(byte[] header, NioZipEncoding encoding, boolean oldStyle) {
int offset = 0;
name = oldStyle ? TarUtils.parseName(header, offset, TarUtils.NAMELEN)
: TarUtils.parseName(header, offset, TarUtils.NAMELEN, encoding);
Method parseTarHeader
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
private boolean parseTarHeader(byte[] header, NioZipEncoding encoding, boolean oldStyle) {
int offset = 0;
name = oldStyle ? TarUtils.parseName(header, offset, TarUtils.NAMELEN)
: TarUtils.parseName(header, offset, TarUtils.NAMELEN, encoding);
- 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 processPaxHeader
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
private boolean processPaxHeader(String key, String val, Map<String, String> headers) {
if ("path".equals(key)) {
setName(val);
return true;
}
Method processPaxHeader
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private boolean processPaxHeader(String key, String val, Map<String, String> headers) {
if ("path".equals(key)) {
setName(val);
return true;
}
- 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 writeEntryHeader
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void writeEntryHeader(byte[] outbuf, NioZipEncoding encoding, boolean starMode) {
int offset = 0;
offset = TarUtils.formatNameBytes(name, outbuf, offset, TarUtils.NAMELEN, encoding);
offset = writeEntryHeaderField(mode, outbuf, offset, TarUtils.MODELEN, starMode);
Method normalizeFileName
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static String normalizeFileName(String fileName, boolean preserveAbsolutePath) {
if (preserveAbsolutePath == false) {
final String osname = System.getProperty("os.name").toLowerCase(Locale.ENGLISH);
if (osname != null) {
Avoid deeply nested control flow statements. Open
if (ch2 == ':' && (ch1 >= 'a' && ch1 <= 'z' || ch1 >= 'A' && ch1 <= 'Z')) {
fileName = fileName.substring(2);
}
Method writeEntryHeaderField
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private int writeEntryHeaderField(long value, byte[] outbuf, final int offset, final int length,
final boolean starMode) {
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
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 true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Do not start a literal by 0 unless its an octal value Open
public static final int DEFAULT_DIR_MODE = 040755;
- 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 int DEFAULT_FILE_MODE = 0100644;
- 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