zxing-js/library

View on GitHub

Showing 958 of 958 total issues

Function decodeAsciiSegment has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

  private static decodeAsciiSegment(bits: BitSource,
                                         result: StringBuilder,
                                         resultTrailer: StringBuilder): Mode {
    let upperShift = false;
    do {
Severity: Minor
Found in src/core/datamatrix/decoder/DecodedBitStreamParser.ts - About 2 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 4 locations. Consider refactoring.
Open

    for (let dataLength of FieldParser.THREE_DIGIT_DATA_LENGTH) {
      if (dataLength[0] === firstThreeDigits) {
        if (dataLength[1] === FieldParser.VARIABLE_LENGTH) {
          return FieldParser.processVariableAI(3, <number>dataLength[2], rawInformation);
        }
Severity: Major
Found in src/core/oned/rss/expanded/decoders/FieldParser.ts and 3 other locations - About 2 hrs to fix
src/core/oned/rss/expanded/decoders/FieldParser.ts on lines 164..171
src/core/oned/rss/expanded/decoders/FieldParser.ts on lines 189..196
src/core/oned/rss/expanded/decoders/FieldParser.ts on lines 204..211

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

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

    for (let dataLength of FieldParser.TWO_DIGIT_DATA_LENGTH) {
      if (dataLength[0] === firstTwoDigits) {
        if (dataLength[1] === FieldParser.VARIABLE_LENGTH) {
          return FieldParser.processVariableAI(2, <number>dataLength[2], rawInformation);
        }
Severity: Major
Found in src/core/oned/rss/expanded/decoders/FieldParser.ts and 3 other locations - About 2 hrs to fix
src/core/oned/rss/expanded/decoders/FieldParser.ts on lines 179..186
src/core/oned/rss/expanded/decoders/FieldParser.ts on lines 189..196
src/core/oned/rss/expanded/decoders/FieldParser.ts on lines 204..211

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

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

    for (let dataLength of FieldParser.THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH) {
      if (dataLength[0] === firstThreeDigits) {
        if (dataLength[1] === FieldParser.VARIABLE_LENGTH) {
          return FieldParser.processVariableAI(4, <number>dataLength[2], rawInformation);
        }
Severity: Major
Found in src/core/oned/rss/expanded/decoders/FieldParser.ts and 3 other locations - About 2 hrs to fix
src/core/oned/rss/expanded/decoders/FieldParser.ts on lines 164..171
src/core/oned/rss/expanded/decoders/FieldParser.ts on lines 179..186
src/core/oned/rss/expanded/decoders/FieldParser.ts on lines 204..211

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

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

    for (let dataLength of FieldParser.FOUR_DIGIT_DATA_LENGTH) {
      if (dataLength[0] === firstFourDigits) {
        if (dataLength[1] === FieldParser.VARIABLE_LENGTH) {
          return FieldParser.processVariableAI(4, <number>dataLength[2], rawInformation);
        }
Severity: Major
Found in src/core/oned/rss/expanded/decoders/FieldParser.ts and 3 other locations - About 2 hrs to fix
src/core/oned/rss/expanded/decoders/FieldParser.ts on lines 164..171
src/core/oned/rss/expanded/decoders/FieldParser.ts on lines 179..186
src/core/oned/rss/expanded/decoders/FieldParser.ts on lines 189..196

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

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

Encoder has 25 functions (exceeds 20 allowed). Consider refactoring.
Open

export default class Encoder {

    // The original table is defined in the table 5 of JISX0510:2004 (p.19).
    private static ALPHANUMERIC_TABLE = Int32Array.from([
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  // 0x00-0x0f
Severity: Minor
Found in src/core/qrcode/encoder/Encoder.ts - About 2 hrs to fix

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

        protected createSVGElement(w: number, h: number): SVGSVGElement {
    
            const el = document.createElementNS(BrowserSvgCodeWriter.SVG_NS, 'svg');
    
            el.setAttributeNS(null, 'width', h.toString());
    Severity: Major
    Found in src/browser/BrowserSvgCodeWriter.ts and 1 other location - About 2 hrs to fix
    src/browser/BrowserQRCodeSvgWriter.ts on lines 136..144

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

    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

        static checkStandardUPCEANChecksum(s: string): boolean {
            let length = s.length;
            if (length === 0) return false;
    
            let check = parseInt(s.charAt(length - 1), 10);
    Severity: Major
    Found in src/core/oned/AbstractUPCEANReader.ts and 1 other location - About 2 hrs to fix
    src/core/oned/UPCEANReader.ts on lines 144..150

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

    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

        static checkStandardUPCEANChecksum(s: string): boolean {
            let length = s.length;
            if (length === 0) return false;
    
            let check = parseInt(s.charAt(length - 1), 10);
    Severity: Major
    Found in src/core/oned/UPCEANReader.ts and 1 other location - About 2 hrs to fix
    src/core/oned/AbstractUPCEANReader.ts on lines 112..118

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

    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 createSVGElement(w: number, h: number): SVGSVGElement {
    
            const svgElement = document.createElementNS(BrowserQRCodeSvgWriter.SVG_NS, 'svg');
    
            svgElement.setAttributeNS(null, 'height', w.toString());
    Severity: Major
    Found in src/browser/BrowserQRCodeSvgWriter.ts and 1 other location - About 2 hrs to fix
    src/browser/BrowserSvgCodeWriter.ts on lines 140..148

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

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

      getLastASCII(): number {
        const length = this.input.length();
        const from = this.fromPosition + this.characterLength;
        if (length - from > 4 || from >= length) {
          return 0;
    Severity: Major
    Found in src/core/datamatrix/encoder/MinimalEncoder.ts - About 2 hrs to fix

      Function getNumberOfC40Words has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

        static getNumberOfC40Words(
          input: Input,
          from: number,
          c40: boolean,
          characterLength: number[]
      Severity: Minor
      Found in src/core/datamatrix/encoder/MinimalEncoder.ts - About 2 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 getDataBlocks has a Cognitive Complexity of 20 (exceeds 5 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 2 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 extractPureBits has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

        private static extractPureBits(image: BitMatrix): BitMatrix /*throws NotFoundException */ {
      
          const leftTopBlack: Int32Array = image.getTopLeftOnBit();
          const rightBottomBlack: Int32Array = image.getBottomRightOnBit();
          if (leftTopBlack === null || rightBottomBlack === null) {
      Severity: Minor
      Found in src/core/qrcode/QRCodeReader.ts - About 2 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 crossCheckDiagonal has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          private crossCheckDiagonal(startI: number /*int*/, centerJ: number /*int*/, maxCount: number /*int*/, originalStateCountTotal: number /*int*/): boolean {
              const stateCount: Int32Array = this.getCrossCheckStateCount();
      
              // Start counting up, left from center finding black center mass
              let i = 0;
      Severity: Minor
      Found in src/core/qrcode/detector/FinderPatternFinder.ts - About 2 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 createDecoderResultFromAmbiguousValues has a Cognitive Complexity of 20 (exceeds 5 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 2 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 encode has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

        public encode(): BitArray {
      
          const spaceCharCode = StringUtils.getCharCode(' ');
          const lineBreakCharCode = StringUtils.getCharCode('\n');
      
      
      Severity: Minor
      Found in src/core/aztec/encoder/HighLevelEncoder.ts - About 2 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 decodeRow has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          public decodeRow(rowNumber: number, row: BitArray, hints?: Map<DecodeHintType, any>): Result {
              let startGuardRange = UPCEANReader.findStartGuardPattern(row);
              let resultPointCallback = hints == null ? null : hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
      
              if (resultPointCallback != null) {
      Severity: Minor
      Found in src/core/oned/UPCEANReader.ts - About 2 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 correctBits has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          private correctBits(rawbits: boolean[]): boolean[] {
              let gf: GenericGF;
              let codewordSize: number;
      
              if (this.ddata.getNbLayers() <= 2) {
      Severity: Minor
      Found in src/core/aztec/decoder/Decoder.ts - About 2 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 6 locations. Consider refactoring.
      Open

              new Version(38, Int32Array.from([6, 32, 58, 84, 110, 136, 162]),
                  new ECBlocks(30, new ECB(4, 122),
                      new ECB(18, 123)),
                  new ECBlocks(28, new ECB(13, 46),
                      new ECB(32, 47)),
      Severity: Major
      Found in src/core/qrcode/decoder/Version.ts and 5 other locations - About 2 hrs to fix
      src/core/qrcode/decoder/Version.ts on lines 326..334
      src/core/qrcode/decoder/Version.ts on lines 335..343
      src/core/qrcode/decoder/Version.ts on lines 344..352
      src/core/qrcode/decoder/Version.ts on lines 362..370
      src/core/qrcode/decoder/Version.ts on lines 371..379

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

      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

      Severity
      Category
      Status
      Source
      Language