zxing-js/library

View on GitHub

Showing 605 of 958 total issues

Function getMinSymbolSize has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  getMinSymbolSize(minimum: number): number {
    switch (this.input.getShapeHint()) {
      case SymbolShapeHint.FORCE_SQUARE:
        for (const capacity of this.squareCodewordCapacities) {
          if (capacity >= minimum) {
Severity: Minor
Found in src/core/datamatrix/encoder/MinimalEncoder.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 findGuardPattern has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  private static findGuardPattern( matrix: BitMatrix,
                                         column: /*int*/ number,
                                         row: /*int*/ number,
                                         width: /*int*/ number,
                                         whiteFirst: boolean,
Severity: Minor
Found in src/core/pdf417/detector/Detector.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 encode has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public encode(context: EncoderContext) {
    const buffer = new StringBuilder();
    buffer.append(0o0); // Initialize length field
    while (context.hasMoreCharacters()) {
      const c = context.getCurrentChar();
Severity: Minor
Found in src/core/datamatrix/encoder/Base256Encoder.ts - About 1 hr to fix

    Function getLatchBytes has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      getLatchBytes(): Uint8Array {
        switch (this.getPreviousMode()) {
          case Mode.ASCII:
          case Mode.B256: // after B256 ends (via length) we are back to ASCII
            switch (this.mode) {
    Severity: Minor
    Found in src/core/datamatrix/encoder/MinimalEncoder.ts - About 1 hr to fix

      Function getEnclosingRectangle has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public getEnclosingRectangle(): Int32Array {
              const width = this.width;
              const height = this.height;
              const rowSize = this.rowSize;
              const bits = this.bits;
      Severity: Minor
      Found in src/core/common/BitMatrix.ts - About 1 hr to fix

        Function constructor has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          public constructor(hints?: Map<DecodeHintType, any>) {
            super();
            const possibleFormats = !hints ? null : <BarcodeFormat[]>hints.get(DecodeHintType.POSSIBLE_FORMATS);
            const useCode39CheckDigit = hints && hints.get(DecodeHintType.ASSUME_CODE_39_CHECK_DIGIT) !== undefined;
            const useCode39ExtendedMode = hints && hints.get(DecodeHintType.ENABLE_CODE_39_EXTENDED_MODE) !== undefined;
        Severity: Minor
        Found in src/core/oned/MultiFormatOneDReader.ts - About 1 hr to fix

          Function estimateBlackPoint has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private static estimateBlackPoint(buckets: Int32Array): number /*int*/ /*throws NotFoundException*/ {
                  // Find the tallest peak in the histogram.
                  const numBuckets = buckets.length;
                  let maxBucketCount = 0;
                  let firstPeak = 0;
          Severity: Minor
          Found in src/core/common/GlobalHistogramBinarizer.ts - About 1 hr to fix

            Function encodeChar has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              encodeChar(c: char, sb: StringBuilder): number {
                if (c === ' '.charCodeAt(0)) {
                  sb.append(0o3);
                  return 1;
                }
            Severity: Minor
            Found in src/core/datamatrix/encoder/C40Encoder.ts - About 1 hr to fix

              Function toGrayscaleBuffer has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private static toGrayscaleBuffer(imageBuffer: Uint8ClampedArray, width: number, height: number): Uint8ClampedArray {
                      const grayscaleBuffer = new Uint8ClampedArray(width * height);
                      HTMLCanvasElementLuminanceSource.FRAME_INDEX = !HTMLCanvasElementLuminanceSource.FRAME_INDEX;
                      if(HTMLCanvasElementLuminanceSource.FRAME_INDEX)
                      {
              Severity: Minor
              Found in src/browser/HTMLCanvasElementLuminanceSource.ts - About 1 hr to fix

                Function getDataBlocks has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  static getDataBlocks(rawCodewords: Int8Array,
                                                   version: Version): DataBlock[]  {
                    // Figure out the number and size of data blocks used by this version
                    const ecBlocks = version.getECBlocks();
                
                
                Severity: Minor
                Found in src/core/datamatrix/decoder/DataBlock.ts - About 1 hr to fix

                  Function crossCheckVertical has 41 lines of code (exceeds 25 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

                    Function encodeLowLevel has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      private encodeLowLevel(
                        placement: DefaultPlacement,
                        symbolInfo: SymbolInfo,
                        width: number,
                        height: number
                    Severity: Minor
                    Found in src/core/datamatrix/DataMatrixWriter.ts - About 1 hr to fix

                      Function runEuclideanAlgorithm has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private runEuclideanAlgorithm(a: GenericGFPoly, b: GenericGFPoly, R: number /*int*/): GenericGFPoly[] {
                              // Assume a's degree is >= b's
                              if (a.getDegree() < b.getDegree()) {
                                  const temp = a;
                                  a = b;
                      Severity: Minor
                      Found in src/core/common/reedsolomon/ReedSolomonDecoder.ts - About 1 hr to fix

                        Function getBarcodeMetadata has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          getBarcodeMetadata(): BarcodeMetadata {
                            let codewords: Codeword[] = this.getCodewords();
                            let barcodeColumnCount: BarcodeValue = new BarcodeValue();
                            let barcodeRowCountUpperPart: BarcodeValue = new BarcodeValue();
                            let barcodeRowCountLowerPart: BarcodeValue = new BarcodeValue();
                        Severity: Minor
                        Found in src/core/pdf417/decoder/DetectionResultRowIndicatorColumn.ts - About 1 hr to fix

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

                              public decode(image: BinaryBitmap, hints: Map<DecodeHintType, any> | null = null): Result {
                          
                                  let exception: Exception = null;
                                  let detector = new Detector(image.getBlackMatrix());
                                  let points: ResultPoint[] = null;
                          Severity: Minor
                          Found in src/core/aztec/AztecReader.ts - About 1 hr to fix

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

                              public decodeRow(rowNumber: number, row: BitArray, hints?: Map<DecodeHintType, any>): Result {
                            
                                // Find out where the Middle section (payload) starts & ends
                                let startRange: number[] = this.decodeStart(row);
                                let endRange: number[] = this.decodeEnd(row);
                            Severity: Minor
                            Found in src/core/oned/ITFReader.ts - About 1 hr to fix

                              Function encodeChar has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                              Open

                                encodeChar(c: char, sb: StringBuilder): number {
                                  if (c === ' '.charCodeAt(0)) {
                                    sb.append(0o3);
                                    return 1;
                                  }
                              Severity: Minor
                              Found in src/core/datamatrix/encoder/TextEncoder.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 encodeECC200 has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                              Open

                                public static encodeECC200(codewords: string, symbolInfo: SymbolInfo) {
                                  if (codewords.length !== symbolInfo.getDataCapacity()) {
                                    throw new Error(
                                      'The number of codewords does not match the selected symbol'
                                    );
                              Severity: Minor
                              Found in src/core/datamatrix/encoder/ErrorCorrection.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 encode has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  public static encode(content: string,
                                      ecLevel: ErrorCorrectionLevel,
                                      hints: Map<EncodeHintType, any> = null): QRCode /*throws WriterException*/ {
                              
                                      // Determine what character encoding has been specified by the caller, if any
                              Severity: Minor
                              Found in src/core/qrcode/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 numericCompaction has a Cognitive Complexity of 13 (exceeds 5 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

                              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