zxing-js/library

View on GitHub

Showing 605 of 958 total issues

Function toString has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

  public toString(): String {
    let result: StringBuilder = new StringBuilder(/*8 * this.getDegree()*/); // dynamic string size in JS
    for (let degree /*int*/ = this.getDegree(); degree >= 0; degree--) {
      let coefficient: /*int*/ number = this.getCoefficient(degree);
      if (coefficient !== 0) {
Severity: Minor
Found in src/core/pdf417/decoder/ec/ModulusPoly.ts - About 3 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 parseFromString has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public static parseFromString(stringRepresentation: string, setString: string, unsetString: string): BitMatrix {
        if (stringRepresentation === null) {
            throw new IllegalArgumentException('stringRepresentation cannot be null');
        }

Severity: Minor
Found in src/core/common/BitMatrix.ts - About 3 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 checkAndNudgePoints has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    protected static checkAndNudgePoints(
        image: BitMatrix,
        points: Float32Array
    ): void /*throws NotFoundException*/ {

Severity: Minor
Found in src/core/common/GridSampler.ts - About 3 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 a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

  public constructor(hints?: Map<DecodeHintType, any>) {
    super();
    const possibleFormats = !hints ? null : <BarcodeFormat[]>hints.get(DecodeHintType.POSSIBLE_FORMATS);
    const useCode39CheckDigit = hints && hints.get(DecodeHintType.ASSUME_CODE_39_CHECK_DIGIT) !== undefined;
    const useCode39ExtendedMode = hints && hints.get(DecodeHintType.ENABLE_CODE_39_EXTENDED_MODE) !== undefined;
Severity: Minor
Found in src/core/oned/MultiFormatOneDReader.ts - About 3 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 decodeDataCharacter has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    private decodeDataCharacter(row: BitArray, pattern: FinderPattern, outsideChar: boolean): DataCharacter {

        let counters = this.getDataCharacterCounters();
        for (let x = 0; x < counters.length; x++) {
            counters[x] = 0;
Severity: Minor
Found in src/core/oned/rss/RSS14Reader.ts - About 3 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 findStartPattern has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

  private static findStartPattern(row: BitArray): Int32Array {
    const width = row.getSize();
    const rowOffset = row.getNextSet(0);

        let counterPosition = 0;
Severity: Minor
Found in src/core/oned/Code128Reader.ts - About 3 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

File BitMatrix.ts has 295 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * Copyright 2007 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/common/BitMatrix.ts - About 3 hrs to fix

    Function decodeC40Segment has 76 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      private static decodeC40Segment(bits: BitSource, result: StringBuilder): void {
        // Three C40 values are encoded in a 16-bit value as
        // (1600 * C1) + (40 * C2) + C3 + 1
        // TODO(bbrown): The Upper Shift with C40 doesn't work in the 4 value scenario all the time
        let upperShift = false;
    Severity: Major
    Found in src/core/datamatrix/decoder/DecodedBitStreamParser.ts - About 3 hrs to fix

      Function decodeMacroBlock has 75 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        static decodeMacroBlock(codewords: Int32Array, codeIndex: int, resultMetadata: PDF417ResultMetadata): int {
          if (codeIndex + DecodedBitStreamParser.NUMBER_OF_SEQUENCE_CODEWORDS > codewords[0]) {
            // we must have at least two bytes left for the segment index
            throw FormatException.getFormatInstance();
          }
      Severity: Major
      Found in src/core/pdf417/decoder/DecodedBitStreamParser.ts - About 3 hrs to fix

        BitArray has 26 functions (exceeds 20 allowed). Consider refactoring.
        Open

        export default class BitArray /*implements Cloneable*/ {
        
          private size: number;
          private bits: Int32Array;
        
        
        Severity: Minor
        Found in src/core/common/BitArray.ts - About 3 hrs to fix

          PDF417ScanningDecoder has 26 functions (exceeds 20 allowed). Consider refactoring.
          Open

          export default /*public final*/ class PDF417ScanningDecoder {
          
            /*final*/ static CODEWORD_SKEW_SIZE: int = 2;
          
            /*final*/ static MAX_ERRORS: int = 3;
          Severity: Minor
          Found in src/core/pdf417/decoder/PDF417ScanningDecoder.ts - About 3 hrs to fix

            File MatrixUtil.ts has 289 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            /*
             * Copyright 2008 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/qrcode/encoder/MatrixUtil.ts - About 2 hrs to fix

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

                public static decode(bytes: Uint8Array,
                  version: Version,
                  ecLevel: ErrorCorrectionLevel,
                  hints: Map<DecodeHintType, any>): DecoderResult /*throws FormatException*/ {
                  const bits = new BitSource(bytes);
              Severity: Major
              Found in src/core/qrcode/decoder/DecodedBitStreamParser.ts - About 2 hrs to fix

                Function getX12Value has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                Open

                  getX12Value(c: number): number {
                    return c === 13
                      ? 0
                      : c === 42
                      ? 1
                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 decodeAsciiSegment has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                Open

                  private static decodeAsciiSegment(bits: BitSource,
                                                         result: StringBuilder,
                                                         resultTrailer: StringBuilder): Mode {
                    let upperShift = false;
                    do {
                Severity: Minor
                Found in src/core/datamatrix/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 decode has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                Open

                  public static decode(bytes: Uint8Array,
                    version: Version,
                    ecLevel: ErrorCorrectionLevel,
                    hints: Map<DecodeHintType, any>): DecoderResult /*throws FormatException*/ {
                    const bits = new BitSource(bytes);
                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

                Encoder has 25 functions (exceeds 20 allowed). Consider refactoring.
                Open

                export default class Encoder {
                
                    // The original table is defined in the table 5 of JISX0510:2004 (p.19).
                    private static ALPHANUMERIC_TABLE = Int32Array.from([
                        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  // 0x00-0x0f
                Severity: Minor
                Found in src/core/qrcode/encoder/Encoder.ts - About 2 hrs to fix

                  Function getLastASCII has 69 lines of code (exceeds 25 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: Major
                  Found in src/core/datamatrix/encoder/MinimalEncoder.ts - About 2 hrs to fix

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

                      static getNumberOfC40Words(
                        input: Input,
                        from: number,
                        c40: boolean,
                        characterLength: number[]
                    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 extractPureBits has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                    Open

                      private static extractPureBits(image: BitMatrix): BitMatrix /*throws NotFoundException */ {
                    
                        const leftTopBlack: Int32Array = image.getTopLeftOnBit();
                        const rightBottomBlack: Int32Array = image.getBottomRightOnBit();
                        if (leftTopBlack === null || rightBottomBlack === null) {
                    Severity: Minor
                    Found in src/core/qrcode/QRCodeReader.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