zxing-js/library

View on GitHub

Showing 605 of 958 total issues

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

  private readCorner3(numRows: number, numColumns: number): number {
    let currentByte = 0;
    if (this.readModule(numRows - 1, 0, numRows, numColumns)) {
      currentByte |= 1;
    }
Severity: Minor
Found in src/core/datamatrix/decoder/BitMatrixParser.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

              switch (cValue) {
                case 27: // FNC1
                  result.append(String.fromCharCode(29)); // translate as ASCII 29
                  break;
                case 30: // Upper Shift
Severity: Major
Found in src/core/datamatrix/decoder/DecodedBitStreamParser.ts - About 45 mins to fix

    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

      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

      Avoid deeply nested control flow statements.
      Open

                              if (this.bitMatrix.get(j - col, i)) {
                                  currentByte |= 1;
                              }
      Severity: Major
      Found in src/core/qrcode/decoder/BitMatrixParser.ts - About 45 mins to fix

        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

        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 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

                    if (sjisCurKatakanaWordLength > sjisMaxKatakanaWordLength) {
                      sjisMaxKatakanaWordLength = sjisCurKatakanaWordLength;
                    }
          Severity: Major
          Found in src/core/common/StringUtils.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 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

                Avoid deeply nested control flow statements.
                Open

                          if ((value & 0x40) === 0) {
                            canBeUTF8 = false;
                          } else {
                            utf8BytesLeft++;
                            if ((value & 0x20) === 0) {
                Severity: Major
                Found in src/core/common/StringUtils.ts - About 45 mins to fix

                  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/common/StringUtils.ts - About 45 mins to fix

                    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

                                              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

                                                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 (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
                            Severity
                            Category
                            Status
                            Source
                            Language