zxing-js/library

View on GitHub

Showing 605 of 958 total issues

Function crossCheckDiagonal has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    private crossCheckDiagonal(startI: number /*int*/, centerJ: number /*int*/, maxCount: number /*int*/, originalStateCountTotal: number /*int*/): boolean {
        const stateCount: Int32Array = this.getCrossCheckStateCount();

        // Start counting up, left from center finding black center mass
        let i = 0;
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 getDataBlocks has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  static getDataBlocks(rawCodewords: Int8Array,
                                   version: Version): DataBlock[]  {
    // Figure out the number and size of data blocks used by this version
    const ecBlocks = version.getECBlocks();

Severity: Minor
Found in src/core/datamatrix/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 createDecoderResultFromAmbiguousValues has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  private static createDecoderResultFromAmbiguousValues(ecLevel: int,
    codewords: Int32Array,
    erasureArray: Int32Array,
    ambiguousIndexes: Int32Array,
    ambiguousIndexValues: Int32Array[]): DecoderResult {
Severity: Minor
Found in src/core/pdf417/decoder/PDF417ScanningDecoder.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 encode has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  public encode(): BitArray {

    const spaceCharCode = StringUtils.getCharCode(' ');
    const lineBreakCharCode = StringUtils.getCharCode('\n');

Severity: Minor
Found in src/core/aztec/encoder/HighLevelEncoder.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 a Cognitive Complexity of 20 (exceeds 5 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: Minor
Found in src/core/oned/UPCEANReader.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 correctBits has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    private correctBits(rawbits: boolean[]): boolean[] {
        let gf: GenericGF;
        let codewordSize: number;

        if (this.ddata.getNbLayers() <= 2) {
Severity: Minor
Found in src/core/aztec/decoder/Decoder.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

Consider simplifying this complex logical expression.
Open

        if (formats !== null && formats !== undefined) {
            const addOneDReader: boolean = formats.some(f =>
                f === BarcodeFormat.UPC_A ||
                f === BarcodeFormat.UPC_E ||
                f === BarcodeFormat.EAN_13 ||
Severity: Critical
Found in src/core/MultiFormatReader.ts - About 2 hrs to fix

    BitMatrix has 24 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export default class BitMatrix /*implements Cloneable*/ {
    
        /**
         * Creates an empty square {@link BitMatrix}.
         *
    Severity: Minor
    Found in src/core/common/BitMatrix.ts - About 2 hrs to fix

      Function byteCompaction has 66 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        private static /*int*/ byteCompaction(mode: int,
          codewords: Int32Array,
          encoding: /*Charset*/ CharacterSetECI,
          codeIndex: int,
          result: StringBuilder) {
      Severity: Major
      Found in src/core/pdf417/decoder/DecodedBitStreamParser.ts - About 2 hrs to fix

        Function encodeLowLevel has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

          private encodeLowLevel(
            placement: DefaultPlacement,
            symbolInfo: SymbolInfo,
            width: number,
            height: number
        Severity: Minor
        Found in src/core/datamatrix/DataMatrixWriter.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 handlePossibleCenter has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            protected handlePossibleCenter(stateCount: Int32Array, i: number /*int*/, j: number /*int*/, pureBarcode: boolean): boolean {
                const stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] +
                    stateCount[4];
                let centerJ: number /*float*/ = FinderPatternFinder.centerFromEnd(stateCount, j);
                let centerI: number /*float*/ = this.crossCheckVertical(i, /*(int) */Math.floor(centerJ), stateCount[2], stateCountTotal);
        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 addEdges has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

          static addEdges(
            input: Input,
            edges: Edge[][],
            from: number,
            previous: Edge
        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 sizeOfBlackWhiteBlackRun has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

          private sizeOfBlackWhiteBlackRun(fromX: number /*int*/, fromY: number /*int*/, toX: number /*int*/, toY: number /*int*/): number/*float*/ {
            // Mild variant of Bresenham's algorithm
            // see http://en.wikipedia.org/wiki/Bresenham's_line_algorithm
            const steep: boolean = Math.abs(toY - fromY) > Math.abs(toX - fromX);
            if (steep) {
        Severity: Minor
        Found in src/core/qrcode/detector/Detector.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 buildBitArray has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

          static buildBitArray(pairs: Array<ExpandedPair>): BitArray {
            let charNumber: number = pairs.length * 2 - 1;
            if (pairs[pairs.length - 1].getRightChar() == null) {
              charNumber -= 1;
            }
        Severity: Minor
        Found in src/core/oned/rss/expanded/BitArrayBuilder.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 constructor has 63 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          constructor(solution: Edge) {
            const input = solution.input;
            let size = 0;
            let bytesAL: number[] = [];
            const randomizePostfixLength = [];
        Severity: Major
        Found in src/core/datamatrix/encoder/MinimalEncoder.ts - About 2 hrs to fix

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

            private 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/Code93Reader.ts - About 2 hrs to fix

            Function buildVersions has 62 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              private static buildVersions(): Version[] {
                return [
                    new Version(1, 10, 10, 8, 8,
                        new ECBlocks(5, new ECB(1, 3))),
                    new Version(2, 12, 12, 10, 10,
            Severity: Major
            Found in src/core/datamatrix/decoder/Version.ts - About 2 hrs to fix

              Function addEdges has 61 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                static addEdges(
                  input: Input,
                  edges: Edge[][],
                  from: number,
                  previous: Edge
              Severity: Major
              Found in src/core/datamatrix/encoder/MinimalEncoder.ts - About 2 hrs to fix

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

                  static encodeMinimally(input: Input): Result {
                    /* The minimal encoding is computed by Dijkstra. The acyclic graph is modeled as follows:
                     * A vertex represents a combination of a position in the input and an encoding mode where position 0
                     * denotes the position left of the first character, 1 the position left of the second character and so on.
                     * Likewise the end vertices are located after the last character at position input.length().
                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 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

                Severity
                Category
                Status
                Source
                Language