zxing-js/library

View on GitHub

Showing 958 of 958 total issues

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 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

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

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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      public decodeFromImage(
        source?: string | HTMLImageElement,
        url?: string
      ): Promise<Result> {
        if (!source && !url) {
    Severity: Major
    Found in src/browser/BrowserCodeReader.ts and 1 other location - About 3 hrs to fix
    src/browser/BrowserCodeReader.ts on lines 543..558

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 96.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      public decodeFromVideo(
        source?: string | HTMLVideoElement,
        url?: string
      ): Promise<Result> {
        if (!source && !url) {
    Severity: Major
    Found in src/browser/BrowserCodeReader.ts and 1 other location - About 3 hrs to fix
    src/browser/BrowserCodeReader.ts on lines 517..532

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 96.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        private static embedPositionAdjustmentPattern(xStart: number /*int*/, yStart: number /*int*/, matrix: ByteMatrix): void {
            for (let y = 0; y < 5; ++y) {
                const patternY: Int32Array = MatrixUtil.POSITION_ADJUSTMENT_PATTERN[y];
                for (let x = 0; x < 5; ++x) {
                    matrix.setNumber(xStart + x, yStart + y, patternY[x]);
    Severity: Major
    Found in src/core/qrcode/encoder/MatrixUtil.ts and 1 other location - About 3 hrs to fix
    src/core/qrcode/encoder/MatrixUtil.ts on lines 418..425

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 96.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      static isNativeText(ch: number): boolean {
        return (
          ch === ' '.charCodeAt(0) ||
          (ch >= '0'.charCodeAt(0) && ch <= '9'.charCodeAt(0)) ||
          (ch >= 'a'.charCodeAt(0) && ch <= 'z'.charCodeAt(0))
    Severity: Major
    Found in src/core/datamatrix/encoder/HighLevelEncoder.ts and 1 other location - About 3 hrs to fix
    src/core/datamatrix/encoder/HighLevelEncoder.ts on lines 419..425

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 96.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      static isNativeC40(ch: number): boolean {
        return (
          ch === ' '.charCodeAt(0) ||
          (ch >= '0'.charCodeAt(0) && ch <= '9'.charCodeAt(0)) ||
          (ch >= 'A'.charCodeAt(0) && ch <= 'Z'.charCodeAt(0))
    Severity: Major
    Found in src/core/datamatrix/encoder/HighLevelEncoder.ts and 1 other location - About 3 hrs to fix
    src/core/datamatrix/encoder/HighLevelEncoder.ts on lines 427..433

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 96.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        private static embedPositionDetectionPattern(xStart: number /*int*/, yStart: number /*int*/, matrix: ByteMatrix): void {
            for (let y = 0; y < 7; ++y) {
                const patternY: Int32Array = MatrixUtil.POSITION_DETECTION_PATTERN[y];
                for (let x = 0; x < 7; ++x) {
                    matrix.setNumber(xStart + x, yStart + y, patternY[x]);
    Severity: Major
    Found in src/core/qrcode/encoder/MatrixUtil.ts and 1 other location - About 3 hrs to fix
    src/core/qrcode/encoder/MatrixUtil.ts on lines 409..416

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 96.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                const moduleSizeEst1: number /*float*/ = this.sizeOfBlackWhiteBlackRunBothWays(/*(int) */Math.floor(pattern.getX()),
                    /*(int) */Math.floor(pattern.getY()),
                    /*(int) */Math.floor(otherPattern.getX()),
                    /*(int) */Math.floor(otherPattern.getY()));
            Severity: Major
            Found in src/core/qrcode/detector/Detector.ts and 1 other location - About 2 hrs to fix
            src/core/qrcode/detector/Detector.ts on lines 251..254

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 94.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                const moduleSizeEst2: number /*float*/ = this.sizeOfBlackWhiteBlackRunBothWays(/*(int) */Math.floor(otherPattern.getX()),
                    /*(int) */Math.floor(otherPattern.getY()),
                    /*(int) */Math.floor(pattern.getX()),
                    /*(int) */Math.floor(pattern.getY()));
            Severity: Major
            Found in src/core/qrcode/detector/Detector.ts and 1 other location - About 2 hrs to fix
            src/core/qrcode/detector/Detector.ts on lines 247..250

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 94.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            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 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

                Severity
                Category
                Status
                Source
                Language