zxing-js/library

View on GitHub

Showing 958 of 958 total issues

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

          case 0:
            if (cValue < 3) {
              shift = cValue + 1;
            } else if (cValue < this.TEXT_BASIC_SET_CHARS.length) {
              const textChar = this.TEXT_BASIC_SET_CHARS[cValue];
Severity: Major
Found in src/core/datamatrix/decoder/DecodedBitStreamParser.ts and 1 other location - About 4 hrs to fix
src/core/datamatrix/decoder/DecodedBitStreamParser.ts on lines 219..233

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

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

          case 0:
            if (cValue < 3) {
              shift = cValue + 1;
            } else if (cValue < this.C40_BASIC_SET_CHARS.length) {
              const c40char = this.C40_BASIC_SET_CHARS[cValue];
Severity: Major
Found in src/core/datamatrix/decoder/DecodedBitStreamParser.ts and 1 other location - About 4 hrs to fix
src/core/datamatrix/decoder/DecodedBitStreamParser.ts on lines 308..322

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

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

  public static guessEncoding(bytes: Uint8Array, hints: Map<DecodeHintType, any>): string {
    if (hints !== null && hints !== undefined && undefined !== hints.get(DecodeHintType.CHARACTER_SET)) {
      return hints.get(DecodeHintType.CHARACTER_SET).toString();
    }
    // For now, merely tries to distinguish ISO-8859-1, UTF-8 and Shift_JIS,
Severity: Major
Found in src/core/common/StringUtils.ts - About 4 hrs to fix

    Function doDecode has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

        private doDecode(image: BinaryBitmap, hints?: Map<DecodeHintType, any>): Result {
            const width = image.getWidth();
            const height = image.getHeight();
            let row = new BitArray(width);
    
    
    Severity: Minor
    Found in src/core/oned/OneDReader.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

    File Detector.ts has 357 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*
     * Copyright 2010 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/aztec/detector/Detector.ts - About 4 hrs to fix

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

              if (hints !== null) {
      
                  if (undefined !== hints.get(EncodeHintType.ERROR_CORRECTION)) {
                      errorCorrectionLevel = ErrorCorrectionLevel.fromString(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
                  }
      Severity: Major
      Found in src/browser/BrowserQRCodeSvgWriter.ts and 1 other location - About 4 hrs to fix
      src/core/qrcode/QRCodeWriter.ts on lines 69..76

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

      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

              if (hints !== null) {
                  if (undefined !== hints.get(EncodeHintType.ERROR_CORRECTION)) {
                      errorCorrectionLevel = ErrorCorrectionLevel.fromString(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
                  }
                  if (undefined !== hints.get(EncodeHintType.MARGIN)) {
      Severity: Major
      Found in src/core/qrcode/QRCodeWriter.ts and 1 other location - About 4 hrs to fix
      src/browser/BrowserQRCodeSvgWriter.ts on lines 50..59

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

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

          public detect(): Array<ResultPoint> /*throws NotFoundException*/ {
              let left = this.leftInit;
              let right = this.rightInit;
              let up = this.upInit;
              let down = this.downInit;
      Severity: Major
      Found in src/core/common/detector/WhiteRectangleDetector.ts - About 4 hrs to fix

        Function constructor has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
        Open

          constructor(stringToEncode: string, priorityCharset: Charset, fnc1: number) {
            const neededEncoders: CharsetEncoder[] = [];
        
            // we always need the ISO-8859-1 encoder. It is the default encoding
            neededEncoders.push(new CharsetEncoder(StandardCharsets.ISO_8859_1));
        Severity: Minor
        Found in src/core/common/ECIEncoderSet.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

        Function drawModeMessage has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
        Open

          private static drawModeMessage(matrix: BitMatrix, compact: boolean, matrixSize: int, modeMessage: BitArray): void {
            let center: int = Integer.truncDivision(matrixSize, 2);
            if (compact) {
              for (let i /*int*/ = 0; i < 7; i++) {
                let offset: int = center - 3 + i;
        Severity: Minor
        Found in src/core/aztec/encoder/Encoder.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

        Function encode has 107 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          public static encode(data: Uint8Array, minECCPercent: int, userSpecifiedLayers: int): AztecCode {
            // High-level encode
            let bits: BitArray = new HighLevelEncoder(data).encode();
        
            // stuff bits and choose symbol size
        Severity: Major
        Found in src/core/aztec/encoder/Encoder.ts - About 4 hrs to fix

          Function toString has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
          Open

              public toString(): string {
                  let result = '';
                  for (let degree = this.getDegree(); degree >= 0; degree--) {
                      let coefficient = this.getCoefficient(degree);
                      if (coefficient !== 0) {
          Severity: Minor
          Found in src/core/common/reedsolomon/AbstractGenericGFPoly.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

          Function toString has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
          Open

              public toString(): string {
                  let result = '';
                  for (let degree = this.getDegree(); degree >= 0; degree--) {
                      let coefficient = this.getCoefficient(degree);
                      if (coefficient !== 0) {
          Severity: Minor
          Found in src/core/common/reedsolomon/GenericGFPoly.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

          Function decodeDataCharacter has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
          Open

            decodeDataCharacter(
              row: BitArray,
              pattern: FinderPattern,
              isOddPattern: boolean,
              leftChar: boolean
          Severity: Minor
          Found in src/core/oned/rss/expanded/RSSExpandedReader.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

          Function encodeMinimally has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

            encodeMinimally(
              stringToEncode: string,
              encoderSet: ECIEncoderSet,
              fnc1: number
            ): number[] {
          Severity: Minor
          Found in src/core/common/MinimalECIInput.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

          Function parseFieldsInGeneralPurpose has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

            static parseFieldsInGeneralPurpose(rawInformation: string): string {
              if (!rawInformation) {
                return null;
              }
          
          
          Severity: Minor
          Found in src/core/oned/rss/expanded/decoders/FieldParser.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

          Function adjustOddEvenCounts has 102 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private adjustOddEvenCounts(outsideChar: boolean, numModules: number) {
          
                  let oddSum = MathUtils.sum(new Int32Array(this.getOddCounts()));
                  let evenSum = MathUtils.sum(new Int32Array(this.getEvenCounts()));
          
          
          Severity: Major
          Found in src/core/oned/rss/RSS14Reader.ts - About 4 hrs to fix

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

                if (otherToX < 0) {
                  scale = fromX / /*(float) */(fromX - otherToX);
                  otherToX = 0;
                } else if (otherToX >= this.image.getWidth()) {
                  scale = (this.image.getWidth() - 1 - fromX) / /*(float) */(otherToX - fromX);
            Severity: Major
            Found in src/core/qrcode/detector/Detector.ts and 1 other location - About 4 hrs to fix
            src/core/qrcode/detector/Detector.ts on lines 288..294

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

            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 (otherToY < 0) {
                  scale = fromY / /*(float) */(fromY - otherToY);
                  otherToY = 0;
                } else if (otherToY >= this.image.getHeight()) {
                  scale = (this.image.getHeight() - 1 - fromY) / /*(float) */(otherToY - fromY);
            Severity: Major
            Found in src/core/qrcode/detector/Detector.ts and 1 other location - About 4 hrs to fix
            src/core/qrcode/detector/Detector.ts on lines 278..284

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

            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 aboutEquals(moduleSize: number/*float*/, i: number/*float*/, j: number/*float*/): boolean {
                    if (Math.abs(i - this.getY()) <= moduleSize && Math.abs(j - this.getX()) <= moduleSize) {
                        const moduleSizeDiff: number /*float*/ = Math.abs(moduleSize - this.estimatedModuleSize);
                        return moduleSizeDiff <= 1.0 || moduleSizeDiff <= this.estimatedModuleSize;
                    }
            Severity: Major
            Found in src/core/qrcode/detector/FinderPattern.ts and 1 other location - About 3 hrs to fix
            src/core/qrcode/detector/AlignmentPattern.ts on lines 37..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 114.

            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