zxing-js/library

View on GitHub
src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.ts

Summary

Maintainability
F
4 days
Test Coverage
F
10%

File GeneralAppIdDecoder.ts has 373 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import BitArray from '../../../../common/BitArray';
import FormatException from '../../../../FormatException';
import IllegalStateException from '../../../../IllegalStateException';
import StringBuilder from '../../../../util/StringBuilder';
import BlockParsedResult from './BlockParsedResult';
Severity: Minor
Found in src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.ts - About 4 hrs to fix

    Function decodeIsoIec646 has 84 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      private decodeIsoIec646(pos: number): DecodedChar {
        let fiveBitValue = this.extractNumericValueFromBitArray(pos, 5);
        if (fiveBitValue === 15) {
          return new DecodedChar(pos + 5, DecodedChar.FNC1);
        }
    Severity: Major
    Found in src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.ts - About 3 hrs to fix

      Function decodeAlphanumeric has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        private decodeAlphanumeric(pos: number): DecodedChar {
          let fiveBitValue = this.extractNumericValueFromBitArray(pos, 5);
          if (fiveBitValue === 15) {
            return new DecodedChar(pos + 5, DecodedChar.FNC1);
          }
      Severity: Minor
      Found in src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.ts - About 1 hr to fix

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

          private parseNumericBlock(): BlockParsedResult {
            while (this.isStillNumeric(this.current.getPosition())) {
              let numeric: DecodedNumeric = this.decodeNumeric(this.current.getPosition());
              this.current.setPosition(numeric.getNewPosition());
        
        
        Severity: Minor
        Found in src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.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 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 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 parseBlocks has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          private parseBlocks(): DecodedInformation {
            let isFinished: boolean;
            let result: BlockParsedResult;
            do {
              let initialPosition = this.current.getPosition();
        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

        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 too many return statements within this function.
        Open

            return new DecodedChar(pos + 8, c);
        Severity: Major
        Found in src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return eightBitValue >= 232 && eightBitValue < 253;
          Severity: Major
          Found in src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                  return false;
            Severity: Major
            Found in src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.ts - About 30 mins to fix

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

                  if (this.isAlphaOr646ToNumericLatch(this.current.getPosition())) {
                    this.current.incrementPosition(3);
                    this.current.setNumeric();
                  } else if (this.isAlphaTo646ToAlphaLatch(this.current.getPosition())) {
                    if (this.current.getPosition() + 5 < this.information.getSize()) {
              Severity: Major
              Found in src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.ts and 1 other location - About 7 hrs to fix
              src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.ts on lines 178..189

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

              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 (this.isAlphaOr646ToNumericLatch(this.current.getPosition())) {
                    this.current.incrementPosition(3);
                    this.current.setNumeric();
                  } else if (this.isAlphaTo646ToAlphaLatch(this.current.getPosition())) {
                    if (this.current.getPosition() + 5 < this.information.getSize()) {
              Severity: Major
              Found in src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.ts and 1 other location - About 7 hrs to fix
              src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.ts on lines 206..217

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

              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 (numeric.isSecondDigitFNC1()) {
                      let information = new DecodedInformation(this.current.getPosition(), this.buffer.toString());
                      return new BlockParsedResult(true, information);
                    }
              Severity: Major
              Found in src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.ts and 1 other location - About 1 hr to fix
              src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.ts on lines 171..174

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

              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 (iso.isFNC1()) {
                      let information = new DecodedInformation(this.current.getPosition(), this.buffer.toString());
                      return new BlockParsedResult(true, information);
                    }
              Severity: Major
              Found in src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.ts and 1 other location - About 1 hr to fix
              src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.ts on lines 152..155

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

              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 = pos; i < pos + 3; ++i) {
                    if (this.information.get(i)) {
                      return false;
                    }
                  }
              Severity: Minor
              Found in src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.ts and 1 other location - About 40 mins to fix
              src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.ts on lines 53..57

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

              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 = pos; i < pos + 3; ++i) {
                    if (this.information.get(i)) {
                      return true;
                    }
                  }
              Severity: Minor
              Found in src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.ts and 1 other location - About 40 mins to fix
              src/core/oned/rss/expanded/decoders/GeneralAppIdDecoder.ts on lines 423..427

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

              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