zxing-js/library

View on GitHub

Showing 958 of 958 total issues

Function setHints has a Cognitive Complexity of 24 (exceeds 5 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 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 find has 84 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public find(hints: Map<DecodeHintType, any>): FinderPatternInfo /*throws NotFoundException */ {
        const tryHarder: boolean = (hints !== null && hints !== undefined) && undefined !== hints.get(DecodeHintType.TRY_HARDER);
        const pureBarcode: boolean = (hints !== null && hints !== undefined) && undefined !== hints.get(DecodeHintType.PURE_BARCODE);
        const image = this.image;
        const maxI = image.getHeight();
Severity: Major
Found in src/core/qrcode/detector/FinderPatternFinder.ts - About 3 hrs to fix

    Function decodeIsoIec646 has 84 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      private decodeIsoIec646(pos: number): DecodedChar {
        let fiveBitValue = this.extractNumericValueFromBitArray(pos, 5);
        if (fiveBitValue === 15) {
          return new DecodedChar(pos + 5, DecodedChar.FNC1);
        }
    Severity: Major
    Found in src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.ts - About 3 hrs to fix

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

        constructor(
          public readonly input: Input,
          public readonly mode: Mode,
          public readonly fromPosition: number,
          public readonly characterLength: number,
      Severity: Major
      Found in src/core/datamatrix/encoder/MinimalEncoder.ts - About 3 hrs to fix

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

            public detect(): ResultPoint[] {
        
                let left = this.leftInit;
                let right = this.rightInit;
                let up = this.upInit;
        Severity: Major
        Found in src/core/common/detector/CornerDetector.ts - About 3 hrs to fix

          File BitMatrixParser.ts has 303 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import BitMatrix from '../../common/BitMatrix';
          import Version from './Version';
          
          import FormatException from '../../FormatException';
          import IllegalArgumentException from '../../IllegalArgumentException';
          Severity: Minor
          Found in src/core/datamatrix/decoder/BitMatrixParser.ts - About 3 hrs to fix

            Function place has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
            Open

              public place(): void {
                let pos = 0;
                let row = 4;
                let col = 0;
            
            
            Severity: Minor
            Found in src/core/datamatrix/encoder/DefaultPlacement.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 adjustCompleteIndicatorColumnRowNumbers has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
            Open

              adjustCompleteIndicatorColumnRowNumbers(barcodeMetadata: BarcodeMetadata): void {
                let codewords: Codeword[] = this.getCodewords();
                this.setRowNumbers();
                this.removeIncorrectCodewords(codewords, barcodeMetadata);
                let boundingBox: BoundingBox = this.getBoundingBox();
            Severity: Minor
            Found in src/core/pdf417/decoder/DetectionResultRowIndicatorColumn.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 detect has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
            Open

              private static detect( multiple: boolean,  bitMatrix: BitMatrix): Array<ResultPoint[]> {
                const barcodeCoordinates = new Array<ResultPoint[]>();
                let row = 0;
                let column = 0;
                let foundBarcodeInRow = false;
            Severity: Minor
            Found in src/core/pdf417/detector/Detector.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 getStartColumn has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
            Open

              private static getStartColumn(detectionResult: DetectionResult,
                barcodeColumn: int,
                imageRow: int,
                leftToRight: boolean): int {
                let offset: int = leftToRight ? 1 : -1;
            Severity: Minor
            Found in src/core/pdf417/decoder/PDF417ScanningDecoder.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

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

                    for (let x = 0; x < 4 && rowOffset < end; x++) {
                        let bestMatch = UPCEANReader.decodeDigit(row, counters, rowOffset, UPCEANReader.L_PATTERNS);
                        resultString += String.fromCharCode(('0'.charCodeAt(0) + bestMatch));
            
                        for (let counter of counters) {
            Severity: Major
            Found in src/core/oned/EAN8Reader.ts and 2 other locations - About 3 hrs to fix
            src/core/oned/EAN13Reader.ts on lines 67..73
            src/core/oned/EAN8Reader.ts on lines 44..51

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

            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 x = 0; x < 4 && rowOffset < end; x++) {
                        let bestMatch = UPCEANReader.decodeDigit(row, counters, rowOffset, UPCEANReader.L_PATTERNS);
                        resultString += String.fromCharCode(('0'.charCodeAt(0) + bestMatch));
            
                        for (let counter of counters) {
            Severity: Major
            Found in src/core/oned/EAN8Reader.ts and 2 other locations - About 3 hrs to fix
            src/core/oned/EAN13Reader.ts on lines 67..73
            src/core/oned/EAN8Reader.ts on lines 56..63

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

            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 x = 0; x < 6 && rowOffset < end; x++) {
                        let bestMatch = UPCEANReader.decodeDigit(row, counters, rowOffset, UPCEANReader.L_PATTERNS);
                        resultString += String.fromCharCode(('0'.charCodeAt(0) + bestMatch));
                        for (let counter of counters) {
                            rowOffset += counter;
            Severity: Major
            Found in src/core/oned/EAN13Reader.ts and 2 other locations - About 3 hrs to fix
            src/core/oned/EAN8Reader.ts on lines 44..51
            src/core/oned/EAN8Reader.ts on lines 56..63

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

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

              private static decodeTextSegment(bits: BitSource, result: StringBuilder): void {
                // Three Text values are encoded in a 16-bit value as
                // (1600 * C1) + (40 * C2) + C3 + 1
                // TODO(bbrown): The Upper Shift with Text doesn't work in the 4 value scenario all the time
                let upperShift = false;
            Severity: Major
            Found in src/core/datamatrix/decoder/DecodedBitStreamParser.ts - About 3 hrs to fix

              Function encode has 80 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                public encode(
                  contents: string,
                  format: BarcodeFormat,
                  width: number,
                  height: number,
              Severity: Major
              Found in src/core/datamatrix/DataMatrixWriter.ts - About 3 hrs to fix

                Function decodeDataCharacter has 78 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private decodeDataCharacter(row: BitArray, pattern: FinderPattern, outsideChar: boolean): DataCharacter {
                
                        let counters = this.getDataCharacterCounters();
                        for (let x = 0; x < counters.length; x++) {
                            counters[x] = 0;
                Severity: Major
                Found in src/core/oned/rss/RSS14Reader.ts - About 3 hrs to fix

                  Function constructor has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                  Open

                    constructor(solution: Edge) {
                      const input = solution.input;
                      let size = 0;
                      let bytesAL: number[] = [];
                      const randomizePostfixLength = [];
                  Severity: Minor
                  Found in src/core/datamatrix/encoder/MinimalEncoder.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 checkAndNudgePoints has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected static checkAndNudgePoints(
                          image: BitMatrix,
                          points: Float32Array
                      ): void /*throws NotFoundException*/ {
                  
                  
                  Severity: Minor
                  Found in src/core/common/GridSampler.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 parseFromString has a Cognitive Complexity of 22 (exceeds 5 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 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 toString has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                  Open

                    public toString(): String {
                      let result: StringBuilder = new StringBuilder(/*8 * this.getDegree()*/); // dynamic string size in JS
                      for (let degree /*int*/ = this.getDegree(); degree >= 0; degree--) {
                        let coefficient: /*int*/ number = this.getCoefficient(degree);
                        if (coefficient !== 0) {
                  Severity: Minor
                  Found in src/core/pdf417/decoder/ec/ModulusPoly.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