zxing-js/library

View on GitHub

Showing 958 of 958 total issues

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

    public aboutEquals(moduleSize: number/*float*/, i: number/*float*/, j: number/*float*/): boolean {
        if (Math.abs(i - this.getY()) <= moduleSize && Math.abs(j - this.getX()) <= moduleSize) {
            const moduleSizeDiff: number /*float*/ = Math.abs(moduleSize - this.estimatedModuleSize);
            return moduleSizeDiff <= 1.0 || moduleSizeDiff <= this.estimatedModuleSize;
        }
Severity: Major
Found in src/core/qrcode/detector/AlignmentPattern.ts and 1 other location - About 3 hrs to fix
src/core/qrcode/detector/FinderPattern.ts on lines 59..65

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

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 findNextPair has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

  private findNextPair(
    row: BitArray,
    previousPairs: Array<ExpandedPair>,
    forcedOffset: number
  ): void {
Severity: Minor
Found in src/core/oned/rss/expanded/RSSExpandedReader.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 static_CHAR_MAP has 95 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function static_CHAR_MAP(CHAR_MAP: Int32Array[]): Int32Array[] {
  const spaceCharCode = StringUtils.getCharCode(' ');
  const pointCharCode = StringUtils.getCharCode('.');
  const commaCharCode = StringUtils.getCharCode(',');

Severity: Major
Found in src/core/aztec/encoder/CharMap.ts - About 3 hrs to fix

    Function readCodewords has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        public readCodewords(): Uint8Array /*throws FormatException*/ {
    
            const formatInfo = this.readFormatInformation();
            const version = this.readVersion();
    
    
    Severity: Minor
    Found in src/core/qrcode/decoder/BitMatrixParser.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 form has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

      private static form(str: string, arr: any[]) {
    
        let i = -1;
    
        function callback(exp: string | number, p0: any, p1: any, p2: any, p3: any, p4: any) {
    Severity: Minor
    Found in src/core/util/Formatter.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 format has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

      public static format(append: string, ...args: any[]) {
    
        let i = -1;
    
        function callback(exp: string | number, p0: any, p1: any, p2: any, p3: any, p4: any) {
    Severity: Minor
    Found in src/core/common/StringUtils.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

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

                    if (alpha === 0) {
                        gray = 0xFF;
                    } else {
                        const pixelR = imageBuffer[i];
                        const pixelG = imageBuffer[i + 1];
    Severity: Major
    Found in src/browser/HTMLCanvasElementLuminanceSource.ts and 1 other location - About 3 hrs to fix
    src/browser/HTMLCanvasElementLuminanceSource.ts on lines 38..51

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

    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

                    if (alpha === 0) {
                        gray = 0xFF;
                    } else {
                        const pixelR = imageBuffer[i];
                        const pixelG = imageBuffer[i + 1];
    Severity: Major
    Found in src/browser/HTMLCanvasElementLuminanceSource.ts and 1 other location - About 3 hrs to fix
    src/browser/HTMLCanvasElementLuminanceSource.ts on lines 63..76

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

    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 adjustOddEvenCounts has 93 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      private adjustOddEvenCounts(numModules) {
        let oddSum = MathUtils.sum(new Int32Array(this.getOddCounts()));
        let evenSum = MathUtils.sum(new Int32Array(this.getEvenCounts()));
    
        let incrementOdd = false;
    Severity: Major
    Found in src/core/oned/rss/expanded/RSSExpandedReader.ts - About 3 hrs to fix

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

        protected static decrement(array: number[], errors: number[]) {
          let index = 0;
          let biggestError = errors[0];
          for (let i = 1; i < array.length; i++) {
            if (errors[i] < biggestError) {
      Severity: Major
      Found in src/core/oned/rss/AbstractRSSReader.ts and 1 other location - About 3 hrs to fix
      src/core/oned/rss/AbstractRSSReader.ts on lines 74..84

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

      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

        protected static increment(array: number[], errors: number[]) {
          let index = 0;
          let biggestError = errors[0];
          for (let i = 1; i < array.length; i++) {
            if (errors[i] > biggestError) {
      Severity: Major
      Found in src/core/oned/rss/AbstractRSSReader.ts and 1 other location - About 3 hrs to fix
      src/core/oned/rss/AbstractRSSReader.ts on lines 86..96

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

      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 toNarrowWidePattern has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

        private static toNarrowWidePattern(counters: Int32Array): number {
          let numCounters = counters.length;
          let maxNarrowCounter = 0;
          let wideCounters: number;
          do {
      Severity: Minor
      Found in src/core/oned/Code39Reader.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 findRowsWithPattern has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

        private static  findRowsWithPattern( matrix: BitMatrix,
                                                          height: /*int*/ number,
                                                          width: /*int*/ number,
                                                          startRow: /*int*/ number,
                                                          startColumn: /*int*/ number,
      Severity: Minor
      Found in src/core/pdf417/detector/Detector.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

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

          for (
            let inputY = 0, outputY = topPadding;
            inputY < matrixHeight;
            inputY++, outputY += multiple
          ) {
      Severity: Major
      Found in src/core/datamatrix/DataMatrixWriter.ts and 1 other location - About 3 hrs to fix
      src/core/qrcode/QRCodeWriter.ts on lines 106..113

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

      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

              for (let inputY = 0, outputY = topPadding; inputY < inputHeight; inputY++ , outputY += multiple) {
                  // Write the contents of this row of the barcode
                  for (let inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++ , outputX += multiple) {
                      if (input.get(inputX, inputY) === 1) {
                          output.setRegion(outputX, outputY, multiple, multiple);
      Severity: Major
      Found in src/core/qrcode/QRCodeWriter.ts and 1 other location - About 3 hrs to fix
      src/core/datamatrix/DataMatrixWriter.ts on lines 226..241

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

      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 decodeDataCharacter has 87 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        decodeDataCharacter(
          row: BitArray,
          pattern: FinderPattern,
          isOddPattern: boolean,
          leftChar: boolean
      Severity: Major
      Found in src/core/oned/rss/expanded/RSSExpandedReader.ts - About 3 hrs to fix

        Function constructor has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

          constructor(
            public readonly input: Input,
            public readonly mode: Mode,
            public readonly fromPosition: number,
            public readonly characterLength: number,
        Severity: Minor
        Found in src/core/datamatrix/encoder/MinimalEncoder.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 readCodewords has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

          readCodewords(): Int8Array {
        
            const result = new Int8Array(this.version.getTotalCodewords());
            let resultOffset = 0;
        
        
        Severity: Minor
        Found in src/core/datamatrix/decoder/BitMatrixParser.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 embedDataBits has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

            public static embedDataBits(dataBits: BitArray, maskPattern: number /*int*/, matrix: ByteMatrix): void {
                let bitIndex = 0;
                let direction = -1;
                // Start from the right bottom cell.
                let x = matrix.getWidth() - 1;
        Severity: Minor
        Found in src/core/qrcode/encoder/MatrixUtil.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 createBarcodeMatrix has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

          private static createBarcodeMatrix(detectionResult: DetectionResult): BarcodeValue[][] {
            // let barcodeMatrix: BarcodeValue[][] =
              // new BarcodeValue[detectionResult.getBarcodeRowCount()][detectionResult.getBarcodeColumnCount() + 2];
            let barcodeMatrix: BarcodeValue[][] =
              Array.from({ length: detectionResult.getBarcodeRowCount() }, () => new Array(detectionResult.getBarcodeColumnCount() + 2));
        Severity: Minor
        Found in src/core/pdf417/decoder/PDF417ScanningDecoder.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

        Severity
        Category
        Status
        Source
        Language