zxing-js/library

View on GitHub

Showing 605 of 958 total issues

Avoid deeply nested control flow statements.
Open

            if (bitMatrix.get(readColumnOffset, readRowOffset)) {
              const writeColumnOffset = dataRegionColumnOffset + j;
              bitMatrixWithoutAlignment.set(writeColumnOffset, writeRowOffset);
            }
Severity: Major
Found in src/core/datamatrix/decoder/BitMatrixParser.ts - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                  if (upperShift) {
                    result.append(String.fromCharCode(c40char.charCodeAt(0) + 128));
                    upperShift = false;
                  } else {
                    result.append(c40char);
    Severity: Major
    Found in src/core/datamatrix/decoder/DecodedBitStreamParser.ts - About 45 mins to fix

      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

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

        private readCorner4(numRows: number, numColumns: number): number {
          let currentByte = 0;
          if (this.readModule(numRows - 3, 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

                    if (upperShift) {
                      result.append(String.fromCharCode(c40char.charCodeAt(0) + 128));
                      upperShift = false;
                    } else {
                      result.append(c40char);
      Severity: Major
      Found in src/core/datamatrix/decoder/DecodedBitStreamParser.ts - About 45 mins to fix

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

            public write(
                contents: string,
                width: number,
                height: number,
                hints: Map<EncodeHintType, any> = null
        Severity: Minor
        Found in src/browser/BrowserQRCodeSvgWriter.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 (upperShift) {
                        result.append(String.fromCharCode(textChar.charCodeAt(0) + 128));
                        upperShift = false;
                      } else {
                        result.append(textChar);
        Severity: Major
        Found in src/core/datamatrix/decoder/DecodedBitStreamParser.ts - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                        if (upperShift) {
                          result.append(String.fromCharCode(textChar.charCodeAt(0) + 128));
                          upperShift = false;
                        } else {
                          result.append(textChar);
          Severity: Major
          Found in src/core/datamatrix/decoder/DecodedBitStreamParser.ts - About 45 mins to fix

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

              private readCorner2(numRows: number, numColumns: number): number {
                let currentByte = 0;
                if (this.readModule(numRows - 3, 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

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

              private static decodeBase256Segment(bits: BitSource,
                                                       result: StringBuilder,
                                                       byteSegments: Uint8Array[]): void {
                // Figure out how long the Base 256 Segment is.
                let codewordPosition = 1 + bits.getByteOffset(); // position is 1-indexed
            Severity: Minor
            Found in src/core/datamatrix/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 readUtah has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              private readUtah(row: number, column: number, numRows: number, numColumns: number): number {
                let currentByte = 0;
                if (this.readModule(row - 2, column - 2, 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

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

              private readCorner1(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

              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

                Avoid deeply nested control flow statements.
                Open

                              if (upperShift) {
                                result.append(String.fromCharCode(textChar.charCodeAt(0) + 128));
                                upperShift = false;
                              } else {
                                result.append(textChar);
                Severity: Major
                Found in src/core/datamatrix/decoder/DecodedBitStreamParser.ts - About 45 mins to fix

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

                      public static chooseMode(content: string, encoding: string = null): Mode {
                          if (CharacterSetECI.SJIS.getName() === encoding && this.isOnlyDoubleByteKanji(content)) {
                              // Choose Kanji mode if all input are double-byte characters
                              return Mode.KANJI;
                          }
                  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 getBarcodeMetadata has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                    getBarcodeMetadata(): BarcodeMetadata {
                      let codewords: Codeword[] = this.getCodewords();
                      let barcodeColumnCount: BarcodeValue = new BarcodeValue();
                      let barcodeRowCountUpperPart: BarcodeValue = new BarcodeValue();
                      let barcodeRowCountLowerPart: BarcodeValue = new BarcodeValue();
                  Severity: Minor
                  Found in src/core/pdf417/decoder/DetectionResultRowIndicatorColumn.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 (let j /*int*/ = 0; j < 6; ++j) {
                                    /* @note
                                     * JavaScript stores numbers as 64 bits floating point numbers, but all bitwise operations are performed on 32 bits binary numbers.
                                     * So the next bitwise operation could not be done with simple numbers
                                     */
                  Severity: Major
                  Found in src/core/pdf417/decoder/DecodedBitStreamParser.ts - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if (currentState === 4) { // A winner?
                                                if (FinderPatternFinder.foundPatternCross(stateCount)) { // Yes
                                                    const confirmed: boolean = this.handlePossibleCenter(stateCount, i, j, pureBarcode);
                                                    if (confirmed === true) {
                                                        // Start examining every other line. Checking each line turned out to be too
                    Severity: Major
                    Found in src/core/qrcode/detector/FinderPatternFinder.ts - About 45 mins to fix

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