zxing-js/library

View on GitHub

Showing 958 of 958 total issues

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

  private corner1(pos: number): void {
    this.module(this.numrows - 1, 0, pos, 1);
    this.module(this.numrows - 1, 1, pos, 2);
    this.module(this.numrows - 1, 2, pos, 3);
    this.module(0, this.numcols - 2, pos, 4);
Severity: Major
Found in src/core/datamatrix/encoder/DefaultPlacement.ts and 2 other locations - About 7 hrs to fix
src/core/datamatrix/encoder/DefaultPlacement.ts on lines 144..153
src/core/datamatrix/encoder/DefaultPlacement.ts on lines 155..164

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

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

File PDF417ScanningDecoder.ts has 485 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
* Copyright 2013 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/pdf417/decoder/PDF417ScanningDecoder.ts - About 7 hrs to fix

    File DecodedBitStreamParser.ts has 476 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*
     * Copyright 2009 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/pdf417/decoder/DecodedBitStreamParser.ts - About 7 hrs to fix

      Function decodeC40Segment has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
      Open

        private static decodeC40Segment(bits: BitSource, result: StringBuilder): void {
          // Three C40 values are encoded in a 16-bit value as
          // (1600 * C1) + (40 * C2) + C3 + 1
          // TODO(bbrown): The Upper Shift with C40 doesn't work in the 4 value scenario all the time
          let upperShift = false;
      Severity: Minor
      Found in src/core/datamatrix/decoder/DecodedBitStreamParser.ts - About 7 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 a Cognitive Complexity of 47 (exceeds 5 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: Minor
      Found in src/core/oned/rss/expanded/RSSExpandedReader.ts - About 7 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 lookAheadTestIntern has 180 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        static lookAheadTestIntern(
          msg: string,
          startpos: number,
          currentMode: number
        ): number {
      Severity: Major
      Found in src/core/datamatrix/encoder/HighLevelEncoder.ts - About 7 hrs to fix

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

            if (this.isAlphaOr646ToNumericLatch(this.current.getPosition())) {
              this.current.incrementPosition(3);
              this.current.setNumeric();
            } else if (this.isAlphaTo646ToAlphaLatch(this.current.getPosition())) {
              if (this.current.getPosition() + 5 < this.information.getSize()) {
        Severity: Major
        Found in src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.ts and 1 other location - About 7 hrs to fix
        src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.ts on lines 178..189

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

        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

            if (this.isAlphaOr646ToNumericLatch(this.current.getPosition())) {
              this.current.incrementPosition(3);
              this.current.setNumeric();
            } else if (this.isAlphaTo646ToAlphaLatch(this.current.getPosition())) {
              if (this.current.getPosition() + 5 < this.information.getSize()) {
        Severity: Major
        Found in src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.ts and 1 other location - About 7 hrs to fix
        src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.ts on lines 206..217

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

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

            public find(): AlignmentPattern /*throws NotFoundException*/ {
                const startX = this.startX;
                const height = this.height;
                const width = this.width;
                const maxJ = startX + width;
        Severity: Minor
        Found in src/core/qrcode/detector/AlignmentPatternFinder.ts - About 7 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 45 (exceeds 5 allowed). Consider refactoring.
        Open

            public detect(): ResultPoint[] {
        
                let left = this.leftInit;
                let right = this.rightInit;
                let up = this.upInit;
        Severity: Minor
        Found in src/core/common/detector/CornerDetector.ts - About 6 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 2 locations. Consider refactoring.
        Open

                for (let x = 0; x < 2 && rowOffset < end; x++) {
                    let bestMatch = AbstractUPCEANReader.decodeDigit(row, counters, rowOffset, AbstractUPCEANReader.L_AND_G_PATTERNS);
                    resultString += String.fromCharCode(('0'.charCodeAt(0) + bestMatch % 10));
                    for (let counter of counters) {
                        rowOffset += counter;
        Severity: Major
        Found in src/core/oned/UPCEANExtension2Support.ts and 1 other location - About 6 hrs to fix
        src/core/oned/UPCEANExtension5Support.ts on lines 68..82

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

        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 x = 0; x < 5 && rowOffset < end; x++) {
                    let bestMatch = AbstractUPCEANReader.decodeDigit(row, counters, rowOffset, AbstractUPCEANReader.L_AND_G_PATTERNS);
                    resultString += String.fromCharCode(('0'.charCodeAt(0) + bestMatch % 10));
                    for (let counter of counters) {
                        rowOffset += counter;
        Severity: Major
        Found in src/core/oned/UPCEANExtension5Support.ts and 1 other location - About 6 hrs to fix
        src/core/oned/UPCEANExtension2Support.ts on lines 66..80

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

        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

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

            public abstract sampleGrid(
                image: BitMatrix,
                dimensionX: number /*int*/,
                dimensionY: number /*int*/,
                p1ToX: number/*float*/, p1ToY: number/*float*/,
        Severity: Major
        Found in src/core/common/GridSampler.ts and 1 other location - About 6 hrs to fix
        src/core/common/DefaultGridSampler.ts on lines 33..50

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

        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

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

            public sampleGrid(image: BitMatrix,
                dimensionX: number /*int*/,
                dimensionY: number /*int*/,
                p1ToX: number/*float*/, p1ToY: number/*float*/,
                p2ToX: number/*float*/, p2ToY: number/*float*/,
        Severity: Major
        Found in src/core/common/DefaultGridSampler.ts and 1 other location - About 6 hrs to fix
        src/core/common/GridSampler.ts on lines 70..82

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

        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 getEnclosingRectangle has a Cognitive Complexity of 43 (exceeds 5 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 6 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 2 locations. Consider refactoring.
        Open

                if (outsideChar) {
                    if ((oddSum & 0x01) !== 0 || oddSum > 12 || oddSum < 4) {
                        throw new NotFoundException();
                    }
                    let group = (12 - oddSum) / 2;
        Severity: Major
        Found in src/core/oned/rss/RSS14Reader.ts and 1 other location - About 6 hrs to fix
        src/core/oned/rss/RSS14Reader.ts on lines 224..236

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

        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

                } else {
                    if ((evenSum & 0x01) !== 0 || evenSum > 10 || evenSum < 4) {
                        throw new NotFoundException();
                    }
                    let group = (10 - evenSum) / 2;
        Severity: Major
        Found in src/core/oned/rss/RSS14Reader.ts and 1 other location - About 6 hrs to fix
        src/core/oned/rss/RSS14Reader.ts on lines 212..224

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

        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

        File Code128Reader.ts has 430 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /*
         * Copyright 2008 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/oned/Code128Reader.ts - About 6 hrs to fix

          File Version.ts has 429 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          /*
           * Copyright 2007 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/qrcode/decoder/Version.ts - About 6 hrs to fix

            File FinderPatternFinder.ts has 420 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            /*
             * Copyright 2007 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/qrcode/detector/FinderPatternFinder.ts - About 6 hrs to fix
              Severity
              Category
              Status
              Source
              Language