zxing-js/library

View on GitHub

Showing 958 of 958 total issues

Function decodeAllCodes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  decodeAllCodes(buff: StringBuilder, initialPosition: number): string {
    let currentPosition = initialPosition;
    let remaining = null;
    do {
      let info = this.decodeGeneralPurposeField(currentPosition, remaining);
Severity: Minor
Found in src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.ts - About 45 mins 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 parseIsoIec646Block has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  private parseIsoIec646Block(): BlockParsedResult {
    while (this.isStillIsoIec646(this.current.getPosition())) {
      let iso = this.decodeIsoIec646(this.current.getPosition());
      this.current.setPosition(iso.getNewPosition());

Severity: Minor
Found in src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.ts - About 45 mins 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

Avoid deeply nested control flow statements.
Open

        if (oddSum < evenSum) {
          incrementOdd = true;
          decrementEven = true;
        } else {
          decrementOdd = true;
Severity: Major
Found in src/core/oned/rss/expanded/RSSExpandedReader.ts - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                switch (code) {
                  case Code128Reader.CODE_FNC_1:
                    if (convertFNC1) {
                      if (result.length === 0) {
                        // GS1 specification 5.4.3.7. and 5.4.6.4. If the first char after the start code
    Severity: Major
    Found in src/core/oned/Code128Reader.ts - About 45 mins to fix

      Function retrieveNextPair has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        retrieveNextPair(
          row: BitArray,
          previousPairs: Array<ExpandedPair>,
          rowNumber: number
        ): ExpandedPair {
      Severity: Minor
      Found in src/core/oned/rss/expanded/RSSExpandedReader.ts - About 45 mins 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 parseAlphaBlock has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        private parseAlphaBlock(): BlockParsedResult {
          while (this.isStillAlpha(this.current.getPosition())) {
            let alpha = this.decodeAlphanumeric(this.current.getPosition());
            this.current.setPosition(alpha.getNewPosition());
      
      
      Severity: Minor
      Found in src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.ts - About 45 mins 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

      Avoid deeply nested control flow statements.
      Open

                      if (!upperMode && shiftUpperMode) {
                        upperMode = true;
                        shiftUpperMode = false;
                      } else if (upperMode && shiftUpperMode) {
                        upperMode = false;
      Severity: Major
      Found in src/core/oned/Code128Reader.ts - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                if (evenParityBad) {
                  throw new NotFoundException();
                }
        Severity: Major
        Found in src/core/oned/rss/expanded/RSSExpandedReader.ts - About 45 mins to fix

          Function extractParameters has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              private extractParameters(bullsEyeCorners: ResultPoint[]): void {
                  if (!this.isValidPoint(bullsEyeCorners[0]) || !this.isValidPoint(bullsEyeCorners[1]) ||
                      !this.isValidPoint(bullsEyeCorners[2]) || !this.isValidPoint(bullsEyeCorners[3])) {
                      throw new NotFoundException();
                  }
          Severity: Minor
          Found in src/core/aztec/detector/Detector.ts - About 45 mins 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 isAlphaTo646ToAlphaLatch has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            private isAlphaTo646ToAlphaLatch(pos: number): boolean {
              if (pos + 1 > this.information.getSize()) {
                return false;
              }
          
          
          Severity: Minor
          Found in src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.ts - About 45 mins 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 getStandardUPCEANChecksum has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              static getStandardUPCEANChecksum(s: string): number {
                  let length = s.length;
                  let sum = 0;
                  for (let i = length - 1; i >= 0; i -= 2) {
                      let digit = s.charAt(i).charCodeAt(0) - '0'.charCodeAt(0);
          Severity: Minor
          Found in src/core/oned/AbstractUPCEANReader.ts - About 45 mins 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

          Avoid deeply nested control flow statements.
          Open

                      if (variance < bestVariance) {
                        bestVariance = variance;
                        bestMatch = startCode;
                      }
          Severity: Major
          Found in src/core/oned/Code128Reader.ts - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                        if (shiftUpperMode === upperMode) {
                          result += String.fromCharCode((code - 64));
                        } else {
                          result += String.fromCharCode((code + 64));
                        }
            Severity: Major
            Found in src/core/oned/Code128Reader.ts - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                              if (convertFNC1) {
                                if (result.length === 0) {
                                  // GS1 specification 5.4.3.7. and 5.4.6.4. If the first char after the start code
                                  // is FNC1 then this is GS1-128. We add the symbology identifier.
                                  result += ']C1';
              Severity: Major
              Found in src/core/oned/Code128Reader.ts - About 45 mins to fix

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

                      HighLevelEncoder.isDigit(this.input.charAt(from)) &&
                      HighLevelEncoder.isDigit(this.input.charAt(from + 1)) &&
                      HighLevelEncoder.isDigit(this.input.charAt(from + 2)) &&
                Severity: Minor
                Found in src/core/datamatrix/encoder/MinimalEncoder.ts and 1 other location - About 45 mins to fix
                src/core/datamatrix/encoder/MinimalEncoder.ts on lines 855..860

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

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

                        while (j < maxJ && image.get(j, centerI) && stateCount[4] < maxCount) {
                            stateCount[4]++;
                            j++;
                        }
                Severity: Major
                Found in src/core/qrcode/detector/FinderPatternFinder.ts and 2 other locations - About 45 mins to fix
                src/core/qrcode/detector/AlignmentPatternFinder.ts on lines 214..217
                src/core/qrcode/detector/FinderPatternFinder.ts on lines 384..387

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

                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

                        HighLevelEncoder.isDigit(this.input.charAt(from)) &&
                        HighLevelEncoder.isDigit(this.input.charAt(from + 1)) &&
                        !MinimalEncoder.isExtendedASCII(
                          this.input.charAt(from + 2),
                          this.input.getFNC1Character()
                Severity: Minor
                Found in src/core/datamatrix/encoder/MinimalEncoder.ts and 1 other location - About 45 mins to fix
                src/core/datamatrix/encoder/MinimalEncoder.ts on lines 877..879

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

                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 (firstNonZero === coefficientsLength) {
                                this.coefficients = Int32Array.from([0]);
                            } else {
                                this.coefficients = new Int32Array(coefficientsLength - firstNonZero);
                                System.arraycopy(coefficients,
                Severity: Minor
                Found in src/core/common/reedsolomon/GenericGFPoly.ts and 1 other location - About 45 mins to fix
                src/core/pdf417/decoder/ec/ModulusPoly.ts on lines 45..54

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

                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 (firstNonZero === coefficientsLength) {
                        this.coefficients = new Int32Array([0]);
                      } else {
                        this.coefficients = new Int32Array(coefficientsLength - firstNonZero);
                        System.arraycopy(coefficients,
                Severity: Minor
                Found in src/core/pdf417/decoder/ec/ModulusPoly.ts and 1 other location - About 45 mins to fix
                src/core/common/reedsolomon/GenericGFPoly.ts on lines 59..68

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

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

                        while (i < maxI && image.get(centerJ, i) && stateCount[1] <= maxCount) {
                            stateCount[1]++;
                            i++;
                        }
                Severity: Major
                Found in src/core/qrcode/detector/AlignmentPatternFinder.ts and 2 other locations - About 45 mins to fix
                src/core/qrcode/detector/FinderPatternFinder.ts on lines 384..387
                src/core/qrcode/detector/FinderPatternFinder.ts on lines 453..456

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

                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