zxing-js/library

View on GitHub

Showing 605 of 958 total issues

Function encode has a Cognitive Complexity of 16 (exceeds 5 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 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 interleaveWithECBytes has a Cognitive Complexity of 16 (exceeds 5 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 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 a Cognitive Complexity of 16 (exceeds 5 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: Minor
Found in src/core/oned/Code39Reader.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 addMissingRows has a Cognitive Complexity of 16 (exceeds 5 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 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 getBlackRow has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public getBlackRow(y: number /*int*/, row: BitArray): BitArray /*throws NotFoundException*/ {
        const source = this.getLuminanceSource();
        const width = source.getWidth();
        if (row === undefined || row === null || row.getSize() < width) {
            row = new BitArray(width);
Severity: Minor
Found in src/core/common/GlobalHistogramBinarizer.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 getRSSvalue has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  public static getRSSvalue(widths: number[], maxWidth: number, noNarrow: boolean): number {
    let n = 0;
    for (let width of widths) {
      n += width;
    }
Severity: Minor
Found in src/core/oned/rss/RSSUtils.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 decode has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public decode(image: BinaryBitmap, hints?: Map<DecodeHintType, any>): Result {
        try {
            return this.doDecode(image, hints);
        } catch (nfe) {
            const tryHarder = hints && (hints.get(DecodeHintType.TRY_HARDER) === true);
Severity: Minor
Found in src/core/oned/OneDReader.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 updateStateForChar has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  private updateStateForChar(
    state: State,
    index: int,
    result: Collection<State>
  ): void {
Severity: Minor
Found in src/core/aztec/encoder/HighLevelEncoder.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 encodeChar has 51 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: Major
Found in src/core/datamatrix/encoder/TextEncoder.ts - About 2 hrs to fix

    Function getC40Value has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      getC40Value(c40: boolean, setIndex: number, c: number, fnc1: number): number {
        if (c === fnc1) {
          if (!(setIndex === 2)) {
            throw new Error('FNC1 cannot be used in C40 shift 2');
          }
    Severity: Major
    Found in src/core/datamatrix/encoder/MinimalEncoder.ts - About 2 hrs to fix

      Function calculateBlackPoints has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private static calculateBlackPoints(luminances: Uint8ClampedArray,
              subWidth: number /*int*/,
              subHeight: number /*int*/,
              width: number /*int*/,
              height: number /*int*/): Int32Array[] {
      Severity: Major
      Found in src/core/common/HybridBinarizer.ts - About 2 hrs to fix

        Consider simplifying this complex logical expression.
        Open

            if (c40) {
              return c <= 31
                ? c
                : c === 32
                ? 3
        Severity: Critical
        Found in src/core/datamatrix/encoder/MinimalEncoder.ts - About 2 hrs to fix

          Consider simplifying this complex logical expression.
          Open

                          if (y + 6 < height &&
                              array[y][x] === 1 &&
                              array[y + 1][x] === 0 &&
                              array[y + 2][x] === 1 &&
                              array[y + 3][x] === 1 &&
          Severity: Critical
          Found in src/core/qrcode/encoder/MaskUtil.ts - About 2 hrs to fix

            Function encode has 50 lines of code (exceeds 25 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 2 hrs to fix

              Consider simplifying this complex logical expression.
              Open

                              if (x + 6 < width &&
                                  arrayY[x] === 1 &&
                                  arrayY[x + 1] === 0 &&
                                  arrayY[x + 2] === 1 &&
                                  arrayY[x + 3] === 1 &&
              Severity: Critical
              Found in src/core/qrcode/encoder/MaskUtil.ts - About 2 hrs to fix

                Function parseFromString has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static parseFromString(stringRepresentation: string, setString: string, unsetString: string): BitMatrix {
                        if (stringRepresentation === null) {
                            throw new IllegalArgumentException('stringRepresentation cannot be null');
                        }
                
                
                Severity: Minor
                Found in src/core/common/BitMatrix.ts - About 2 hrs to fix

                  Function setHints has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public setHints(hints?: Map<DecodeHintType, any> | null): void {
                          this.hints = hints;
                  
                          const tryHarder: boolean = hints !== null && hints !== undefined && undefined !== hints.get(DecodeHintType.TRY_HARDER);
                          /*@SuppressWarnings("unchecked")*/
                  Severity: Minor
                  Found in src/core/MultiFormatReader.ts - About 2 hrs to fix

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

                      constructor(stringToEncode: string, priorityCharset: Charset, fnc1: number) {
                        const neededEncoders: CharsetEncoder[] = [];
                    
                        // we always need the ISO-8859-1 encoder. It is the default encoding
                        neededEncoders.push(new CharsetEncoder(StandardCharsets.ISO_8859_1));
                    Severity: Minor
                    Found in src/core/common/ECIEncoderSet.ts - About 1 hr to fix

                      Function getEncodedData has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private static getEncodedData(correctedBits: boolean[]): string {
                              let endIndex: number = correctedBits.length;
                              let latchTable = Table.UPPER; // table most recently latched to
                              let shiftTable = Table.UPPER; // table to use for the next read
                              let result: string = '';
                      Severity: Minor
                      Found in src/core/aztec/decoder/Decoder.ts - About 1 hr to fix

                        Function extractPureBits has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          private static extractPureBits(image: BitMatrix): BitMatrix /*throws NotFoundException */ {
                        
                            const leftTopBlack: Int32Array = image.getTopLeftOnBit();
                            const rightBottomBlack: Int32Array = image.getBottomRightOnBit();
                            if (leftTopBlack === null || rightBottomBlack === null) {
                        Severity: Minor
                        Found in src/core/qrcode/QRCodeReader.ts - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language