zxing-js/library

View on GitHub

Showing 605 of 958 total issues

Function createECCBlock has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  private static createECCBlock(codewords: string, numECWords: number): string {
    let table = -1;
    for (let i = 0; i < FACTOR_SETS.length; i++) {
      if (FACTOR_SETS[i] === numECWords) {
        table = i;
Severity: Minor
Found in src/core/datamatrix/encoder/ErrorCorrection.ts - About 2 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

Function getDataBlocks has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    public static getDataBlocks(rawCodewords: Uint8Array,
        version: Version,
        ecLevel: ErrorCorrectionLevel): DataBlock[] {

        if (rawCodewords.length !== version.getTotalCodewords()) {
Severity: Minor
Found in src/core/qrcode/decoder/DataBlock.ts - About 2 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

Function applyMaskPenaltyRule1Internal has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    private static applyMaskPenaltyRule1Internal(matrix: ByteMatrix, isHorizontal: boolean): number /*int*/ {
        let penalty = 0;
        const iLimit = isHorizontal ? matrix.getHeight() : matrix.getWidth();
        const jLimit = isHorizontal ? matrix.getWidth() : matrix.getHeight();
        const array: Array<Uint8Array> = matrix.getArray();
Severity: Minor
Found in src/core/qrcode/encoder/MaskUtil.ts - About 2 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

Function crossCheckVertical has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    private crossCheckVertical(startI: number /*int*/, centerJ: number /*int*/, maxCount: number /*int*/,
        originalStateCountTotal: number /*int*/): number/*float*/ {
        const image: BitMatrix = this.image;

        const maxI = image.getHeight();
Severity: Minor
Found in src/core/qrcode/detector/FinderPatternFinder.ts - About 2 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

Function crossCheckHorizontal has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    private crossCheckHorizontal(startJ: number /*int*/, centerI: number /*int*/, maxCount: number /*int*/,
        originalStateCountTotal: number /*int*/): number/*float*/ {
        const image: BitMatrix = this.image;

        const maxJ = image.getWidth();
Severity: Minor
Found in src/core/qrcode/detector/FinderPatternFinder.ts - About 2 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

Function decodeAlphanumericSegment has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  private static decodeAlphanumericSegment(bits: BitSource,
    result: StringBuilder,
    count: number /*int*/,
    fc1InEffect: boolean): void /*throws FormatException*/ {
    // Read two characters at a time
Severity: Minor
Found in src/core/qrcode/decoder/DecodedBitStreamParser.ts - About 2 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

Function removeIncorrectCodewords has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  private removeIncorrectCodewords(codewords: Codeword[], barcodeMetadata: BarcodeMetadata): void {
    // Remove codewords which do not match the metadata
    // TODO Maybe we should keep the incorrect codewords for the start and end positions?
    for (let codewordRow /*int*/ = 0; codewordRow < codewords.length; codewordRow++) {
      let codeword: Codeword = codewords[codewordRow];
Severity: Minor
Found in src/core/pdf417/decoder/DetectionResultRowIndicatorColumn.ts - About 2 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

Function decodeRow2pairs has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  decodeRow2pairs(rowNumber: number, row: BitArray): Array<ExpandedPair> {
    let done = false;
    while (!done) {
      try {
        this.pairs.push(this.retrieveNextPair(row, this.pairs, rowNumber));
Severity: Minor
Found in src/core/oned/rss/expanded/RSSExpandedReader.ts - About 2 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

Function decodeRow has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public decodeRow(rowNumber: number, row: BitArray, hints?: Map<DecodeHintType, any>): Result {
    let theCounters = this.counters;
    theCounters.fill(0);
    this.decodeRowResult = '';

Severity: Major
Found in src/core/oned/Code39Reader.ts - About 2 hrs to fix

    Function decodeExtended has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      private static decodeExtended(encoded: string): string {
        let length = encoded.length;
        let decoded = '';
        for (let i = 0; i < length; i++) {
          let c = encoded.charAt(i);
    Severity: Major
    Found in src/core/oned/Code39Reader.ts - About 2 hrs to fix

      Function decodeRow has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public decodeRow(rowNumber: number, row: BitArray, hints?: Map<DecodeHintType, any>): Result {
              let startGuardRange = UPCEANReader.findStartGuardPattern(row);
              let resultPointCallback = hints == null ? null : hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
      
              if (resultPointCallback != null) {
      Severity: Major
      Found in src/core/oned/UPCEANReader.ts - About 2 hrs to fix

        Function decodeAsciiSegment has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          private static decodeAsciiSegment(bits: BitSource,
                                                 result: StringBuilder,
                                                 resultTrailer: StringBuilder): Mode {
            let upperShift = false;
            do {
        Severity: Major
        Found in src/core/datamatrix/decoder/DecodedBitStreamParser.ts - About 2 hrs to fix

          Function decode has 59 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            public static decode(image: BitMatrix,
              imageTopLeft: ResultPoint,
              imageBottomLeft: ResultPoint,
              imageTopRight: ResultPoint,
              imageBottomRight: ResultPoint,
          Severity: Major
          Found in src/core/pdf417/decoder/PDF417ScanningDecoder.ts - About 2 hrs to fix

            Function findNextPair has 59 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              private findNextPair(
                row: BitArray,
                previousPairs: Array<ExpandedPair>,
                forcedOffset: number
              ): void {
            Severity: Major
            Found in src/core/oned/rss/expanded/RSSExpandedReader.ts - About 2 hrs to fix

              File Decoder.ts has 264 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              /*
               * Copyright 2010 ZXing authors
               *
               * Licensed under the Apache License, Version 2.0 (the "License");
               * you may not use this file except in compliance with the License.
              Severity: Minor
              Found in src/core/aztec/decoder/Decoder.ts - About 2 hrs to fix

                PDF417ResultMetadata has 22 functions (exceeds 20 allowed). Consider refactoring.
                Open

                export default /*public final*/ class PDF417ResultMetadata {
                
                    private segmentIndex: /*int*/ number;
                    private fileId: string;
                    private lastSegment: boolean;
                Severity: Minor
                Found in src/core/pdf417/PDF417ResultMetadata.ts - About 2 hrs to fix

                  File Detector.ts has 262 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import BitMatrix from '../../common/BitMatrix';
                  import WhiteRectangleDetector from '../../common/detector/WhiteRectangleDetector';
                  import DetectorResult from '../../common/DetectorResult';
                  import GridSamplerInstance from '../../common/GridSamplerInstance';
                  import NotFoundException from '../../NotFoundException';
                  Severity: Minor
                  Found in src/core/datamatrix/detector/Detector.ts - About 2 hrs to fix

                    Function encodeMinimally has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      encodeMinimally(
                        stringToEncode: string,
                        encoderSet: ECIEncoderSet,
                        fnc1: number
                      ): number[] {
                    Severity: Major
                    Found in src/core/common/MinimalECIInput.ts - About 2 hrs to fix

                      Function getLastASCII has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

                        getLastASCII(): number {
                          const length = this.input.length();
                          const from = this.fromPosition + this.characterLength;
                          if (length - from > 4 || from >= length) {
                            return 0;
                      Severity: Minor
                      Found in src/core/datamatrix/encoder/MinimalEncoder.ts - About 2 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

                      Function lookup has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

                        public static lookup(
                          dataCodewords: number,
                          shape = SymbolShapeHint.FORCE_NONE,
                          minSize: Dimension = null,
                          maxSize: Dimension = null,
                      Severity: Minor
                      Found in src/core/datamatrix/encoder/SymbolInfo.ts - About 2 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

                      Severity
                      Category
                      Status
                      Source
                      Language