zxing-js/library

View on GitHub

Showing 958 of 958 total issues

Function crossCheckVertical has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    private crossCheckVertical(startI: number /*int*/, centerJ: number /*int*/, maxCount: number /*int*/,
        originalStateCountTotal: number /*int*/): number/*float*/ {
        const image = this.image;

        const maxI = image.getHeight();
Severity: Minor
Found in src/core/qrcode/detector/AlignmentPatternFinder.ts - About 1 hr 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 removePartialRows has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  private removePartialRows(
    pairs: Array<ExpandedPair>,
    rows: Array<ExpandedRow>
  ): void {
    // for (Iterator<ExpandedRow> iterator = rows.iterator(); iterator.hasNext();) {
Severity: Minor
Found in src/core/oned/rss/expanded/RSSExpandedReader.ts - About 1 hr 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 findFinderPattern has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    private findFinderPattern(row: BitArray, rightFinderPattern: boolean): number[] {

        let counters = this.getDecodeFinderCounters();
        counters[0] = 0;
        counters[1] = 0;
Severity: Minor
Found in src/core/oned/rss/RSS14Reader.ts - About 1 hr 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 isPartialRow has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  private static isPartialRow(pairs: any, rows: any): boolean {
    for (let r of rows) {
      let allFound = true;
      for (let p of pairs) {
        let found = false;
Severity: Minor
Found in src/core/oned/rss/expanded/RSSExpandedReader.ts - About 1 hr 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 extractBits has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    private extractBits(matrix: BitMatrix): boolean[] {
        let compact = this.ddata.isCompact();
        let layers = this.ddata.getNbLayers();
        let baseMatrixSize = (compact ? 11 : 14) + layers * 4; // not including alignment lines
        let alignmentMap = new Int32Array(baseMatrixSize);
Severity: Minor
Found in src/core/aztec/decoder/Decoder.ts - About 1 hr 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

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

    for (let i = 0; i < shorterBlocksNumDataCodewords; i++) {
      for (let j = 0; j < numResultBlocks; j++) {
        result[j].codewords[i] = rawCodewords[rawCodewordsOffset++];
      }
    }
Severity: Major
Found in src/core/datamatrix/decoder/DataBlock.ts and 1 other location - About 1 hr to fix
src/core/qrcode/decoder/DataBlock.ts on lines 96..100

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

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 i = 0; i < shorterBlocksNumDataCodewords; i++) {
            for (let j = 0; j < numResultBlocks; j++) {
                result[j].codewords[i] = rawCodewords[rawCodewordsOffset++];
            }
        }
Severity: Major
Found in src/core/qrcode/decoder/DataBlock.ts and 1 other location - About 1 hr to fix
src/core/datamatrix/decoder/DataBlock.ts on lines 82..86

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

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

  public encode(context: EncoderContext): void {
    // step C
    const buffer = new StringBuilder();
    while (context.hasMoreCharacters()) {
      const c = context.getCurrentChar();
Severity: Minor
Found in src/core/datamatrix/encoder/C40Encoder.ts - About 1 hr to fix

    Function handleEOD has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      private handleEOD(context: EncoderContext, buffer: StringBuilder) {
        try {
          const count = buffer.length();
          if (count === 0) {
            return; // Already finished
    Severity: Minor
    Found in src/core/datamatrix/encoder/EdifactEncoder.ts - About 1 hr to fix

      Function interleaveWithECBytes has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static interleaveWithECBytes(bits: BitArray,
              numTotalBytes: number /*int*/,
              numDataBytes: number /*int*/,
              numRSBlocks: number /*int*/): BitArray /*throws WriterException*/ {
      
      
      Severity: Minor
      Found in src/core/qrcode/encoder/Encoder.ts - About 1 hr to fix

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

                    case DecodedBitStreamParser.MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM:
                      let checksum: StringBuilder = new StringBuilder();
                      codeIndex = DecodedBitStreamParser.numericCompaction(codewords, codeIndex + 1, checksum);
                      resultMetadata.setChecksum(Integer.parseInt(checksum.toString()));
                      break;
        Severity: Major
        Found in src/core/pdf417/decoder/DecodedBitStreamParser.ts and 3 other locations - About 1 hr to fix
        src/core/pdf417/decoder/DecodedBitStreamParser.ts on lines 306..310
        src/core/pdf417/decoder/DecodedBitStreamParser.ts on lines 311..315
        src/core/pdf417/decoder/DecodedBitStreamParser.ts on lines 321..325

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

        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

                    case DecodedBitStreamParser.MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT:
                      let segmentCount: StringBuilder = new StringBuilder();
                      codeIndex = DecodedBitStreamParser.numericCompaction(codewords, codeIndex + 1, segmentCount);
                      resultMetadata.setSegmentCount(Integer.parseInt(segmentCount.toString()));
                      break;
        Severity: Major
        Found in src/core/pdf417/decoder/DecodedBitStreamParser.ts and 3 other locations - About 1 hr to fix
        src/core/pdf417/decoder/DecodedBitStreamParser.ts on lines 311..315
        src/core/pdf417/decoder/DecodedBitStreamParser.ts on lines 316..320
        src/core/pdf417/decoder/DecodedBitStreamParser.ts on lines 321..325

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

        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

                    case DecodedBitStreamParser.MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP:
                      let timestamp: StringBuilder = new StringBuilder();
                      codeIndex = DecodedBitStreamParser.numericCompaction(codewords, codeIndex + 1, timestamp);
                      resultMetadata.setTimestamp(Long.parseLong(timestamp.toString()));
                      break;
        Severity: Major
        Found in src/core/pdf417/decoder/DecodedBitStreamParser.ts and 3 other locations - About 1 hr to fix
        src/core/pdf417/decoder/DecodedBitStreamParser.ts on lines 306..310
        src/core/pdf417/decoder/DecodedBitStreamParser.ts on lines 316..320
        src/core/pdf417/decoder/DecodedBitStreamParser.ts on lines 321..325

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

        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

                    case DecodedBitStreamParser.MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE:
                      let fileSize: StringBuilder = new StringBuilder();
                      codeIndex = DecodedBitStreamParser.numericCompaction(codewords, codeIndex + 1, fileSize);
                      resultMetadata.setFileSize(Long.parseLong(fileSize.toString()));
                      break;
        Severity: Major
        Found in src/core/pdf417/decoder/DecodedBitStreamParser.ts and 3 other locations - About 1 hr to fix
        src/core/pdf417/decoder/DecodedBitStreamParser.ts on lines 306..310
        src/core/pdf417/decoder/DecodedBitStreamParser.ts on lines 311..315
        src/core/pdf417/decoder/DecodedBitStreamParser.ts on lines 316..320

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

        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

                  case 1:
                    if (upperShift) {
                      result.append(String.fromCharCode(cValue + 128));
                      upperShift = false;
                    } else {
        Severity: Major
        Found in src/core/datamatrix/decoder/DecodedBitStreamParser.ts and 1 other location - About 1 hr to fix
        src/core/datamatrix/decoder/DecodedBitStreamParser.ts on lines 323..331

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

        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

                  case 1:
                    if (upperShift) {
                      result.append(String.fromCharCode(cValue + 128));
                      upperShift = false;
                    } else {
        Severity: Major
        Found in src/core/datamatrix/decoder/DecodedBitStreamParser.ts and 1 other location - About 1 hr to fix
        src/core/datamatrix/decoder/DecodedBitStreamParser.ts on lines 234..242

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

        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 getDataBlocks has 46 lines of code (exceeds 25 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 1 hr to fix

          Function checkAndNudgePoints has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected static checkAndNudgePoints(
                  image: BitMatrix,
                  points: Float32Array
              ): void /*throws NotFoundException*/ {
          
          
          Severity: Minor
          Found in src/core/common/GridSampler.ts - About 1 hr to fix

            Function decodeRow has 45 lines of code (exceeds 25 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 1 hr to fix

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

                  public static squareToQuadrilateral(
                      x0: number/*float*/, y0: number/*float*/,
                      x1: number/*float*/, y1: number/*float*/,
                      x2: number/*float*/, y2: number/*float*/,
                      x3: number/*float*/, y3: number/*float*/
              Severity: Major
              Found in src/core/common/PerspectiveTransform.ts and 1 other location - About 1 hr to fix
              src/core/common/PerspectiveTransform.ts on lines 130..138

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

              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

              Severity
              Category
              Status
              Source
              Language