zxing-js/library

View on GitHub
src/core/oned/rss/RSS14Reader.ts

Summary

Maintainability
F
1 wk
Test Coverage
A
92%

Function adjustOddEvenCounts has a Cognitive Complexity of 58 (exceeds 5 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: Minor
Found in src/core/oned/rss/RSS14Reader.ts - About 1 day 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

    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

      Function decodeDataCharacter has 78 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private decodeDataCharacter(row: BitArray, pattern: FinderPattern, outsideChar: boolean): DataCharacter {
      
              let counters = this.getDataCharacterCounters();
              for (let x = 0; x < counters.length; x++) {
                  counters[x] = 0;
      Severity: Major
      Found in src/core/oned/rss/RSS14Reader.ts - About 3 hrs to fix

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

            private decodeDataCharacter(row: BitArray, pattern: FinderPattern, outsideChar: boolean): DataCharacter {
        
                let counters = this.getDataCharacterCounters();
                for (let x = 0; x < counters.length; x++) {
                    counters[x] = 0;
        Severity: Minor
        Found in src/core/oned/rss/RSS14Reader.ts - About 3 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 findFinderPattern has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            private findFinderPattern(row: BitArray, rightFinderPattern: boolean): number[] {
        
                let counters = this.getDecodeFinderCounters();
                counters[0] = 0;
                counters[1] = 0;
        Severity: Minor
        Found in src/core/oned/rss/RSS14Reader.ts - About 1 hr to fix

        Cognitive Complexity

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

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

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

        Further reading

        Function findFinderPattern has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private findFinderPattern(row: BitArray, rightFinderPattern: boolean): number[] {
        
                let counters = this.getDecodeFinderCounters();
                counters[0] = 0;
                counters[1] = 0;
        Severity: Minor
        Found in src/core/oned/rss/RSS14Reader.ts - About 1 hr to fix

          Function decodeRow has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public decodeRow(rowNumber: number, row: BitArray, hints?: Map<DecodeHintType, any>): Result {
                  const leftPair = this.decodePair(row, false, rowNumber, hints);
                  RSS14Reader.addOrTally(this.possibleLeftPairs, leftPair);
                  row.reverse();
                  let rightPair = this.decodePair(row, true, rowNumber, hints);
          Severity: Minor
          Found in src/core/oned/rss/RSS14Reader.ts - About 1 hr to fix

          Cognitive Complexity

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

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

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

          Further reading

          Avoid deeply nested control flow statements.
          Open

                          if (!evenParityBad) {
                              throw new NotFoundException();
                          }
          Severity: Major
          Found in src/core/oned/rss/RSS14Reader.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/RSS14Reader.ts - About 45 mins to fix

              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/RSS14Reader.ts - About 45 mins to fix

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

                        if (mismatch === 1) {
                        if (oddParityBad) {
                            if (evenParityBad) {
                                throw new NotFoundException();
                            }
                Severity: Major
                Found in src/core/oned/rss/RSS14Reader.ts and 1 other location - About 1 day to fix
                src/core/oned/rss/expanded/RSSExpandedReader.ts on lines 840..885

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

                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 (outsideChar) {
                            if ((oddSum & 0x01) !== 0 || oddSum > 12 || oddSum < 4) {
                                throw new NotFoundException();
                            }
                            let group = (12 - oddSum) / 2;
                Severity: Major
                Found in src/core/oned/rss/RSS14Reader.ts and 1 other location - About 6 hrs to fix
                src/core/oned/rss/RSS14Reader.ts on lines 224..236

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

                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

                        } else {
                            if ((evenSum & 0x01) !== 0 || evenSum > 10 || evenSum < 4) {
                                throw new NotFoundException();
                            }
                            let group = (10 - evenSum) / 2;
                Severity: Major
                Found in src/core/oned/rss/RSS14Reader.ts and 1 other location - About 6 hrs to fix
                src/core/oned/rss/RSS14Reader.ts on lines 212..224

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

                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

                            for (let i = 0, j = counters.length - 1; i < j; i++ , j--) {
                                let temp = counters[i];
                                counters[i] = counters[j];
                                counters[j] = temp;
                            }
                Severity: Major
                Found in src/core/oned/rss/RSS14Reader.ts and 1 other location - About 2 hrs to fix
                src/core/oned/rss/expanded/RSSExpandedReader.ts on lines 718..722

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

                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

                        else {
                            if (oddSum > 11) {
                                decrementOdd = true;
                            }
                            else if (oddSum < 5) {
                Severity: Major
                Found in src/core/oned/rss/RSS14Reader.ts and 1 other location - About 2 hrs to fix
                src/core/oned/rss/RSS14Reader.ts on lines 322..335

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

                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 (outsideChar) {
                            if (oddSum > 12) {
                                decrementOdd = true;
                            }
                            else if (oddSum < 4) {
                Severity: Major
                Found in src/core/oned/rss/RSS14Reader.ts and 1 other location - About 2 hrs to fix
                src/core/oned/rss/RSS14Reader.ts on lines 336..349

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

                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 ((i & 0x01) === 0) {
                                oddCounts[offset] = count;
                                oddRoundingErrors[offset] = value - count;
                            } else {
                                evenCounts[offset] = count;
                Severity: Major
                Found in src/core/oned/rss/RSS14Reader.ts and 1 other location - About 1 hr to fix
                src/core/oned/rss/expanded/RSSExpandedReader.ts on lines 758..764

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

                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

                        for (let i = oddCounts.length - 1; i >= 0; i--) {
                            oddChecksumPortion *= 9;
                            oddChecksumPortion += oddCounts[i];
                            oddSum += oddCounts[i];
                        }
                Severity: Major
                Found in src/core/oned/rss/RSS14Reader.ts and 1 other location - About 1 hr to fix
                src/core/oned/rss/RSS14Reader.ts on lines 205..209

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

                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

                        for (let i = evenCounts.length - 1; i >= 0; i--) {
                            evenChecksumPortion *= 9;
                            evenChecksumPortion += evenCounts[i];
                            evenSum += evenCounts[i];
                        }
                Severity: Major
                Found in src/core/oned/rss/RSS14Reader.ts and 1 other location - About 1 hr to fix
                src/core/oned/rss/RSS14Reader.ts on lines 198..202

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

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

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

                        if (incrementOdd) {
                            if (decrementOdd) {
                                throw new NotFoundException();
                            }
                            AbstractRSSReader.increment(this.getOddCounts(), this.getOddRoundingErrors());
                Severity: Major
                Found in src/core/oned/rss/RSS14Reader.ts and 3 other locations - About 35 mins to fix
                src/core/oned/rss/RSS14Reader.ts on lines 413..418
                src/core/oned/rss/expanded/RSSExpandedReader.ts on lines 887..895
                src/core/oned/rss/expanded/RSSExpandedReader.ts on lines 902..910

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

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

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

                        if (incrementEven) {
                            if (decrementEven) {
                                throw new NotFoundException();
                            }
                            AbstractRSSReader.increment(this.getEvenCounts(), this.getOddRoundingErrors());
                Severity: Major
                Found in src/core/oned/rss/RSS14Reader.ts and 3 other locations - About 35 mins to fix
                src/core/oned/rss/RSS14Reader.ts on lines 404..409
                src/core/oned/rss/expanded/RSSExpandedReader.ts on lines 887..895
                src/core/oned/rss/expanded/RSSExpandedReader.ts on lines 902..910

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

                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

                There are no issues that match your filters.

                Category
                Status