zxing-js/library

View on GitHub
src/core/oned/rss/expanded/RSSExpandedReader.ts

Summary

Maintainability
F
1 wk
Test Coverage
F
12%

File RSSExpandedReader.ts has 749 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import BarcodeFormat from '../../../BarcodeFormat';
// import ResultPoint from '../../../ResultPoint';
import BitArray from '../../../common/BitArray';
import MathUtils from '../../../common/detector/MathUtils';
import DecodeHintType from '../../../DecodeHintType';
Severity: Major
Found in src/core/oned/rss/expanded/RSSExpandedReader.ts - About 1 day to fix

    Function adjustOddEvenCounts has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
    Open

      private adjustOddEvenCounts(numModules) {
        let oddSum = MathUtils.sum(new Int32Array(this.getOddCounts()));
        let evenSum = MathUtils.sum(new Int32Array(this.getEvenCounts()));
    
        let incrementOdd = false;
    Severity: Minor
    Found in src/core/oned/rss/expanded/RSSExpandedReader.ts - About 7 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 findNextPair has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

      private findNextPair(
        row: BitArray,
        previousPairs: Array<ExpandedPair>,
        forcedOffset: number
      ): void {
    Severity: Minor
    Found in src/core/oned/rss/expanded/RSSExpandedReader.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 adjustOddEvenCounts has 93 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      private adjustOddEvenCounts(numModules) {
        let oddSum = MathUtils.sum(new Int32Array(this.getOddCounts()));
        let evenSum = MathUtils.sum(new Int32Array(this.getEvenCounts()));
    
        let incrementOdd = false;
    Severity: Major
    Found in src/core/oned/rss/expanded/RSSExpandedReader.ts - About 3 hrs to fix

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

        decodeDataCharacter(
          row: BitArray,
          pattern: FinderPattern,
          isOddPattern: boolean,
          leftChar: boolean
      Severity: Major
      Found in src/core/oned/rss/expanded/RSSExpandedReader.ts - About 3 hrs to fix

        Function decodeRow2pairs has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

          decodeRow2pairs(rowNumber: number, row: BitArray): Array<ExpandedPair> {
            let done = false;
            while (!done) {
              try {
                this.pairs.push(this.retrieveNextPair(row, this.pairs, rowNumber));
        Severity: Minor
        Found in src/core/oned/rss/expanded/RSSExpandedReader.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 findNextPair has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          private findNextPair(
            row: BitArray,
            previousPairs: Array<ExpandedPair>,
            forcedOffset: number
          ): void {
        Severity: Major
        Found in src/core/oned/rss/expanded/RSSExpandedReader.ts - About 2 hrs to fix

          RSSExpandedReader has 21 functions (exceeds 20 allowed). Consider refactoring.
          Open

          export default class RSSExpandedReader extends AbstractRSSReader {
            private static readonly SYMBOL_WIDEST = [7, 5, 4, 3, 1];
            private static readonly EVEN_TOTAL_SUBSET = [4, 20, 52, 104, 204];
            private static readonly GSUM = [0, 348, 1388, 2948, 3988];
          
          
          Severity: Minor
          Found in src/core/oned/rss/expanded/RSSExpandedReader.ts - About 2 hrs to fix

            Function isPartialRow has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              private static isPartialRow(pairs: any, rows: any): boolean {
                for (let r of rows) {
                  let allFound = true;
                  for (let p of pairs) {
                    let found = false;
            Severity: Minor
            Found in src/core/oned/rss/expanded/RSSExpandedReader.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 removePartialRows has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              private removePartialRows(
                pairs: Array<ExpandedPair>,
                rows: Array<ExpandedRow>
              ): void {
                // for (Iterator<ExpandedRow> iterator = rows.iterator(); iterator.hasNext();) {
            Severity: Minor
            Found in src/core/oned/rss/expanded/RSSExpandedReader.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 retrieveNextPair has 34 lines of code (exceeds 25 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 1 hr to fix

              Function decodeRow2pairs has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                decodeRow2pairs(rowNumber: number, row: BitArray): Array<ExpandedPair> {
                  let done = false;
                  while (!done) {
                    try {
                      this.pairs.push(this.retrieveNextPair(row, this.pairs, rowNumber));
              Severity: Minor
              Found in src/core/oned/rss/expanded/RSSExpandedReader.ts - About 1 hr to fix

                Function parseFoundFinderPattern has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  private parseFoundFinderPattern(
                    row: BitArray,
                    rowNumber: number,
                    oddPattern: boolean
                  ): FinderPattern {
                Severity: Minor
                Found in src/core/oned/rss/expanded/RSSExpandedReader.ts - About 1 hr to fix

                  Function checkRows has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    private checkRows(
                      collectedRows: any,
                      currentRow: number
                    ): Array<ExpandedPair> {
                      for (let i = currentRow; i < this.rows.length; i++) {
                  Severity: Minor
                  Found in src/core/oned/rss/expanded/RSSExpandedReader.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 isValidSequence has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    private static isValidSequence(pairs: Array<ExpandedPair>): boolean {
                      for (let sequence of RSSExpandedReader.FINDER_PATTERN_SEQUENCES) {
                        if (pairs.length > sequence.length) {
                          continue;
                        }
                  Severity: Minor
                  Found in src/core/oned/rss/expanded/RSSExpandedReader.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 (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

                            if (evenParityBad) {
                              throw new NotFoundException();
                            }
                    Severity: Major
                    Found in src/core/oned/rss/expanded/RSSExpandedReader.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 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 storeRow has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                          private storeRow(rowNumber: number, wasReversed: boolean): void {
                            // Discard if duplicate above or below; otherwise insert in order by row number.
                            let insertPos = 0;
                            let prevIsSame = false;
                            let nextIsSame = false;
                        Severity: Minor
                        Found in src/core/oned/rss/expanded/RSSExpandedReader.ts - About 25 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

                        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/expanded/RSSExpandedReader.ts and 1 other location - About 1 day to fix
                        src/core/oned/rss/RSS14Reader.ts on lines 354..402

                        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

                        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/expanded/RSSExpandedReader.ts and 1 other location - About 2 hrs to fix
                        src/core/oned/rss/RSS14Reader.ts on lines 161..165

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 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

                              if ((i & 0x01) === 0) {
                                oddCounts[offset] = count;
                                oddRoundingErrors[offset] = value - count;
                              } else {
                                evenCounts[offset] = count;
                        Severity: Major
                        Found in src/core/oned/rss/expanded/RSSExpandedReader.ts and 1 other location - About 1 hr to fix
                        src/core/oned/rss/RSS14Reader.ts on lines 185..191

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

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

                        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 (incrementOdd) {
                              if (decrementOdd) {
                                throw new NotFoundException();
                              }
                              RSSExpandedReader.increment(
                        Severity: Major
                        Found in src/core/oned/rss/expanded/RSSExpandedReader.ts and 3 other locations - About 35 mins to fix
                        src/core/oned/rss/RSS14Reader.ts on lines 404..409
                        src/core/oned/rss/RSS14Reader.ts on lines 413..418
                        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