zxing-js/library

View on GitHub

Showing 958 of 958 total issues

Function decodeExtended has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

  private static decodeExtended(encoded: string): string {
    let length = encoded.length;
    let decoded = '';
    for (let i = 0; i < length; i++) {
      let c = encoded.charAt(i);
Severity: Minor
Found in src/core/oned/Code39Reader.ts - About 5 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 decodeExtended has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

  private decodeExtended(encoded: string): string {
    let length = encoded.length;
    let decoded = '';
    for (let i = 0; i < length; i++) {
      let c = encoded.charAt(i);
Severity: Minor
Found in src/core/oned/Code93Reader.ts - About 5 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

    public decodeRow(rowNumber: number, row: BitArray, extensionStartRange: Int32Array): Result {
        let result = this.decodeRowStringBuffer;
        let end = this.decodeMiddle(row, extensionStartRange, result);

        let resultString = result.toString();
Severity: Major
Found in src/core/oned/UPCEANExtension5Support.ts and 1 other location - About 5 hrs to fix
src/core/oned/UPCEANExtension2Support.ts on lines 34..53

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

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 createSvgRectElement(x: number, y: number, w: number, h: number): SVGRectElement {

        const rect = document.createElementNS(BrowserQRCodeSvgWriter.SVG_NS, 'rect');

        rect.setAttributeNS(null, 'x', x.toString());
Severity: Major
Found in src/browser/BrowserQRCodeSvgWriter.ts and 1 other location - About 5 hrs to fix
src/browser/BrowserSvgCodeWriter.ts on lines 166..177

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

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

    public decodeRow(rowNumber: number, row: BitArray, extensionStartRange: Int32Array) {
        let result = this.decodeRowStringBuffer;
        let end = this.decodeMiddle(row, extensionStartRange, result);

        let resultString = result.toString();
Severity: Major
Found in src/core/oned/UPCEANExtension2Support.ts and 1 other location - About 5 hrs to fix
src/core/oned/UPCEANExtension5Support.ts on lines 36..55

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

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

    protected createSvgRectElement(x: number, y: number, w: number, h: number): SVGRectElement {

        const el = document.createElementNS(BrowserSvgCodeWriter.SVG_NS, 'rect');

        el.setAttributeNS(null, 'x', x.toString());
Severity: Major
Found in src/browser/BrowserSvgCodeWriter.ts and 1 other location - About 5 hrs to fix
src/browser/BrowserQRCodeSvgWriter.ts on lines 154..165

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

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 HighLevelEncoder.ts has 405 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// tslint:disable-next-line:no-circular-imports
import { ASCIIEncoder } from './ASCIIEncoder';

// tslint:disable-next-line:no-circular-imports
import { Base256Encoder } from './Base256Encoder';
Severity: Minor
Found in src/core/datamatrix/encoder/HighLevelEncoder.ts - About 5 hrs to fix

    File Encoder.ts has 405 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/qrcode/encoder/Encoder.ts - About 5 hrs to fix

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

      import DecoderResult from '../../common/DecoderResult';
      import BitSource from '../../common/BitSource';
      import StringBuilder from '../../util/StringBuilder';
      
      import StringEncoding from '../../util/StringEncoding';
      Severity: Minor
      Found in src/core/datamatrix/decoder/DecodedBitStreamParser.ts - About 5 hrs to fix

        Function decodeTextCompaction has 139 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          private static decodeTextCompaction(textCompactionData: Int32Array,
            byteCompactionData: Int32Array,
            length: int,
            result: StringBuilder): void {
            // Beginning from an initial state of the Alpha sub-mode
        Severity: Major
        Found in src/core/pdf417/decoder/DecodedBitStreamParser.ts - About 5 hrs to fix

          File PDF417Common.ts has 398 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/PDF417Common.ts - About 5 hrs to fix

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

              private static getMinCodewordWidth(p: ResultPoint[]): number /*int*/ {
                return Math.floor(Math.min(
                  Math.min(PDF417Reader.getMinWidth(p[0], p[4]), PDF417Reader.getMinWidth(p[6], p[2]) * PDF417Common.MODULES_IN_CODEWORD /
                    PDF417Common.MODULES_IN_STOP_PATTERN),
                  Math.min(PDF417Reader.getMinWidth(p[1], p[5]), PDF417Reader.getMinWidth(p[7], p[3]) * PDF417Common.MODULES_IN_CODEWORD /
            Severity: Major
            Found in src/core/pdf417/PDF417Reader.ts and 1 other location - About 5 hrs to fix
            src/core/pdf417/PDF417Reader.ts on lines 145..151

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

            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 static getMaxCodewordWidth(p: ResultPoint[]): number /*int*/ {
                return Math.floor(Math.max(
                  Math.max(PDF417Reader.getMaxWidth(p[0], p[4]), PDF417Reader.getMaxWidth(p[6], p[2]) * PDF417Common.MODULES_IN_CODEWORD /
                    PDF417Common.MODULES_IN_STOP_PATTERN),
                  Math.max(PDF417Reader.getMaxWidth(p[1], p[5]), PDF417Reader.getMaxWidth(p[7], p[3]) * PDF417Common.MODULES_IN_CODEWORD /
            Severity: Major
            Found in src/core/pdf417/PDF417Reader.ts and 1 other location - About 5 hrs to fix
            src/core/pdf417/PDF417Reader.ts on lines 153..159

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

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

              private static /*int*/ byteCompaction(mode: int,
                codewords: Int32Array,
                encoding: /*Charset*/ CharacterSetECI,
                codeIndex: int,
                result: StringBuilder) {
            Severity: Minor
            Found in src/core/pdf417/decoder/DecodedBitStreamParser.ts - About 5 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

              public drawImageOnCanvas(
                srcElement: HTMLImageElement,
                dimensions = {
                  sx: 0,
                  sy: 0,
            Severity: Major
            Found in src/browser/BrowserCodeReader.ts and 1 other location - About 5 hrs to fix
            src/browser/BrowserCodeReader.ts on lines 985..1010

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

            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

              public drawFrameOnCanvas(
                srcElement: HTMLVideoElement,
                dimensions = {
                  sx: 0,
                  sy: 0,
            Severity: Major
            Found in src/browser/BrowserCodeReader.ts and 1 other location - About 5 hrs to fix
            src/browser/BrowserCodeReader.ts on lines 1015..1040

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

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

                private static getEncodedData(correctedBits: boolean[]): string {
                    let endIndex: number = correctedBits.length;
                    let latchTable = Table.UPPER; // table most recently latched to
                    let shiftTable = Table.UPPER; // table to use for the next read
                    let result: string = '';
            Severity: Minor
            Found in src/core/aztec/decoder/Decoder.ts - About 5 hrs to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            File RSS14Reader.ts has 377 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import AbstractRSSReader from './AbstractRSSReader';
            import Pair from './Pair';
            import Result from '../../Result';
            import BitArray from '../../common/BitArray';
            import DecodeHintType from '../../DecodeHintType';
            Severity: Minor
            Found in src/core/oned/rss/RSS14Reader.ts - About 5 hrs to fix

              File GeneralAppIdDecoder.ts has 373 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import BitArray from '../../../../common/BitArray';
              import FormatException from '../../../../FormatException';
              import IllegalStateException from '../../../../IllegalStateException';
              import StringBuilder from '../../../../util/StringBuilder';
              import BlockParsedResult from './BlockParsedResult';
              Severity: Minor
              Found in src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.ts - About 4 hrs to fix

                Function decode has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
                Open

                  public static decode(image: BitMatrix,
                    imageTopLeft: ResultPoint,
                    imageBottomLeft: ResultPoint,
                    imageTopRight: ResultPoint,
                    imageBottomRight: ResultPoint,
                Severity: Minor
                Found in src/core/pdf417/decoder/PDF417ScanningDecoder.ts - About 4 hrs to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Severity
                Category
                Status
                Source
                Language