fujaba/NetworkParser

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

Summary

Maintainability
D
1 day
Test Coverage

Method parseString has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    @Override
    protected CharacterBuffer parseString(CharacterBuffer sc, boolean allowQuote, boolean nextStep, char... quotes) {
        if (quotes == null) {
            sc.with(getCurrentChar());
            return sc;
Severity: Minor
Found in src/main/java/de/uniks/networkparser/buffer/BufferedBuffer.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

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

public abstract class BufferedBuffer extends Buffer implements BaseItem {
    /** The count is the number of characters used. */
    protected int length;

    /** The start is the number of characters started. */
Severity: Minor
Found in src/main/java/de/uniks/networkparser/buffer/BufferedBuffer.java - About 2 hrs to fix

    Method substring has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        public String substring(int... positions) {
            if (positions == null || positions.length < 1) {
                positions = new int[] { -1 };
            }
            int start = positions[0], end = -1;
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/buffer/BufferedBuffer.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 parseString has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        @Override
        protected CharacterBuffer parseString(CharacterBuffer sc, boolean allowQuote, boolean nextStep, char... quotes) {
            if (quotes == null) {
                sc.with(getCurrentChar());
                return sc;
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/buffer/BufferedBuffer.java - About 1 hr to fix

      Method substring has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public String substring(int... positions) {
              if (positions == null || positions.length < 1) {
                  positions = new int[] { -1 };
              }
              int start = positions[0], end = -1;
      Severity: Minor
      Found in src/main/java/de/uniks/networkparser/buffer/BufferedBuffer.java - About 1 hr to fix

        Method nextValue has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            @Override
            protected CharacterBuffer nextValue(char c, boolean allowDuppleMark) {
                int start = position();
                if (allowDuppleMark) {
                    while (c >= ' ' && STOPCHARSXML.indexOf(c) < 0) {
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/buffer/BufferedBuffer.java - About 45 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 getNextString has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public String getNextString(int n) {
                int pos = 0;
                if (n < -1) {
                    n = n * -1;
                    char[] chars = new char[n];
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/buffer/BufferedBuffer.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

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

            public String toArrayString(boolean... addString) {
                CharacterBuffer sb = new CharacterBuffer();
                sb.with('[');
        
                byte[] byteArray = this.toBytes();
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/buffer/BufferedBuffer.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 toBytes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public byte[] toBytes(boolean... all) {
                byte[] result;
                int i = start;
                if (all != null && all.length > 0 && all[0]) {
                    result = new byte[length];
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/buffer/BufferedBuffer.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

        These nested if statements could be combined
        Open

                                if (allowQuote) {
                                    c = 0;
                                }

        CollapsibleIfStatements

        Since: PMD 3.1

        Priority: Medium

        Categories: Style

        Remediation Points: 50000

        Sometimes two consecutive 'if' statements can be consolidated by separating their conditions with a boolean short-circuit operator.

        Example:

        void bar() {
         if (x) { // original implementation
         if (y) {
         // do stuff
         }
         }
        }
        
        void bar() {
         if (x && y) { // optimized implementation
         // do stuff
         }
        }

        There are no issues that match your filters.

        Category
        Status