fujaba/NetworkParser

View on GitHub
src/main/java/de/uniks/networkparser/bytes/qr/BitMatrixParser.java

Summary

Maintainability
F
3 days
Test Coverage

Method unmaskBitMatrix has a Cognitive Complexity of 80 (exceeds 5 allowed). Consider refactoring.
Open

    final void unmaskBitMatrix(byte mask, BitMatrix bits, int dimension) {
        if (mask == 0) { /* 000: mask bits for which (x + y) mod 2 == 0 */
            for (int i = 0; i < dimension; i++) {
                for (int j = 0; j < dimension; j++) {
                    if (((i + j) & 0x01) == 0) {
Severity: Minor
Found in src/main/java/de/uniks/networkparser/bytes/qr/BitMatrixParser.java - About 1 day 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 readCodewords has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    byte[] readCodewords() {
        if (bitMatrix == null) {
            return null;
        }
        FormatInformation formatInfo = readFormatInformation();
Severity: Minor
Found in src/main/java/de/uniks/networkparser/bytes/qr/BitMatrixParser.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 unmaskBitMatrix has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    final void unmaskBitMatrix(byte mask, BitMatrix bits, int dimension) {
        if (mask == 0) { /* 000: mask bits for which (x + y) mod 2 == 0 */
            for (int i = 0; i < dimension; i++) {
                for (int j = 0; j < dimension; j++) {
                    if (((i + j) & 0x01) == 0) {
Severity: Major
Found in src/main/java/de/uniks/networkparser/bytes/qr/BitMatrixParser.java - About 2 hrs to fix

    Method readVersion has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        Version readVersion() {
            if (parsedVersion != null || bitMatrix == null) {
                return parsedVersion;
            }
            int dimension = bitMatrix.getHeight();
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/bytes/qr/BitMatrixParser.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 readCodewords has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        byte[] readCodewords() {
            if (bitMatrix == null) {
                return null;
            }
            FormatInformation formatInfo = readFormatInformation();
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/bytes/qr/BitMatrixParser.java - About 1 hr to fix

      Method readVersion has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          Version readVersion() {
              if (parsedVersion != null || bitMatrix == null) {
                  return parsedVersion;
              }
              int dimension = bitMatrix.getHeight();
      Severity: Minor
      Found in src/main/java/de/uniks/networkparser/bytes/qr/BitMatrixParser.java - About 1 hr to fix

        Method mirror has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            void mirror() {
                if (bitMatrix != null) {
                    for (int x = 0; x < bitMatrix.getWidth(); x++) {
                        for (int y = x + 1; y < bitMatrix.getHeight(); y++) {
                            if (bitMatrix.get(x, y) != bitMatrix.get(y, x)) {
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/bytes/qr/BitMatrixParser.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

        Avoid deeply nested control flow statements.
        Open

                                if (bitMatrix.get(j - col, i)) {
                                    currentByte |= 1;
                                }
        Severity: Major
        Found in src/main/java/de/uniks/networkparser/bytes/qr/BitMatrixParser.java - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if (bitsRead == 8) {
                                      result[resultOffset++] = (byte) currentByte;
                                      bitsRead = 0;
                                      currentByte = 0;
                                  }
          Severity: Major
          Found in src/main/java/de/uniks/networkparser/bytes/qr/BitMatrixParser.java - About 45 mins to fix

            Avoid too many return statements within this method.
            Open

                    return null;
            Severity: Major
            Found in src/main/java/de/uniks/networkparser/bytes/qr/BitMatrixParser.java - About 30 mins to fix

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

                  FormatInformation readFormatInformation() {
                      if (parsedFormatInfo != null || bitMatrix == null) {
                          return parsedFormatInfo;
                      }
              
              
              Severity: Minor
              Found in src/main/java/de/uniks/networkparser/bytes/qr/BitMatrixParser.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