fujaba/NetworkParser

View on GitHub
src/main/java/de/uniks/networkparser/ext/io/TarArchiveEntry.java

Summary

Maintainability
F
5 days
Test Coverage

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 = "";
Severity: Major
Found in src/main/java/de/uniks/networkparser/ext/io/TarArchiveEntry.java - About 1 day to fix

    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
    Severity: Major
    Found in src/main/java/de/uniks/networkparser/ext/io/TarArchiveEntry.java - About 1 day to fix

      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) {
      Severity: Minor
      Found in src/main/java/de/uniks/networkparser/ext/io/TarArchiveEntry.java - About 4 hrs to fix

      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);
      Severity: Major
      Found in src/main/java/de/uniks/networkparser/ext/io/TarArchiveEntry.java - About 3 hrs to fix

        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);
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/ext/io/TarArchiveEntry.java - About 3 hrs to fix

        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;
                }
        Severity: Major
        Found in src/main/java/de/uniks/networkparser/ext/io/TarArchiveEntry.java - About 2 hrs to fix

          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;
                  }
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/ext/io/TarArchiveEntry.java - About 1 hr to fix

          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);
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/ext/io/TarArchiveEntry.java - About 1 hr to fix

            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) {
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/ext/io/TarArchiveEntry.java - About 1 hr to fix

              Avoid deeply nested control flow statements.
              Open

                                      if (ch2 == ':' && (ch1 >= 'a' && ch1 <= 'z' || ch1 >= 'A' && ch1 <= 'Z')) {
                                          fileName = fileName.substring(2);
                                      }
              Severity: Major
              Found in src/main/java/de/uniks/networkparser/ext/io/TarArchiveEntry.java - About 45 mins to fix

                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) {
                Severity: Minor
                Found in src/main/java/de/uniks/networkparser/ext/io/TarArchiveEntry.java - About 35 mins to fix

                  Avoid too many return statements within this method.
                  Open

                          return true;
                  Severity: Major
                  Found in src/main/java/de/uniks/networkparser/ext/io/TarArchiveEntry.java - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return true;
                    Severity: Major
                    Found in src/main/java/de/uniks/networkparser/ext/io/TarArchiveEntry.java - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return true;
                      Severity: Major
                      Found in src/main/java/de/uniks/networkparser/ext/io/TarArchiveEntry.java - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                    return true;
                        Severity: Major
                        Found in src/main/java/de/uniks/networkparser/ext/io/TarArchiveEntry.java - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                      return true;
                          Severity: Major
                          Found in src/main/java/de/uniks/networkparser/ext/io/TarArchiveEntry.java - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                        return true;
                            Severity: Major
                            Found in src/main/java/de/uniks/networkparser/ext/io/TarArchiveEntry.java - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                          return false;
                              Severity: Major
                              Found in src/main/java/de/uniks/networkparser/ext/io/TarArchiveEntry.java - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                            return true;
                                Severity: Major
                                Found in src/main/java/de/uniks/networkparser/ext/io/TarArchiveEntry.java - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                          return true;
                                  Severity: Major
                                  Found in src/main/java/de/uniks/networkparser/ext/io/TarArchiveEntry.java - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                return true;
                                    Severity: Major
                                    Found in src/main/java/de/uniks/networkparser/ext/io/TarArchiveEntry.java - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                  return true;
                                      Severity: Major
                                      Found in src/main/java/de/uniks/networkparser/ext/io/TarArchiveEntry.java - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                    return true;
                                        Severity: Major
                                        Found in src/main/java/de/uniks/networkparser/ext/io/TarArchiveEntry.java - About 30 mins to fix

                                          Do not start a literal by 0 unless its an octal value
                                          Open

                                              public static final int DEFAULT_DIR_MODE = 040755;

                                          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;

                                          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

                                          There are no issues that match your filters.

                                          Category
                                          Status