zxing-js/library

View on GitHub

Showing 605 of 958 total issues

Function guessEncoding has 117 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public static guessEncoding(bytes: Uint8Array, hints: Map<DecodeHintType, any>): string {
    if (hints !== null && hints !== undefined && undefined !== hints.get(DecodeHintType.CHARACTER_SET)) {
      return hints.get(DecodeHintType.CHARACTER_SET).toString();
    }
    // For now, merely tries to distinguish ISO-8859-1, UTF-8 and Shift_JIS,
Severity: Major
Found in src/core/common/StringUtils.ts - About 4 hrs to fix

    Function doDecode has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

        private doDecode(image: BinaryBitmap, hints?: Map<DecodeHintType, any>): Result {
            const width = image.getWidth();
            const height = image.getHeight();
            let row = new BitArray(width);
    
    
    Severity: Minor
    Found in src/core/oned/OneDReader.ts - About 4 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

    File Detector.ts has 357 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/detector/Detector.ts - About 4 hrs to fix

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

          public detect(): Array<ResultPoint> /*throws NotFoundException*/ {
              let left = this.leftInit;
              let right = this.rightInit;
              let up = this.upInit;
              let down = this.downInit;
      Severity: Major
      Found in src/core/common/detector/WhiteRectangleDetector.ts - About 4 hrs to fix

        Function constructor has a Cognitive Complexity of 30 (exceeds 5 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 4 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 drawModeMessage has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
        Open

          private static drawModeMessage(matrix: BitMatrix, compact: boolean, matrixSize: int, modeMessage: BitArray): void {
            let center: int = Integer.truncDivision(matrixSize, 2);
            if (compact) {
              for (let i /*int*/ = 0; i < 7; i++) {
                let offset: int = center - 3 + i;
        Severity: Minor
        Found in src/core/aztec/encoder/Encoder.ts - About 4 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 encode has 107 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          public static encode(data: Uint8Array, minECCPercent: int, userSpecifiedLayers: int): AztecCode {
            // High-level encode
            let bits: BitArray = new HighLevelEncoder(data).encode();
        
            // stuff bits and choose symbol size
        Severity: Major
        Found in src/core/aztec/encoder/Encoder.ts - About 4 hrs to fix

          Function toString has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
          Open

              public toString(): string {
                  let result = '';
                  for (let degree = this.getDegree(); degree >= 0; degree--) {
                      let coefficient = this.getCoefficient(degree);
                      if (coefficient !== 0) {
          Severity: Minor
          Found in src/core/common/reedsolomon/AbstractGenericGFPoly.ts - About 4 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 toString has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
          Open

              public toString(): string {
                  let result = '';
                  for (let degree = this.getDegree(); degree >= 0; degree--) {
                      let coefficient = this.getCoefficient(degree);
                      if (coefficient !== 0) {
          Severity: Minor
          Found in src/core/common/reedsolomon/GenericGFPoly.ts - About 4 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 decodeDataCharacter has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
          Open

            decodeDataCharacter(
              row: BitArray,
              pattern: FinderPattern,
              isOddPattern: boolean,
              leftChar: boolean
          Severity: Minor
          Found in src/core/oned/rss/expanded/RSSExpandedReader.ts - About 4 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 encodeMinimally has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

            encodeMinimally(
              stringToEncode: string,
              encoderSet: ECIEncoderSet,
              fnc1: number
            ): number[] {
          Severity: Minor
          Found in src/core/common/MinimalECIInput.ts - About 4 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 parseFieldsInGeneralPurpose has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

            static parseFieldsInGeneralPurpose(rawInformation: string): string {
              if (!rawInformation) {
                return null;
              }
          
          
          Severity: Minor
          Found in src/core/oned/rss/expanded/decoders/FieldParser.ts - About 4 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 adjustOddEvenCounts has 102 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private adjustOddEvenCounts(outsideChar: boolean, numModules: number) {
          
                  let oddSum = MathUtils.sum(new Int32Array(this.getOddCounts()));
                  let evenSum = MathUtils.sum(new Int32Array(this.getEvenCounts()));
          
          
          Severity: Major
          Found in src/core/oned/rss/RSS14Reader.ts - About 4 hrs to fix

            Function findNextPair has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
            Open

              private findNextPair(
                row: BitArray,
                previousPairs: Array<ExpandedPair>,
                forcedOffset: number
              ): void {
            Severity: Minor
            Found in src/core/oned/rss/expanded/RSSExpandedReader.ts - About 3 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 static_CHAR_MAP has 95 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function static_CHAR_MAP(CHAR_MAP: Int32Array[]): Int32Array[] {
              const spaceCharCode = StringUtils.getCharCode(' ');
              const pointCharCode = StringUtils.getCharCode('.');
              const commaCharCode = StringUtils.getCharCode(',');
            
            
            Severity: Major
            Found in src/core/aztec/encoder/CharMap.ts - About 3 hrs to fix

              Function readCodewords has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
              Open

                  public readCodewords(): Uint8Array /*throws FormatException*/ {
              
                      const formatInfo = this.readFormatInformation();
                      const version = this.readVersion();
              
              
              Severity: Minor
              Found in src/core/qrcode/decoder/BitMatrixParser.ts - About 3 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 form has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
              Open

                private static form(str: string, arr: any[]) {
              
                  let i = -1;
              
                  function callback(exp: string | number, p0: any, p1: any, p2: any, p3: any, p4: any) {
              Severity: Minor
              Found in src/core/util/Formatter.ts - About 3 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 format has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
              Open

                public static format(append: string, ...args: any[]) {
              
                  let i = -1;
              
                  function callback(exp: string | number, p0: any, p1: any, p2: any, p3: any, p4: any) {
              Severity: Minor
              Found in src/core/common/StringUtils.ts - About 3 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 adjustOddEvenCounts has 93 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                private adjustOddEvenCounts(numModules) {
                  let oddSum = MathUtils.sum(new Int32Array(this.getOddCounts()));
                  let evenSum = MathUtils.sum(new Int32Array(this.getEvenCounts()));
              
                  let incrementOdd = false;
              Severity: Major
              Found in src/core/oned/rss/expanded/RSSExpandedReader.ts - About 3 hrs to fix

                Function toNarrowWidePattern has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                Open

                  private static toNarrowWidePattern(counters: Int32Array): number {
                    let numCounters = counters.length;
                    let maxNarrowCounter = 0;
                    let wideCounters: number;
                    do {
                Severity: Minor
                Found in src/core/oned/Code39Reader.ts - About 3 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