zxing-js/library

View on GitHub

Showing 605 of 958 total issues

Avoid deeply nested control flow statements.
Open

                if (oddSum < evenSum) {
                    incrementOdd = true;
                    decrementEven = true;
                } else {
                    decrementOdd = true;
Severity: Major
Found in src/core/oned/rss/RSS14Reader.ts - About 45 mins to fix

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

      private isAlphaTo646ToAlphaLatch(pos: number): boolean {
        if (pos + 1 > this.information.getSize()) {
          return false;
        }
    
    
    Severity: Minor
    Found in src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.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 retrieveNextPair has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      retrieveNextPair(
        row: BitArray,
        previousPairs: Array<ExpandedPair>,
        rowNumber: number
      ): ExpandedPair {
    Severity: Minor
    Found in src/core/oned/rss/expanded/RSSExpandedReader.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 (!upperMode && shiftUpperMode) {
                      upperMode = true;
                      shiftUpperMode = false;
                    } else if (upperMode && shiftUpperMode) {
                      upperMode = false;
    Severity: Major
    Found in src/core/oned/Code128Reader.ts - About 45 mins to fix

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

          private getValidRowData(row: BitArray): any {
              let booleanArr = row.toArray();
              let startIndex = booleanArr.indexOf(true);
              if (startIndex === -1) return null;
              let lastIndex = booleanArr.lastIndexOf(true);
      Severity: Minor
      Found in src/core/oned/CodaBarReader.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 (evenParityBad) {
                throw new NotFoundException();
              }
      Severity: Major
      Found in src/core/oned/rss/expanded/RSSExpandedReader.ts - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                    if (code !== Code128Reader.CODE_STOP) {
                      lastCharacterWasPrintable = false;
                    }
        Severity: Major
        Found in src/core/oned/Code128Reader.ts - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                          if (convertFNC1) {
                            if (result.length === 0) {
                              // GS1 specification 5.4.3.7. and 5.4.6.4. If the first char after the start code
                              // is FNC1 then this is GS1-128. We add the symbology identifier.
                              result += ']C1';
          Severity: Major
          Found in src/core/oned/Code128Reader.ts - About 45 mins to fix

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

                static getStandardUPCEANChecksum(s: string): number {
                    let length = s.length;
                    let sum = 0;
                    for (let i = length - 1; i >= 0; i -= 2) {
                        let digit = s.charAt(i).charCodeAt(0) - '0'.charCodeAt(0);
            Severity: Minor
            Found in src/core/oned/AbstractUPCEANReader.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 parseAlphaBlock has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              private parseAlphaBlock(): BlockParsedResult {
                while (this.isStillAlpha(this.current.getPosition())) {
                  let alpha = this.decodeAlphanumeric(this.current.getPosition());
                  this.current.setPosition(alpha.getNewPosition());
            
            
            Severity: Minor
            Found in src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.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

            Consider simplifying this complex logical expression.
            Open

                  } else if ((row === numRows - 2) && (column === 0) && ((numColumns & 0x07) === 4) && !corner4Read) {
                    result[resultOffset++] = this.readCorner4(numRows, numColumns) & 0xff;
                    row -= 2;
                    column += 2;
                    corner4Read = true;
            Severity: Major
            Found in src/core/datamatrix/decoder/BitMatrixParser.ts - About 40 mins to fix

              Consider simplifying this complex logical expression.
              Open

                      if (!sizeExceeded && atLeastOneBlackPointFoundOnBorder) {
              
                          const maxSize = right - left;
              
                          let z: ResultPoint | null = null;
              Severity: Major
              Found in src/core/common/detector/WhiteRectangleDetector.ts - About 40 mins to fix

                Function encodeChar has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  encodeChar(c: char, sb: StringBuilder): number {
                    switch (c) {
                      case 13: // CR (Carriage return)
                        sb.append(0o0);
                        break;
                Severity: Minor
                Found in src/core/datamatrix/encoder/X12Encoder.ts - 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

                Function getShiftValue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  getShiftValue(c: number, c40: boolean, fnc1: number): number {
                    return (c40 && MinimalEncoder.isInC40Shift1Set(c)) ||
                      (!c40 && MinimalEncoder.isInTextShift1Set(c))
                      ? 0
                      : (c40 && MinimalEncoder.isInC40Shift2Set(c, fnc1)) ||
                Severity: Minor
                Found in src/core/datamatrix/encoder/MinimalEncoder.ts - 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

                Function renderResult has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    private renderResult(code: QRCode, width: number /*int*/, height: number /*int*/, quietZone: number /*int*/): SVGSVGElement {
                
                        const input = code.getMatrix();
                
                        if (input === null) {
                Severity: Minor
                Found in src/browser/BrowserQRCodeSvgWriter.ts - 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

                Function renderResult has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    private renderResult(code: QRCode, width: number /*int*/, height: number /*int*/, quietZone: number /*int*/): SVGSVGElement {
                
                        // if (this.format && format != this.format) {
                        //   throw new IllegalArgumentException("Can only encode QR_CODE, but got " + format)
                        // }
                Severity: Minor
                Found in src/browser/BrowserSvgCodeWriter.ts - 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

                Function getDataBytes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  getDataBytes(): Uint8Array {
                    switch (this.mode) {
                      case Mode.ASCII:
                        if (this.input.isECI(this.fromPosition)) {
                          return Edge.getBytes(
                Severity: Minor
                Found in src/core/datamatrix/encoder/MinimalEncoder.ts - 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

                Function decodeContinuously has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  public decodeContinuously(
                    element: HTMLVideoElement,
                    callbackFn: DecodeContinuouslyCallback
                  ): void {
                    this._stopContinuousDecode = false;
                Severity: Minor
                Found in src/browser/BrowserCodeReader.ts - 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

                Function decodeFallback has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  private static decodeFallback(bytes: Uint8Array, encoding: string | CharacterSetECI): string {
                
                    const characterSet = this.encodingCharacterSet(encoding);
                
                    if (StringEncoding.isDecodeFallbackSupported(characterSet)) {
                Severity: Minor
                Found in src/core/util/StringEncoding.ts - 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

                Function decode has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  public decode(image: BinaryBitmap, hints?: Map<DecodeHintType, any>): Result {
                    let decoderResult: DecoderResult;
                    let points: Array<ResultPoint>;
                    if (hints !== undefined && hints !== null && undefined !== hints.get(DecodeHintType.PURE_BARCODE)) {
                      const bits = QRCodeReader.extractPureBits(image.getBlackMatrix());
                Severity: Minor
                Found in src/core/qrcode/QRCodeReader.ts - 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

                Severity
                Category
                Status
                Source
                Language