zxing-js/library

View on GitHub

Showing 958 of 958 total issues

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

    for (let i = 11; i >= 0; --i) {
      if ((firstValue & (1 << i)) !== 0) {
        binary.set(accPos);
      }
      accPos++;
Severity: Major
Found in src/core/oned/rss/expanded/BitArrayBuilder.ts and 2 other locations - About 1 hr to fix
src/core/oned/rss/expanded/BitArrayBuilder.ts on lines 29..34
src/core/oned/rss/expanded/BitArrayBuilder.ts on lines 38..43

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

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

        cx = MathUtils.round((pointA.getX() + pointD.getX() + pointB.getX() + pointC.getX()) / 4.0);
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 384..384

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

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

        let cy = MathUtils.round((pointA.getY() + pointD.getY() + pointB.getY() + pointC.getY()) / 4.0);
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 361..361

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

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

    const loop = (
      resolve: (value?: Result | PromiseLike<Result>) => void,
      reject: (reason?: any) => void
    ) => {
      if (this._stopAsyncDecode) {
Severity: Minor
Found in src/browser/BrowserCodeReader.ts - About 1 hr to fix

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

      private static extractPureBits(image: BitMatrix): BitMatrix {
    
        const leftTopBlack = image.getTopLeftOnBit();
        const rightBottomBlack = image.getBottomRightOnBit();
        if (leftTopBlack == null || rightBottomBlack == null) {
    Severity: Minor
    Found in src/core/datamatrix/DataMatrixReader.ts - About 1 hr to fix

      Function createTransform has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        private static createTransform(topLeft: ResultPoint,
          topRight: ResultPoint,
          bottomLeft: ResultPoint,
          alignmentPattern: ResultPoint,
          dimension: number /*int*/): PerspectiveTransform {
      Severity: Minor
      Found in src/core/qrcode/detector/Detector.ts - About 1 hr to fix

        Function adjustIncompleteIndicatorColumnRowNumbers has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          private adjustIncompleteIndicatorColumnRowNumbers(barcodeMetadata: BarcodeMetadata): void {
            let boundingBox: BoundingBox = this.getBoundingBox();
            let top: ResultPoint = this._isLeft ? boundingBox.getTopLeft() : boundingBox.getTopRight();
            let bottom: ResultPoint = this._isLeft ? boundingBox.getBottomLeft() : boundingBox.getBottomRight();
            let firstRow: int = this.imageRowToCodewordIndex(<int> Math.trunc(top.getY()));
        Severity: Minor
        Found in src/core/pdf417/decoder/DetectionResultRowIndicatorColumn.ts - About 1 hr to fix

          Function findCorners has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private findCorners(right: number, left: number, down: number, up: number): ResultPoint[] {
                  //
                  //      A------------              ------------B
                  //      |           |      up      |           |
                  //      |    -------|--------------|-------    |
          Severity: Minor
          Found in src/core/common/detector/CornerDetector.ts - About 1 hr to fix

            Function findAsteriskPattern has 28 lines of code (exceeds 25 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

              Function createDecoderResultFromAmbiguousValues has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                private static createDecoderResultFromAmbiguousValues(ecLevel: int,
                  codewords: Int32Array,
                  erasureArray: Int32Array,
                  ambiguousIndexes: Int32Array,
                  ambiguousIndexValues: Int32Array[]): DecoderResult {
              Severity: Minor
              Found in src/core/pdf417/decoder/PDF417ScanningDecoder.ts - About 1 hr to fix

                Function getRSSvalue has 28 lines of code (exceeds 25 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 1 hr to fix

                  Function findGuardPattern has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private static findGuardPattern(
                          row: BitArray,
                          rowOffset: number,
                          pattern: Int32Array
                      ): number[] {
                  Severity: Minor
                  Found in src/core/oned/ITFReader.ts - About 1 hr to fix

                    Function parseExtension5String has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        static parseExtension5String(raw: string) {
                            let currency;
                            switch (raw.charAt(0)) {
                                case '0':
                                    currency = '£';
                    Severity: Minor
                    Found in src/core/oned/UPCEANExtension5Support.ts - About 1 hr to fix

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

                          if (c >= '0'.charCodeAt(0) && c <= '9'.charCodeAt(0)) {
                            sb.append(c - 48 + 4);
                            return 1;
                          }
                      Severity: Major
                      Found in src/core/datamatrix/encoder/C40Encoder.ts and 3 other locations - About 1 hr to fix
                      src/core/datamatrix/encoder/C40Encoder.ts on lines 207..210
                      src/core/datamatrix/encoder/TextEncoder.ts on lines 16..19
                      src/core/datamatrix/encoder/TextEncoder.ts on lines 20..23

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

                      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 4 locations. Consider refactoring.
                      Open

                          if (c >= 'a'.charCodeAt(0) && c <= 'z'.charCodeAt(0)) {
                            sb.append(c - 97 + 14);
                            return 1;
                          }
                      Severity: Major
                      Found in src/core/datamatrix/encoder/TextEncoder.ts and 3 other locations - About 1 hr to fix
                      src/core/datamatrix/encoder/C40Encoder.ts on lines 203..206
                      src/core/datamatrix/encoder/C40Encoder.ts on lines 207..210
                      src/core/datamatrix/encoder/TextEncoder.ts on lines 16..19

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

                      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 4 locations. Consider refactoring.
                      Open

                          if (c >= 'A'.charCodeAt(0) && c <= 'Z'.charCodeAt(0)) {
                            sb.append(c - 65 + 14);
                            return 1;
                          }
                      Severity: Major
                      Found in src/core/datamatrix/encoder/C40Encoder.ts and 3 other locations - About 1 hr to fix
                      src/core/datamatrix/encoder/C40Encoder.ts on lines 203..206
                      src/core/datamatrix/encoder/TextEncoder.ts on lines 16..19
                      src/core/datamatrix/encoder/TextEncoder.ts on lines 20..23

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

                      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 4 locations. Consider refactoring.
                      Open

                          if (c >= '0'.charCodeAt(0) && c <= '9'.charCodeAt(0)) {
                            sb.append(c - 48 + 4);
                            return 1;
                          }
                      Severity: Major
                      Found in src/core/datamatrix/encoder/TextEncoder.ts and 3 other locations - About 1 hr to fix
                      src/core/datamatrix/encoder/C40Encoder.ts on lines 203..206
                      src/core/datamatrix/encoder/C40Encoder.ts on lines 207..210
                      src/core/datamatrix/encoder/TextEncoder.ts on lines 20..23

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

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

                        static decode(bytes:  Uint8Array): DecoderResult {
                          const bits = new BitSource(bytes);
                          const result = new StringBuilder();
                          const resultTrailer = new StringBuilder();
                          const byteSegments = new Array<Uint8Array>();
                      Severity: Minor
                      Found in src/core/datamatrix/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 encode has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                        public encode(context: EncoderContext) {
                          const buffer = new StringBuilder();
                          buffer.append(0o0); // Initialize length field
                          while (context.hasMoreCharacters()) {
                            const c = context.getCurrentChar();
                      Severity: Minor
                      Found in src/core/datamatrix/encoder/Base256Encoder.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 getLatchBytes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                        getLatchBytes(): Uint8Array {
                          switch (this.getPreviousMode()) {
                            case Mode.ASCII:
                            case Mode.B256: // after B256 ends (via length) we are back to ASCII
                              switch (this.mode) {
                      Severity: Minor
                      Found in src/core/datamatrix/encoder/MinimalEncoder.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