zxing-js/library

View on GitHub

Showing 958 of 958 total issues

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

    public decodeMiddle(row: BitArray, startRange: Int32Array, resultString: string) {
        let counters = this.decodeMiddleCounters;
        counters[0] = 0;
        counters[1] = 0;
        counters[2] = 0;
Severity: Minor
Found in src/core/oned/UPCEANExtension5Support.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

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

  public appendTo(bitArray: BitArray, text: /*byte[]*/ Uint8Array): void {
    for (let i = 0; i < this.binaryShiftByteCount; i++) {
      if (i === 0 || (i === 31 && this.binaryShiftByteCount <= 62)) {
        // We need a header before the first character, and before
        // character 31 when the total byte code is <= 62
Severity: Minor
Found in src/core/aztec/encoder/BinaryShiftToken.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 decodeAlphanumericSegment has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  private static decodeAlphanumericSegment(bits: BitSource,
    result: StringBuilder,
    count: number /*int*/,
    fc1InEffect: boolean): void /*throws FormatException*/ {
    // Read two characters at a time
Severity: Minor
Found in src/core/qrcode/decoder/DecodedBitStreamParser.ts - About 1 hr to fix

    Function readFormatInformation has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public readFormatInformation(): FormatInformation /*throws FormatException*/ {
    
            if (this.parsedFormatInfo !== null && this.parsedFormatInfo !== undefined) {
                return this.parsedFormatInfo;
            }
    Severity: Minor
    Found in src/core/qrcode/decoder/BitMatrixParser.ts - About 1 hr to fix

      Function orderBestPatterns has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static orderBestPatterns(patterns: Array<ResultPoint>): void {
      
              // Find distances between pattern centers
              const zeroOneDistance = this.distance(patterns[0], patterns[1]);
              const oneTwoDistance = this.distance(patterns[1], patterns[2]);
      Severity: Minor
      Found in src/core/ResultPoint.ts - About 1 hr to fix

        Function getBlackMatrix has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public getBlackMatrix(): BitMatrix /*throws NotFoundException*/ {
                const source = this.getLuminanceSource();
                const width = source.getWidth();
                const height = source.getHeight();
                const matrix = new BitMatrix(width, height);
        Severity: Minor
        Found in src/core/common/GlobalHistogramBinarizer.ts - About 1 hr to fix

          Function adjustBoundingBox has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            private static adjustBoundingBox(rowIndicatorColumn: DetectionResultRowIndicatorColumn): BoundingBox {
              if (rowIndicatorColumn == null) {
                return null;
              }
              let rowHeights: Int32Array = rowIndicatorColumn.getRowHeights();
          Severity: Minor
          Found in src/core/pdf417/decoder/PDF417ScanningDecoder.ts - About 1 hr to fix

            Function decode has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public decode(received: Int32Array, twoS: number /*int*/): void /*throws ReedSolomonException*/ {
                    const field = this.field;
                    const poly = new GenericGFPoly(field, received);
                    const syndromeCoefficients = new Int32Array(twoS);
                    let noError: boolean = true;
            Severity: Minor
            Found in src/core/common/reedsolomon/ReedSolomonDecoder.ts - About 1 hr to fix

              Function encodeCompressedDate has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                private encodeCompressedDate(buf: StringBuilder, currentPos: number): void {
                  let numericDate = this.getGeneralDecoder().extractNumericValueFromBitArray(
                    currentPos,
                    AI013x0x1xDecoder.DATE_SIZE
                  );
              Severity: Minor
              Found in src/core/oned/rss/expanded/decoders/AI013x0x1xDecoder.ts - About 1 hr to fix

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

                    if (c <= '@'.charCodeAt(0)) {
                      sb.append(0o1); // Shift 2 Set
                      sb.append(c - 58 + 15);
                      return 2;
                    }
                Severity: Major
                Found in src/core/datamatrix/encoder/C40Encoder.ts and 3 other locations - About 1 hr to fix
                src/core/datamatrix/encoder/C40Encoder.ts on lines 226..230
                src/core/datamatrix/encoder/TextEncoder.ts on lines 34..38
                src/core/datamatrix/encoder/TextEncoder.ts on lines 49..53

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

                    if (c <= '_'.charCodeAt(0)) {
                      sb.append(0o1); // Shift 2 Set
                      sb.append(c - 91 + 22);
                      return 2;
                    }
                Severity: Major
                Found in src/core/datamatrix/encoder/C40Encoder.ts and 3 other locations - About 1 hr to fix
                src/core/datamatrix/encoder/C40Encoder.ts on lines 221..225
                src/core/datamatrix/encoder/TextEncoder.ts on lines 34..38
                src/core/datamatrix/encoder/TextEncoder.ts on lines 49..53

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

                    if (c <= '@'.charCodeAt(0)) {
                      sb.append(0o1); // Shift 2 Set
                      sb.append(c - 58 + 15);
                      return 2;
                    }
                Severity: Major
                Found in src/core/datamatrix/encoder/TextEncoder.ts and 3 other locations - About 1 hr to fix
                src/core/datamatrix/encoder/C40Encoder.ts on lines 221..225
                src/core/datamatrix/encoder/C40Encoder.ts on lines 226..230
                src/core/datamatrix/encoder/TextEncoder.ts on lines 49..53

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

                    if (c <= 'Z'.charCodeAt(0)) {
                      sb.append(0o2); // Shift 3 Set
                      sb.append(c - 65 + 1);
                      return 2;
                    }
                Severity: Major
                Found in src/core/datamatrix/encoder/TextEncoder.ts and 3 other locations - About 1 hr to fix
                src/core/datamatrix/encoder/C40Encoder.ts on lines 221..225
                src/core/datamatrix/encoder/C40Encoder.ts on lines 226..230
                src/core/datamatrix/encoder/TextEncoder.ts on lines 34..38

                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 (
                        minSize != null &&
                        (symbol.getSymbolWidth() < minSize.getWidth() ||
                          symbol.getSymbolHeight() < minSize.getHeight())
                      ) {
                Severity: Major
                Found in src/core/datamatrix/encoder/SymbolInfo.ts and 1 other location - About 1 hr to fix
                src/core/datamatrix/encoder/SymbolInfo.ts on lines 40..46

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

                  for (let c: int = aUpperCharCode; c <= zUpperCharCode; c++) {
                    CHAR_MAP[C.MODE_UPPER][c] = c - aUpperCharCode + 2;
                  }
                Severity: Major
                Found in src/core/aztec/encoder/CharMap.ts and 2 other locations - About 1 hr to fix
                src/core/aztec/encoder/CharMap.ts on lines 21..23
                src/core/aztec/encoder/CharMap.ts on lines 27..29

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

                  for (let c: int = aLowerCharCode; c <= zLowerCharCode; c++) {
                    CHAR_MAP[C.MODE_LOWER][c] = c - aLowerCharCode + 2;
                  }
                Severity: Major
                Found in src/core/aztec/encoder/CharMap.ts and 2 other locations - About 1 hr to fix
                src/core/aztec/encoder/CharMap.ts on lines 15..17
                src/core/aztec/encoder/CharMap.ts on lines 27..29

                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 (row === this.numrows - 2 && col === 0 && this.numcols % 4 !== 0) {
                        this.corner2(pos++);
                      }
                Severity: Major
                Found in src/core/datamatrix/encoder/DefaultPlacement.ts and 1 other location - About 1 hr to fix
                src/core/datamatrix/encoder/DefaultPlacement.ts on lines 62..64

                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 (
                        maxSize != null &&
                        (symbol.getSymbolWidth() > maxSize.getWidth() ||
                          symbol.getSymbolHeight() > maxSize.getHeight())
                      ) {
                Severity: Major
                Found in src/core/datamatrix/encoder/SymbolInfo.ts and 1 other location - About 1 hr to fix
                src/core/datamatrix/encoder/SymbolInfo.ts on lines 33..39

                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 (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

                Severity
                Category
                Status
                Source
                Language