zxing-js/library

View on GitHub

Showing 605 of 958 total issues

Consider simplifying this complex logical expression.
Open

    if ((barcodeColumnCount.getValue().length === 0) ||
        (barcodeRowCountUpperPart.getValue().length === 0) ||
        (barcodeRowCountLowerPart.getValue().length === 0) ||
        (barcodeECLevel.getValue().length === 0) ||
        barcodeColumnCount.getValue()[0] < 1 ||
Severity: Major
Found in src/core/pdf417/decoder/DetectionResultRowIndicatorColumn.ts - About 1 hr to fix

    Function encode has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      public encode(context: EncoderContext) {
        // step B
        const n = HighLevelEncoder.determineConsecutiveDigitCount(
          context.getMessage(),
          context.pos
    Severity: Minor
    Found in src/core/datamatrix/encoder/ASCIIEncoder.ts - About 55 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 encodeChar has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      encodeChar(c: char, sb: StringBuilder): number {
        if (c === ' '.charCodeAt(0)) {
          sb.append(0o3);
          return 1;
        }
    Severity: Minor
    Found in src/core/datamatrix/encoder/C40Encoder.ts - About 55 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 encode has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public encode(contents: string,
            format: BarcodeFormat,
            width: number /*int*/,
            height: number /*int*/,
            hints: Map<EncodeHintType, any>): BitMatrix /*throws WriterException */ {
    Severity: Minor
    Found in src/core/qrcode/QRCodeWriter.ts - About 55 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 initialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      static initialize() {
         // Pre-computes the symbol ratio table.
        for (/*int*/let i = 0; i < PDF417Common.SYMBOL_TABLE.length; i++) {
          let currentSymbol: int = PDF417Common.SYMBOL_TABLE[i];
          let currentBit: int = currentSymbol & 0x1;
    Severity: Minor
    Found in src/core/pdf417/decoder/PDF417CodewordDecoder.ts - About 55 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 moduleSize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      private static moduleSize(leftTopBlack: Int32Array, image: BitMatrix): number/*float*/ /*throws NotFoundException */ {
        const height: number /*int*/ = image.getHeight();
        const width: number /*int*/ = image.getWidth();
        let x = leftTopBlack[0];
        let y = leftTopBlack[1];
    Severity: Minor
    Found in src/core/qrcode/QRCodeReader.ts - About 55 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 appendAlphanumericBytes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public static appendAlphanumericBytes(content: string, bits: BitArray): void /*throws WriterException*/ {
            const length = content.length;
            let i = 0;
            while (i < length) {
                const code1 = Encoder.getAlphanumericCode(content.charCodeAt(i));
    Severity: Minor
    Found in src/core/qrcode/encoder/Encoder.ts - About 55 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 extractPureBits has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      private static extractPureBits(image: BitMatrix): BitMatrix {
    
        const leftTopBlack = image.getTopLeftOnBit();
        const rightBottomBlack = image.getBottomRightOnBit();
        if (leftTopBlack == null || rightBottomBlack == null) {
    Severity: Minor
    Found in src/core/datamatrix/DataMatrixReader.ts - About 55 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 convertByteMatrixToBitMatrix has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      private convertByteMatrixToBitMatrix(
        matrix: ByteMatrix,
        reqWidth: number,
        reqHeight: number
      ): BitMatrix {
    Severity: Minor
    Found in src/core/datamatrix/DataMatrixWriter.ts - About 55 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 equals has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public equals(o: any) {
            if (!(o instanceof ByteMatrix)) {
                return false;
            }
            const other = <ByteMatrix>o;
    Severity: Minor
    Found in src/core/qrcode/encoder/ByteMatrix.ts - About 55 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 adjustRowNumbers has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      private adjustRowNumbers(barcodeColumn: int, codewordsRow: int, codewords: Codeword[]): void {
        if (this.detectionResultColumns[barcodeColumn - 1] == null) {
          return;
        }
    
    
    Severity: Minor
    Found in src/core/pdf417/decoder/DetectionResult.ts - About 55 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 getBlackMatrix has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public getBlackMatrix(): BitMatrix /*throws NotFoundException*/ {
            const source = this.getLuminanceSource();
            const width = source.getWidth();
            const height = source.getHeight();
            const matrix = new BitMatrix(width, height);
    Severity: Minor
    Found in src/core/common/GlobalHistogramBinarizer.ts - About 55 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 createDecoderResult has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      private static createDecoderResult(detectionResult: DetectionResult): DecoderResult {
        let barcodeMatrix: BarcodeValue[][] = PDF417ScanningDecoder.createBarcodeMatrix(detectionResult);
        PDF417ScanningDecoder.adjustCodewordCount(detectionResult, barcodeMatrix);
        let erasures /*Collection<Integer>*/ = new Array<number>();
        let codewords: Int32Array = new Int32Array(detectionResult.getBarcodeRowCount() * detectionResult.getBarcodeColumnCount());
    Severity: Minor
    Found in src/core/pdf417/decoder/PDF417ScanningDecoder.ts - About 55 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 constructor has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public constructor(private text: string,
          private rawBytes: Uint8Array,
          private numBits: number /*int*/ = rawBytes == null ? 0 : 8 * rawBytes.length,
          private resultPoints: ResultPoint[],
          private format: BarcodeFormat,
    Severity: Minor
    Found in src/core/Result.ts - About 55 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 getBullsEyeCorners has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        private getBullsEyeCorners(pCenter: Point): ResultPoint[] {
    
    
            let pina = pCenter;
            let pinb = pCenter;
    Severity: Minor
    Found in src/core/aztec/detector/Detector.ts - About 55 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 decodeRow has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      public decodeRow(rowNumber: number, row: BitArray, hints?: Map<DecodeHintType, any>): Result {
    
        let start = this.findAsteriskPattern(row);
        // Read off white space
        let nextStart = row.getNextSet(start[1]);
    Severity: Minor
    Found in src/core/oned/Code93Reader.ts - About 55 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 toString has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      public toString(): string {
        const row = new Uint8ClampedArray(this.width);
        let result = new StringBuilder();
        for (let y = 0; y < this.height; y++) {
          const sourceRow = this.getRow(y, row);
    Severity: Minor
    Found in src/core/LuminanceSource.ts - About 55 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 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public decode(image: BinaryBitmap, hints: Map<DecodeHintType, any> | null = null): Result {
    
            let exception: Exception = null;
            let detector = new Detector(image.getBlackMatrix());
            let points: ResultPoint[] = null;
    Severity: Minor
    Found in src/core/aztec/AztecReader.ts - About 55 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

                while (p < msg.length) {
                  const tc = msg.charCodeAt(p);
                  if (this.isX12TermSep(tc)) {
                    return X12_ENCODATION;
                  }
    Severity: Major
    Found in src/core/datamatrix/encoder/HighLevelEncoder.ts - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                  if (oneByte !== 254 || bits.available() !== 0) {
                    throw new FormatException();
                  }
      Severity: Major
      Found in src/core/datamatrix/decoder/DecodedBitStreamParser.ts - About 45 mins to fix
        Severity
        Category
        Status
        Source
        Language