zxing-js/library

View on GitHub

Showing 958 of 958 total issues

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

    public rotateCounterClockwise45(): BinaryBitmap {
        const newSource: LuminanceSource = this.binarizer.getLuminanceSource().rotateCounterClockwise45();
        return new BinaryBitmap(this.binarizer.createBinarizer(newSource));
    }
Severity: Major
Found in src/core/BinaryBitmap.ts and 1 other location - About 1 hr to fix
src/core/BinaryBitmap.ts on lines 126..129

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

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

    private distancePoint(a: Point, b: Point): number {
        return MathUtils.distance(a.getX(), a.getY(), b.getX(), b.getY());
    }
Severity: Major
Found in src/core/aztec/detector/Detector.ts and 1 other location - About 1 hr to fix
src/core/aztec/detector/Detector.ts on lines 598..600

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

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

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

                            for (let i = 5; i >= 0; i--) {
                                for (let j = dimension - 9; j >= ijMin; j--) {
                                    versionBits = this.copyBit(i, j, versionBits);
                                }
                            }
                    Severity: Major
                    Found in src/core/qrcode/decoder/BitMatrixParser.ts and 1 other location - About 1 hr to fix
                    src/core/qrcode/decoder/BitMatrixParser.ts on lines 115..119

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

                    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

                            for (let j = 5; j >= 0; j--) {
                                for (let i = dimension - 9; i >= ijMin; i--) {
                                    versionBits = this.copyBit(i, j, versionBits);
                                }
                            }
                    Severity: Major
                    Found in src/core/qrcode/decoder/BitMatrixParser.ts and 1 other location - About 1 hr to fix
                    src/core/qrcode/decoder/BitMatrixParser.ts on lines 129..133

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

                    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 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 processFinderPatternInfo has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                      protected processFinderPatternInfo(info: FinderPatternInfo): DetectorResult {
                    
                        const topLeft: FinderPattern = info.getTopLeft();
                        const topRight: FinderPattern = info.getTopRight();
                        const bottomLeft: FinderPattern = info.getBottomLeft();
                    Severity: Minor
                    Found in src/core/qrcode/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 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

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

                        public static applyMaskPenaltyRule3(matrix: ByteMatrix): number /*int*/ {
                            let numPenalties = 0;
                            const array: Array<Uint8Array> = matrix.getArray();
                            const width: number /*int*/ = matrix.getWidth();
                            const height: number /*int*/ = matrix.getHeight();
                    Severity: Minor
                    Found in src/core/qrcode/encoder/MaskUtil.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 findAsteriskPattern has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                      private static findAsteriskPattern(row: BitArray, counters: Int32Array): number[] {
                        let width = row.getSize();
                        let rowOffset = row.getNextSet(0);
                    
                        let counterPosition = 0;
                    Severity: Minor
                    Found in src/core/oned/Code39Reader.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