zxing-js/library

View on GitHub

Showing 958 of 958 total issues

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

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

          for (let barcodeColumn /*int*/ = this.barcodeColumnCount + 1; barcodeColumn > 0 && invalidRowCounts < this.ADJUST_ROW_NUMBER_SKIP; barcodeColumn--) {
            let codeword: Codeword = this.detectionResultColumns[barcodeColumn].getCodewords()[codewordsRow];
            if (codeword != null) {
              invalidRowCounts = DetectionResult.adjustRowNumberIfValid(rowIndicatorRowNumber, invalidRowCounts, codeword);
              if (!codeword.hasValidRowNumber()) {
    Severity: Major
    Found in src/core/pdf417/decoder/DetectionResult.ts and 1 other location - About 2 hrs to fix
    src/core/pdf417/decoder/DetectionResult.ts on lines 169..177

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

    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

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

          for (let barcodeColumn /*int*/ = 1; barcodeColumn < this.barcodeColumnCount + 1 && invalidRowCounts < this.ADJUST_ROW_NUMBER_SKIP; barcodeColumn++) {
            let codeword: Codeword = this.detectionResultColumns[barcodeColumn].getCodewords()[codewordsRow];
            if (codeword != null) {
              invalidRowCounts = DetectionResult.adjustRowNumberIfValid(rowIndicatorRowNumber, invalidRowCounts, codeword);
              if (!codeword.hasValidRowNumber()) {
    Severity: Major
    Found in src/core/pdf417/decoder/DetectionResult.ts and 1 other location - About 2 hrs to fix
    src/core/pdf417/decoder/DetectionResult.ts on lines 144..152

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

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

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

            if (this.isNativeText(c)) {
              charCounts[TEXT_ENCODATION] += 2.0 / 3.0;
            } else if (this.isExtendedASCII(c)) {
              charCounts[TEXT_ENCODATION] += 8.0 / 3.0;
            } else {
      Severity: Major
      Found in src/core/datamatrix/encoder/HighLevelEncoder.ts and 3 other locations - About 2 hrs to fix
      src/core/datamatrix/encoder/HighLevelEncoder.ts on lines 228..234
      src/core/datamatrix/encoder/HighLevelEncoder.ts on lines 246..252
      src/core/datamatrix/encoder/HighLevelEncoder.ts on lines 255..261

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

      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 4 locations. Consider refactoring.
      Open

            if (this.isNativeX12(c)) {
              charCounts[X12_ENCODATION] += 2.0 / 3.0;
            } else if (this.isExtendedASCII(c)) {
              charCounts[X12_ENCODATION] += 13.0 / 3.0;
            } else {
      Severity: Major
      Found in src/core/datamatrix/encoder/HighLevelEncoder.ts and 3 other locations - About 2 hrs to fix
      src/core/datamatrix/encoder/HighLevelEncoder.ts on lines 228..234
      src/core/datamatrix/encoder/HighLevelEncoder.ts on lines 237..243
      src/core/datamatrix/encoder/HighLevelEncoder.ts on lines 255..261

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

      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 4 locations. Consider refactoring.
      Open

            if (this.isNativeEDIFACT(c)) {
              charCounts[EDIFACT_ENCODATION] += 3.0 / 4.0;
            } else if (this.isExtendedASCII(c)) {
              charCounts[EDIFACT_ENCODATION] += 17.0 / 4.0;
            } else {
      Severity: Major
      Found in src/core/datamatrix/encoder/HighLevelEncoder.ts and 3 other locations - About 2 hrs to fix
      src/core/datamatrix/encoder/HighLevelEncoder.ts on lines 228..234
      src/core/datamatrix/encoder/HighLevelEncoder.ts on lines 237..243
      src/core/datamatrix/encoder/HighLevelEncoder.ts on lines 246..252

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

      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 4 locations. Consider refactoring.
      Open

            if (this.isNativeC40(c)) {
              charCounts[C40_ENCODATION] += 2.0 / 3.0;
            } else if (this.isExtendedASCII(c)) {
              charCounts[C40_ENCODATION] += 8.0 / 3.0;
            } else {
      Severity: Major
      Found in src/core/datamatrix/encoder/HighLevelEncoder.ts and 3 other locations - About 2 hrs to fix
      src/core/datamatrix/encoder/HighLevelEncoder.ts on lines 237..243
      src/core/datamatrix/encoder/HighLevelEncoder.ts on lines 246..252
      src/core/datamatrix/encoder/HighLevelEncoder.ts on lines 255..261

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

      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

                  while ((rightBorderNotWhite || !atLeastOneBlackPointFoundOnRight) && right < this.width) {
                      rightBorderNotWhite = this.containsBlackPoint(up, down, right, false);
                      if (rightBorderNotWhite) {
                          right++;
                          aBlackPointFoundOnBorder = true;
      Severity: Major
      Found in src/core/common/detector/CornerDetector.ts and 1 other location - About 2 hrs to fix
      src/core/common/detector/CornerDetector.ts on lines 100..109

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

      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 (code < 96) {
                  if (shiftUpperMode === upperMode) {
                    result += String.fromCharCode((' '.charCodeAt(0) + code));
                  } else {
                    result += String.fromCharCode((' '.charCodeAt(0) + code + 128));
      Severity: Major
      Found in src/core/oned/Code128Reader.ts and 1 other location - About 2 hrs to fix
      src/core/oned/Code128Reader.ts on lines 317..379

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

      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

                  while ((bottomBorderNotWhite || !atLeastOneBlackPointFoundOnBottom) && down < this.height) {
                      bottomBorderNotWhite = this.containsBlackPoint(left, right, down, true);
                      if (bottomBorderNotWhite) {
                          down++;
                          aBlackPointFoundOnBorder = true;
      Severity: Major
      Found in src/core/common/detector/CornerDetector.ts and 1 other location - About 2 hrs to fix
      src/core/common/detector/CornerDetector.ts on lines 80..89

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

      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 (code < 64) {
                  if (shiftUpperMode === upperMode) {
                    result += String.fromCharCode((' '.charCodeAt(0) + code));
                  } else {
                    result += String.fromCharCode((' '.charCodeAt(0) + code + 128));
      Severity: Major
      Found in src/core/oned/Code128Reader.ts and 1 other location - About 2 hrs to fix
      src/core/oned/Code128Reader.ts on lines 382..435

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

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

          private static createECCBlock(codewords: string, numECWords: number): string {
            let table = -1;
            for (let i = 0; i < FACTOR_SETS.length; i++) {
              if (FACTOR_SETS[i] === numECWords) {
                table = i;
        Severity: Minor
        Found in src/core/datamatrix/encoder/ErrorCorrection.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 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 encode has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

          public encode(
            contents: string,
            format: BarcodeFormat,
            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 crossCheckHorizontal has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            private crossCheckHorizontal(startJ: number /*int*/, centerI: number /*int*/, maxCount: number /*int*/,
                originalStateCountTotal: number /*int*/): number/*float*/ {
                const image: BitMatrix = this.image;
        
                const maxJ = image.getWidth();
        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 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

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

          private static decodeAlphanumericSegment(bits: BitSource,
            result: StringBuilder,
            count: number /*int*/,
            fc1InEffect: boolean): void /*throws FormatException*/ {
            // Read two characters at a time
        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

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

            public static getDataBlocks(rawCodewords: Uint8Array,
                version: Version,
                ecLevel: ErrorCorrectionLevel): DataBlock[] {
        
                if (rawCodewords.length !== version.getTotalCodewords()) {
        Severity: Minor
        Found in src/core/qrcode/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

        Severity
        Category
        Status
        Source
        Language