zxing-js/library

View on GitHub

Showing 958 of 958 total issues

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

  public constructor(hints?: Map<DecodeHintType, any>) {
    super();
    let possibleFormats = hints == null ? null : <BarcodeFormat[]>hints.get(DecodeHintType.POSSIBLE_FORMATS);
    let readers: Collection<UPCEANReader> = [];
    if (possibleFormats != null) {
Severity: Minor
Found in src/core/oned/MultiFormatUPCEANReader.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 stuffBits has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  static stuffBits(bits: BitArray, wordSize: int): BitArray {
    let out: BitArray = new BitArray();

    let n: int = bits.getSize();
    let mask: int = (1 << wordSize) - 2;
Severity: Minor
Found in src/core/aztec/encoder/Encoder.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 decodeRow has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public decodeRow(rowNumber: number, row: BitArray, hints?: Map<DecodeHintType, any>): Result {
        const leftPair = this.decodePair(row, false, rowNumber, hints);
        RSS14Reader.addOrTally(this.possibleLeftPairs, leftPair);
        row.reverse();
        let rightPair = this.decodePair(row, true, rowNumber, hints);
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 toPattern has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  private toPattern(counters: Int32Array): number {
    let sum = 0;
    for (const counter of counters) {
      sum += counter;
    }
Severity: Minor
Found in src/core/oned/Code93Reader.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 simplifyStates has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  private static simplifyStates(states: State[]): Collection<State> {
    let result: Collection<State> = [];
    for (const newState of states) {
      let add: boolean = true;
      for (const oldState of result) {
Severity: Minor
Found in src/core/aztec/encoder/HighLevelEncoder.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

            if (cValue < this.TEXT_SHIFT2_SET_CHARS.length) {
              const textChar = this.TEXT_SHIFT2_SET_CHARS[cValue];
              if (upperShift) {
                result.append(String.fromCharCode(textChar.charCodeAt(0) + 128));
                upperShift = false;
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 244..263

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

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

            if (cValue < this.C40_SHIFT2_SET_CHARS.length) {
              const c40char = this.C40_SHIFT2_SET_CHARS[cValue];
              if (upperShift) {
                result.append(String.fromCharCode(c40char.charCodeAt(0) + 128));
                upperShift = false;
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 334..353

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

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 set(i: number /*int*/): void {
    this.bits[Math.floor(i / 32)] |= 1 << (i & 0x1F);
  }
Severity: Major
Found in src/core/common/BitArray.ts and 1 other location - About 1 hr to fix
src/core/common/BitArray.ts on lines 104..106

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

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 i = evenCounts.length - 1; i >= 0; i--) {
            evenChecksumPortion *= 9;
            evenChecksumPortion += evenCounts[i];
            evenSum += evenCounts[i];
        }
Severity: Major
Found in src/core/oned/rss/RSS14Reader.ts and 1 other location - About 1 hr to fix
src/core/oned/rss/RSS14Reader.ts on lines 198..202

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

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 i = oddCounts.length - 1; i >= 0; i--) {
            oddChecksumPortion *= 9;
            oddChecksumPortion += oddCounts[i];
            oddSum += oddCounts[i];
        }
Severity: Major
Found in src/core/oned/rss/RSS14Reader.ts and 1 other location - About 1 hr to fix
src/core/oned/rss/RSS14Reader.ts on lines 205..209

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

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 flip(i: number /*int*/): void {
    this.bits[Math.floor(i / 32)] ^= 1 << (i & 0x1F);
  }
Severity: Major
Found in src/core/common/BitArray.ts and 1 other location - About 1 hr to fix
src/core/common/BitArray.ts on lines 95..97

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

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

  private detectSolid1(cornerPoints: ResultPoint[]): ResultPoint[] {
    // 0  2
    // 1  3
    let pointA = cornerPoints[0];
    let pointB = cornerPoints[1];
Severity: Minor
Found in src/core/datamatrix/detector/Detector.ts - About 1 hr to fix

    Function detect has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      public detect(): DetectorResult {
    
    
        const cornerPoints = this.rectangleDetector.detect();
    
    
    Severity: Minor
    Found in src/core/datamatrix/detector/Detector.ts - About 1 hr to fix

      Function getNumDataBytesAndNumECBytesForBlockID has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static getNumDataBytesAndNumECBytesForBlockID(numTotalBytes: number /*int*/,
              numDataBytes: number /*int*/,
              numRSBlocks: number /*int*/,
              blockID: number /*int*/,
              numDataBytesInBlock: Int32Array,
      Severity: Minor
      Found in src/core/qrcode/encoder/Encoder.ts - About 1 hr to fix

        Function getStartColumn has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          private static getStartColumn(detectionResult: DetectionResult,
            barcodeColumn: int,
            imageRow: int,
            leftToRight: boolean): int {
            let offset: int = leftToRight ? 1 : -1;
        Severity: Minor
        Found in src/core/pdf417/decoder/PDF417ScanningDecoder.ts - About 1 hr to fix

          Function addMissingRows has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            addMissingRows(missingStartRows: int, missingEndRows: int, isLeft: boolean): BoundingBox {
              let newTopLeft: ResultPoint = this.topLeft;
              let newBottomLeft: ResultPoint = this.bottomLeft;
              let newTopRight: ResultPoint = this.topRight;
              let newBottomRight: ResultPoint = this.bottomRight;
          Severity: Minor
          Found in src/core/pdf417/decoder/BoundingBox.ts - About 1 hr to fix

            Function extractParameters has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private extractParameters(bullsEyeCorners: ResultPoint[]): void {
                    if (!this.isValidPoint(bullsEyeCorners[0]) || !this.isValidPoint(bullsEyeCorners[1]) ||
                        !this.isValidPoint(bullsEyeCorners[2]) || !this.isValidPoint(bullsEyeCorners[3])) {
                        throw new NotFoundException();
                    }
            Severity: Minor
            Found in src/core/aztec/detector/Detector.ts - About 1 hr to fix

              Function extractDataRegion has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                private extractDataRegion(bitMatrix: BitMatrix): BitMatrix {
                  const symbolSizeRows = this.version.getSymbolSizeRows();
                  const symbolSizeColumns = this.version.getSymbolSizeColumns();
              
                  if (bitMatrix.getHeight() !== symbolSizeRows) {
              Severity: Minor
              Found in src/core/datamatrix/decoder/BitMatrixParser.ts - About 1 hr to fix

                Function applyMaskPenaltyRule3 has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static applyMaskPenaltyRule3(matrix: ByteMatrix): number /*int*/ {
                        let numPenalties = 0;
                        const array: Array<Uint8Array> = matrix.getArray();
                        const width: number /*int*/ = matrix.getWidth();
                        const height: number /*int*/ = matrix.getHeight();
                Severity: Minor
                Found in src/core/qrcode/encoder/MaskUtil.ts - About 1 hr to fix

                  Function numericCompaction has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    private static numericCompaction(codewords: Int32Array, codeIndex: number /*int*/, result: StringBuilder): int {
                      let count: int = 0;
                      let end: boolean = false;
                  
                      let numericCodewords: Int32Array = new Int32Array(DecodedBitStreamParser.MAX_NUMERIC_CODEWORDS);
                  Severity: Minor
                  Found in src/core/pdf417/decoder/DecodedBitStreamParser.ts - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language