fujaba/NetworkParser

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

Summary

Maintainability
D
3 days
Test Coverage

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

    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;
            }
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/ext/io/TarUtils.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

    TarUtils has 24 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class TarUtils {
        /* CONST */
        /** Default record size */
        public static final int DEFAULT_RCDSIZE = 512;
    
    
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/ext/io/TarUtils.java - About 2 hrs to fix

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

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

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

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

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

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

                  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 */
                  Severity: Minor
                  Found in src/main/java/de/uniks/networkparser/ext/io/TarUtils.java - About 35 mins 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

                  Avoid too many return statements within this method.
                  Open

                              return true;
                  Severity: Major
                  Found in src/main/java/de/uniks/networkparser/ext/io/TarUtils.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/TarUtils.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/TarUtils.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/TarUtils.java - About 30 mins to fix

                          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;
                          Severity: Minor
                          Found in src/main/java/de/uniks/networkparser/ext/io/TarUtils.java - About 25 mins 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 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();
                          Severity: Minor
                          Found in src/main/java/de/uniks/networkparser/ext/io/TarUtils.java - About 25 mins 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

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

                              public static final long MAXSIZE = 077777777777L;

                          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;

                          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