zxing-js/library

View on GitHub

Showing 958 of 958 total issues

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

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

        const maxI = image.getHeight();
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 removeIncorrectCodewords has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  private removeIncorrectCodewords(codewords: Codeword[], barcodeMetadata: BarcodeMetadata): void {
    // Remove codewords which do not match the metadata
    // TODO Maybe we should keep the incorrect codewords for the start and end positions?
    for (let codewordRow /*int*/ = 0; codewordRow < codewords.length; codewordRow++) {
      let codeword: Codeword = codewords[codewordRow];
Severity: Minor
Found in src/core/pdf417/decoder/DetectionResultRowIndicatorColumn.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 decodeRow2pairs has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  decodeRow2pairs(rowNumber: number, row: BitArray): Array<ExpandedPair> {
    let done = false;
    while (!done) {
      try {
        this.pairs.push(this.retrieveNextPair(row, this.pairs, rowNumber));
Severity: Minor
Found in src/core/oned/rss/expanded/RSSExpandedReader.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 decodeRow has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public decodeRow(rowNumber: number, row: BitArray, hints?: Map<DecodeHintType, any>): Result {
    let theCounters = this.counters;
    theCounters.fill(0);
    this.decodeRowResult = '';

Severity: Major
Found in src/core/oned/Code39Reader.ts - About 2 hrs to fix

    Function decodeExtended has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      private static 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/Code39Reader.ts - About 2 hrs to fix

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

          public decodeRow(rowNumber: number, row: BitArray, hints?: Map<DecodeHintType, any>): Result {
              let startGuardRange = UPCEANReader.findStartGuardPattern(row);
              let resultPointCallback = hints == null ? null : hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
      
              if (resultPointCallback != null) {
      Severity: Major
      Found in src/core/oned/UPCEANReader.ts - About 2 hrs to fix

        Function decodeAsciiSegment has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          private static decodeAsciiSegment(bits: BitSource,
                                                 result: StringBuilder,
                                                 resultTrailer: StringBuilder): Mode {
            let upperShift = false;
            do {
        Severity: Major
        Found in src/core/datamatrix/decoder/DecodedBitStreamParser.ts - About 2 hrs to fix

          Function decode has 59 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            public static decode(image: BitMatrix,
              imageTopLeft: ResultPoint,
              imageBottomLeft: ResultPoint,
              imageTopRight: ResultPoint,
              imageBottomRight: ResultPoint,
          Severity: Major
          Found in src/core/pdf417/decoder/PDF417ScanningDecoder.ts - About 2 hrs to fix

            Function findNextPair has 59 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              private findNextPair(
                row: BitArray,
                previousPairs: Array<ExpandedPair>,
                forcedOffset: number
              ): void {
            Severity: Major
            Found in src/core/oned/rss/expanded/RSSExpandedReader.ts - About 2 hrs to fix

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

                        case '/':
                          // /A to /O map to ! to , and /Z maps to :
                          if (next >= 'A' && next <= 'O') {
                            decodedChar = String.fromCharCode(next.charCodeAt(0) - 32);
                          } else if (next === 'Z') {
              Severity: Major
              Found in src/core/oned/Code39Reader.ts and 1 other location - About 2 hrs to fix
              src/core/oned/Code93Reader.ts on lines 255..264

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

              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

                        case 'c':
                          // /A to /O map to ! to , and /Z maps to :
                          if (next >= 'A' && next <= 'O') {
                            decodedChar = String.fromCharCode(next.charCodeAt(0) - 32);
                          } else if (next === 'Z') {
              Severity: Major
              Found in src/core/oned/Code93Reader.ts and 1 other location - About 2 hrs to fix
              src/core/oned/Code39Reader.ts on lines 311..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 82.

              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

              File Decoder.ts has 264 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              /*
               * Copyright 2010 ZXing authors
               *
               * Licensed under the Apache License, Version 2.0 (the "License");
               * you may not use this file except in compliance with the License.
              Severity: Minor
              Found in src/core/aztec/decoder/Decoder.ts - About 2 hrs to fix

                PDF417ResultMetadata has 22 functions (exceeds 20 allowed). Consider refactoring.
                Open

                export default /*public final*/ class PDF417ResultMetadata {
                
                    private segmentIndex: /*int*/ number;
                    private fileId: string;
                    private lastSegment: boolean;
                Severity: Minor
                Found in src/core/pdf417/PDF417ResultMetadata.ts - About 2 hrs to fix

                  File Detector.ts has 262 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import BitMatrix from '../../common/BitMatrix';
                  import WhiteRectangleDetector from '../../common/detector/WhiteRectangleDetector';
                  import DetectorResult from '../../common/DetectorResult';
                  import GridSamplerInstance from '../../common/GridSamplerInstance';
                  import NotFoundException from '../../NotFoundException';
                  Severity: Minor
                  Found in src/core/datamatrix/detector/Detector.ts - About 2 hrs to fix

                    Function encodeMinimally has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      encodeMinimally(
                        stringToEncode: string,
                        encoderSet: ECIEncoderSet,
                        fnc1: number
                      ): number[] {
                    Severity: Major
                    Found in src/core/common/MinimalECIInput.ts - About 2 hrs to fix

                      Function handleEOD has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

                        handleEOD(context: EncoderContext, buffer: StringBuilder): void {
                          const unwritten = Math.floor((buffer.length() / 3) * 2);
                          const rest = buffer.length() % 3;
                      
                          const curCodewordCount = context.getCodewordCount() + unwritten;
                      Severity: Minor
                      Found in src/core/datamatrix/encoder/C40Encoder.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 lookup has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

                        public static lookup(
                          dataCodewords: number,
                          shape = SymbolShapeHint.FORCE_NONE,
                          minSize: Dimension = null,
                          maxSize: Dimension = null,
                      Severity: Minor
                      Found in src/core/datamatrix/encoder/SymbolInfo.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 getLastASCII has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

                        getLastASCII(): number {
                          const length = this.input.length();
                          const from = this.fromPosition + this.characterLength;
                          if (length - from > 4 || from >= length) {
                            return 0;
                      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 getC40Words has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

                        getC40Words(c40: boolean, fnc1: number): Uint8Array {
                          const c40Values = [];
                          for (let i = 0; i < this.characterLength; i++) {
                            const ci = this.input.charAt(this.fromPosition + i);
                            if (
                      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 transitionsBetween has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

                        private transitionsBetween(from: ResultPoint, to: ResultPoint): int {
                          // See QR Code Detector, sizeOfBlackWhiteBlackRun()
                          let fromX = Math.trunc(from.getX());
                          let fromY = Math.trunc(from.getY());
                          let toX = Math.trunc(to.getX());
                      Severity: Minor
                      Found in src/core/datamatrix/detector/Detector.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