fujaba/NetworkParser

View on GitHub
src/main/java/de/uniks/networkparser/buffer/ByteBuffer.java

Summary

Maintainability
F
4 days
Test Coverage

File ByteBuffer.java has 481 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package de.uniks.networkparser.buffer;

import java.nio.charset.Charset;

import de.uniks.networkparser.converter.ByteConverter;
Severity: Minor
Found in src/main/java/de/uniks/networkparser/buffer/ByteBuffer.java - About 7 hrs to fix

    Method addBytes has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

        public boolean addBytes(Object value, int len, boolean bufferAtEnd) {
            boolean addEnd = false;
            if (this.position == this.length) {
                addEnd = true;
            }
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/buffer/ByteBuffer.java - About 5 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

    ByteBuffer has 39 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class ByteBuffer extends BufferedBuffer {
        /** The buffer. */
        protected byte[] buffer;
    
        @Override
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/buffer/ByteBuffer.java - About 5 hrs to fix

      Method resize has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          private boolean resize(int len, boolean bufferAtEnd) {
              int bufferLen = 0;
              if (this.buffer != null) {
                  bufferLen = this.buffer.length;
              }
      Severity: Minor
      Found in src/main/java/de/uniks/networkparser/buffer/ByteBuffer.java - About 2 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 addBytes has 61 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public boolean addBytes(Object value, int len, boolean bufferAtEnd) {
              boolean addEnd = false;
              if (this.position == this.length) {
                  addEnd = true;
              }
      Severity: Major
      Found in src/main/java/de/uniks/networkparser/buffer/ByteBuffer.java - About 2 hrs to fix

        Method resize has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private boolean resize(int len, boolean bufferAtEnd) {
                int bufferLen = 0;
                if (this.buffer != null) {
                    bufferLen = this.buffer.length;
                }
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/buffer/ByteBuffer.java - About 1 hr to fix

          Method insert has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public boolean insert(Object item, boolean bufferAdEnd) {
                  if (item instanceof Byte) {
                      return addBytes(item, 1, bufferAdEnd);
                  }
                  if (item instanceof Character) {
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/buffer/ByteBuffer.java - About 1 hr to fix

            Method insert has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                public boolean insert(Object item, boolean bufferAdEnd) {
                    if (item instanceof Byte) {
                        return addBytes(item, 1, bufferAdEnd);
                    }
                    if (item instanceof Character) {
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/buffer/ByteBuffer.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 getBytes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                public byte[] getBytes(Object... parameter) {
                    if (buffer == null || position >= buffer.length - 1) {
                        return new byte[0];
                    }
            
            
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/buffer/ByteBuffer.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 with has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public ByteBuffer with(char[] values, int start, int len) {
                    if (values == null || start + length > values.length) {
                        return this;
                    }
                    if (this.length < 0) {
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/buffer/ByteBuffer.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 addBytes(item, 2, bufferAdEnd);
            Severity: Major
            Found in src/main/java/de/uniks/networkparser/buffer/ByteBuffer.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/buffer/ByteBuffer.java - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return addBytes(item, 4, bufferAdEnd);
                Severity: Major
                Found in src/main/java/de/uniks/networkparser/buffer/ByteBuffer.java - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return addBytes(item, 1, bufferAdEnd);
                  Severity: Major
                  Found in src/main/java/de/uniks/networkparser/buffer/ByteBuffer.java - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return addBytes(item, 8, bufferAdEnd);
                    Severity: Major
                    Found in src/main/java/de/uniks/networkparser/buffer/ByteBuffer.java - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return addBytes(array, array.length, bufferAdEnd);
                      Severity: Major
                      Found in src/main/java/de/uniks/networkparser/buffer/ByteBuffer.java - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                    return addBytes(array, array.length, bufferAdEnd);
                        Severity: Major
                        Found in src/main/java/de/uniks/networkparser/buffer/ByteBuffer.java - About 30 mins to fix

                          Method subSequence has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                              @Override
                              public CharacterBuffer subSequence(int start, int end) {
                                  int len = end - start;
                                  if (len < 0 || buffer == null) {
                                      return new CharacterBuffer();
                          Severity: Minor
                          Found in src/main/java/de/uniks/networkparser/buffer/ByteBuffer.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

                          There are no issues that match your filters.

                          Category
                          Status