zxing-js/library

View on GitHub

Showing 958 of 958 total issues

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

      if (iso.isFNC1()) {
        let information = new DecodedInformation(this.current.getPosition(), this.buffer.toString());
        return new BlockParsedResult(true, information);
      }
Severity: Major
Found in src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.ts and 1 other location - About 1 hr to fix
src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.ts on lines 152..155

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

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

                    rawbits[rowOffset + 4 * rowSize + columnOffset + k] =
                        matrix.get(alignmentMap[high - k], alignmentMap[high - j]);
Severity: Major
Found in src/core/aztec/decoder/Decoder.ts and 1 other location - About 1 hr to fix
src/core/aztec/decoder/Decoder.ts on lines 315..316

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

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 (row === this.numrows - 2 && col === 0 && this.numcols % 8 === 4) {
        this.corner3(pos++);
      }
Severity: Major
Found in src/core/datamatrix/encoder/DefaultPlacement.ts and 1 other location - About 1 hr to fix
src/core/datamatrix/encoder/DefaultPlacement.ts on lines 59..61

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

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

                    rawbits[rowOffset + 2 * rowSize + columnOffset + k] =
                        matrix.get(alignmentMap[low + j], alignmentMap[high - k]);
Severity: Major
Found in src/core/aztec/decoder/Decoder.ts and 1 other location - About 1 hr to fix
src/core/aztec/decoder/Decoder.ts on lines 318..319

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

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

        : c >= 91 && c <= 95
        ? c - 69
        : c === 96
        ? 0
        : c >= 97 && c <= 122
Severity: Major
Found in src/core/datamatrix/encoder/MinimalEncoder.ts and 1 other location - About 1 hr to fix
src/core/datamatrix/encoder/MinimalEncoder.ts on lines 948..956

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

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

      : c === 62
      ? 2
      : c === 32
      ? 3
      : c >= 48 && c <= 57
Severity: Major
Found in src/core/datamatrix/encoder/MinimalEncoder.ts and 1 other location - About 1 hr to fix
src/core/datamatrix/encoder/MinimalEncoder.ts on lines 1030..1038

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

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

  for (let c: int = zeroCharCode; c <= nineCharCode; c++) {
    CHAR_MAP[C.MODE_DIGIT][c] = c - zeroCharCode + 2;
  }
Severity: Major
Found in src/core/aztec/encoder/CharMap.ts and 2 other locations - About 1 hr to fix
src/core/aztec/encoder/CharMap.ts on lines 15..17
src/core/aztec/encoder/CharMap.ts on lines 21..23

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

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

  private static decodeBase256Segment(bits: BitSource,
                                           result: StringBuilder,
                                           byteSegments: Uint8Array[]): void {
    // Figure out how long the Base 256 Segment is.
    let codewordPosition = 1 + bits.getByteOffset(); // position is 1-indexed
Severity: Minor
Found in src/core/datamatrix/decoder/DecodedBitStreamParser.ts - About 1 hr to fix

    Function renderResult has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private renderResult(code: QRCode, width: number /*int*/, height: number /*int*/, quietZone: number /*int*/): SVGSVGElement {
    
            // if (this.format && format != this.format) {
            //   throw new IllegalArgumentException("Can only encode QR_CODE, but got " + format)
            // }
    Severity: Minor
    Found in src/browser/BrowserSvgCodeWriter.ts - About 1 hr to fix

      Function detectCodeword has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        private static detectCodeword(image: BitMatrix,
          minColumn: int,
          maxColumn: int,
          leftToRight: boolean,
          startColumn: int,
      Severity: Minor
      Found in src/core/pdf417/decoder/PDF417ScanningDecoder.ts - About 1 hr to fix

        Function decodeRow has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          public decodeRow(rowNumber: number, row: BitArray, hints?: Map<DecodeHintType, any>): Result {
            for (let reader of this.readers) {
              try {
                // const result: Result = reader.decodeRow(rowNumber, row, startGuardPattern, hints);
                const result = reader.decodeRow(rowNumber, row, hints);
        Severity: Minor
        Found in src/core/oned/MultiFormatUPCEANReader.ts - About 1 hr to fix

          Function recordPattern has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected static recordPattern(row: BitArray, start: number, counters: Int32Array): void {
                  const numCounters = counters.length;
                  for (let index = 0; index < numCounters; index++)
                      counters[index] = 0;
          
          
          Severity: Minor
          Found in src/core/oned/OneDReader.ts - About 1 hr to fix

            Function getCorrectedParameterData has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private getCorrectedParameterData(parameterData: number, compact: boolean): number {
                    let numCodewords;
                    let numDataCodewords;
            
                    if (compact) {
            Severity: Minor
            Found in src/core/aztec/detector/Detector.ts - About 1 hr to fix

              Consider simplifying this complex logical expression.
              Open

                  if ((barcodeColumnCount.getValue().length === 0) ||
                      (barcodeRowCountUpperPart.getValue().length === 0) ||
                      (barcodeRowCountLowerPart.getValue().length === 0) ||
                      (barcodeECLevel.getValue().length === 0) ||
                      barcodeColumnCount.getValue()[0] < 1 ||
              Severity: Major
              Found in src/core/pdf417/decoder/DetectionResultRowIndicatorColumn.ts - About 1 hr to fix

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

                        if (
                          intCharCounts[X12_ENCODATION] + 1 <
                          this.min(
                            intCharCounts[BASE256_ENCODATION],
                            intCharCounts[C40_ENCODATION],
                Severity: Major
                Found in src/core/datamatrix/encoder/HighLevelEncoder.ts and 2 other locations - About 55 mins to fix
                src/core/datamatrix/encoder/HighLevelEncoder.ts on lines 300..311
                src/core/datamatrix/encoder/HighLevelEncoder.ts on lines 312..323

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

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

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

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

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

                Refactorings

                Further Reading

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

                      const hasForceC40Hint =
                        hints != null &&
                        hints.has(EncodeHintType.FORCE_C40) &&
                        Boolean(hints.get(EncodeHintType.FORCE_C40).toString());
                Severity: Minor
                Found in src/core/datamatrix/DataMatrixWriter.ts and 1 other location - About 55 mins to fix
                src/core/datamatrix/DataMatrixWriter.ts on lines 65..68

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

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

                        if (
                          intCharCounts[EDIFACT_ENCODATION] + 1 <
                          this.min(
                            intCharCounts[BASE256_ENCODATION],
                            intCharCounts[C40_ENCODATION],
                Severity: Major
                Found in src/core/datamatrix/encoder/HighLevelEncoder.ts and 2 other locations - About 55 mins to fix
                src/core/datamatrix/encoder/HighLevelEncoder.ts on lines 312..323
                src/core/datamatrix/encoder/HighLevelEncoder.ts on lines 324..335

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

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

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

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

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

                Refactorings

                Further Reading

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

                    const hasCompactionHint =
                      hints != null &&
                      hints.has(EncodeHintType.DATA_MATRIX_COMPACT) &&
                      Boolean(hints.get(EncodeHintType.DATA_MATRIX_COMPACT).toString());
                Severity: Minor
                Found in src/core/datamatrix/DataMatrixWriter.ts and 1 other location - About 55 mins to fix
                src/core/datamatrix/DataMatrixWriter.ts on lines 88..91

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

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

                        if (
                          intCharCounts[TEXT_ENCODATION] + 1 <
                          this.min(
                            intCharCounts[BASE256_ENCODATION],
                            intCharCounts[C40_ENCODATION],
                Severity: Major
                Found in src/core/datamatrix/encoder/HighLevelEncoder.ts and 2 other locations - About 55 mins to fix
                src/core/datamatrix/encoder/HighLevelEncoder.ts on lines 300..311
                src/core/datamatrix/encoder/HighLevelEncoder.ts on lines 324..335

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

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

                  public encode(context: EncoderContext) {
                    // step B
                    const n = HighLevelEncoder.determineConsecutiveDigitCount(
                      context.getMessage(),
                      context.pos
                Severity: Minor
                Found in src/core/datamatrix/encoder/ASCIIEncoder.ts - About 55 mins 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