zxing-js/library

View on GitHub

Showing 605 of 958 total issues

Function findRowSkip has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    private findRowSkip(): number /*int*/ {
        const max = this.possibleCenters.length;
        if (max <= 1) {
            return 0;
        }
Severity: Minor
Found in src/core/qrcode/detector/FinderPatternFinder.ts - 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

Function isOnlyDoubleByteKanji has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    private static isOnlyDoubleByteKanji(content: string): boolean {
        let bytes: Uint8Array;
        try {
            bytes = StringEncoding.encode(content, CharacterSetECI.SJIS); // content.getBytes("Shift_JIS"))
        } catch (ignored/*: UnsupportedEncodingException*/) {
Severity: Minor
Found in src/core/qrcode/encoder/Encoder.ts - 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

Function textCompaction has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  private static textCompaction(codewords: Int32Array, codeIndex: int, result: StringBuilder): int {
    // 2 character per codeword
    let textCompactionData: Int32Array = new Int32Array((codewords[0] - codeIndex) * 2);
    // Used to hold the byte compaction value if there is a mode shift
    let byteCompactionData: Int32Array = new Int32Array((codewords[0] - codeIndex) * 2);
Severity: Minor
Found in src/core/pdf417/decoder/DecodedBitStreamParser.ts - 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

Function callback has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    function callback(exp: string | number, p0: any, p1: any, p2: any, p3: any, p4: any) {
Severity: Minor
Found in src/core/util/Formatter.ts - 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/core/qrcode/decoder/BitMatrixParser.ts - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if (currentState === 2) { // A winner?
                                  if (this.foundPatternCross(stateCount)) { // Yes
                                      const confirmed = this.handlePossibleCenter(stateCount, i, j);
                                      if (confirmed !== null) {
                                          return confirmed;
      Severity: Major
      Found in src/core/qrcode/detector/AlignmentPatternFinder.ts - About 45 mins to fix

        Function handlePossibleCenter has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            private handlePossibleCenter(stateCount: Int32Array, i: number /*int*/, j: number /*int*/): AlignmentPattern {
                const stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2];
                const centerJ: number /*float*/ = AlignmentPatternFinder.centerFromEnd(stateCount, j);
                const centerI: number /*float*/ = this.crossCheckVertical(i, /*(int) */centerJ, 2 * stateCount[1], stateCountTotal);
                if (!isNaN(centerI)) {
        Severity: Minor
        Found in src/core/qrcode/detector/AlignmentPatternFinder.ts - 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

        Function equals has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          public static equals(first: any, second: any): boolean {
            if (!first) {
              return false;
            }
            if (!second) {
        Severity: Minor
        Found in src/core/util/Arrays.ts - 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

        Avoid deeply nested control flow statements.
        Open

                    if (rowNumber >= 0) {
                      if (rowNumber >= barcodeMatrix.length) {
                        // We have more rows than the barcode metadata allows for, ignore them.
                        continue;
                      }
        Severity: Major
        Found in src/core/pdf417/decoder/PDF417ScanningDecoder.ts - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  while (((theBits << (31 - bit)) & 0xFFFFFFFF) === 0) {
                                      bit++;
                                  }
          Severity: Major
          Found in src/core/common/BitMatrix.ts - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if ((x32 * 32 + bit) < left) {
                                        left = x32 * 32 + bit;
                                    }
            Severity: Major
            Found in src/core/common/BitMatrix.ts - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if (min < averageNeighborBlackPoint) {
                                          average = averageNeighborBlackPoint;
                                      }
              Severity: Major
              Found in src/core/common/HybridBinarizer.ts - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                        } else if (value > 0x7F) {
                          sjisBytesLeft++;
                          // sjisDoubleBytesChars++
                          sjisCurKatakanaWordLength = 0;
                          sjisCurDoubleBytesWordLength++;
                Severity: Major
                Found in src/core/common/StringUtils.ts - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if (pixel < min) {
                                              min = pixel;
                                          }
                  Severity: Major
                  Found in src/core/common/HybridBinarizer.ts - About 45 mins to fix

                    Function runEuclideanAlgorithm has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                      private runEuclideanAlgorithm(a: ModulusPoly, b: ModulusPoly, R: int): ModulusPoly[] {
                        // Assume a's degree is >= b's
                        if (a.getDegree() < b.getDegree()) {
                          let temp: ModulusPoly = a;
                          a = b;
                    Severity: Minor
                    Found in src/core/pdf417/decoder/ec/ErrorCorrection.ts - 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

                    Avoid deeply nested control flow statements.
                    Open

                                            for (yy++ , offset += width; yy < HybridBinarizer.BLOCK_SIZE; yy++ , offset += width) {
                                                for (let xx = 0; xx < HybridBinarizer.BLOCK_SIZE; xx++) {
                                                    sum += luminances[offset + xx] & 0xFF;
                                                }
                                            }
                    Severity: Major
                    Found in src/core/common/HybridBinarizer.ts - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              while ((theBits >>> bit) === 0) {
                                                  bit--;
                                              }
                      Severity: Major
                      Found in src/core/common/BitMatrix.ts - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if ((x32 * 32 + bit) > right) {
                                                    right = x32 * 32 + bit;
                                                }
                        Severity: Major
                        Found in src/core/common/BitMatrix.ts - About 45 mins to fix

                          Function getBlackMatrix has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public getBlackMatrix(): BitMatrix /*throws NotFoundException*/ {
                                  if (this.matrix !== null) {
                                      return this.matrix;
                                  }
                                  const source = this.getLuminanceSource();
                          Severity: Minor
                          Found in src/core/common/HybridBinarizer.ts - 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

                          Function setRange has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                            public setRange(start: number /*int*/, end: number /*int*/): void {
                              if (end < start || start < 0 || end > this.size) {
                                throw new IllegalArgumentException();
                              }
                              if (end === start) {
                          Severity: Minor
                          Found in src/core/common/BitArray.ts - 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

                          Severity
                          Category
                          Status
                          Source
                          Language