zxing-js/library

View on GitHub

Showing 605 of 958 total issues

Function handleEOD has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  handleEOD(context: EncoderContext, buffer: StringBuilder): void {
    const unwritten = Math.floor((buffer.length() / 3) * 2);
    const rest = buffer.length() % 3;

    const curCodewordCount = context.getCodewordCount() + unwritten;
Severity: Minor
Found in src/core/datamatrix/encoder/C40Encoder.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 getC40Words has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  getC40Words(c40: boolean, fnc1: number): Uint8Array {
    const c40Values = [];
    for (let i = 0; i < this.characterLength; i++) {
      const ci = this.input.charAt(this.fromPosition + i);
      if (
Severity: Minor
Found in src/core/datamatrix/encoder/MinimalEncoder.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 transitionsBetween has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  private transitionsBetween(from: ResultPoint, to: ResultPoint): int {
    // See QR Code Detector, sizeOfBlackWhiteBlackRun()
    let fromX = Math.trunc(from.getX());
    let fromY = Math.trunc(from.getY());
    let toX = Math.trunc(to.getX());
Severity: Minor
Found in src/core/datamatrix/detector/Detector.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 adjustRowNumbersFromBothRI has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  private adjustRowNumbersFromBothRI(): void {
    if (this.detectionResultColumns[0] == null || this.detectionResultColumns[this.barcodeColumnCount + 1] == null) {
      return;
    }
    let LRIcodewords: Codeword[] = this.detectionResultColumns[0].getCodewords();
Severity: Minor
Found in src/core/pdf417/decoder/DetectionResult.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 findGuardPattern has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    static findGuardPattern(row: BitArray, rowOffset: number, whiteFirst: boolean, pattern: Int32Array, counters: Int32Array): Int32Array {
        let width = row.getSize();
        rowOffset = whiteFirst ? row.getNextUnset(rowOffset) : row.getNextSet(rowOffset);
        let counterPosition = 0;
        let patternStart = rowOffset;
Severity: Minor
Found in src/core/oned/AbstractUPCEANReader.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 readCodewords has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  readCodewords(): Int8Array {

    const result = new Int8Array(this.version.getTotalCodewords());
    let resultOffset = 0;

Severity: Major
Found in src/core/datamatrix/decoder/BitMatrixParser.ts - About 2 hrs to fix

    Function find has 56 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public find(): AlignmentPattern /*throws NotFoundException*/ {
            const startX = this.startX;
            const height = this.height;
            const width = this.width;
            const maxJ = startX + width;
    Severity: Major
    Found in src/core/qrcode/detector/AlignmentPatternFinder.ts - About 2 hrs to fix

      Function crossCheckDiagonal has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private crossCheckDiagonal(startI: number /*int*/, centerJ: number /*int*/, maxCount: number /*int*/, originalStateCountTotal: number /*int*/): boolean {
              const stateCount: Int32Array = this.getCrossCheckStateCount();
      
              // Start counting up, left from center finding black center mass
              let i = 0;
      Severity: Major
      Found in src/core/qrcode/detector/FinderPatternFinder.ts - About 2 hrs to fix

        Function correctBits has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private correctBits(rawbits: boolean[]): boolean[] {
                let gf: GenericGF;
                let codewordSize: number;
        
                if (this.ddata.getNbLayers() <= 2) {
        Severity: Major
        Found in src/core/aztec/decoder/Decoder.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 getC40Words has 54 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              getC40Words(c40: boolean, fnc1: number): Uint8Array {
                const c40Values = [];
                for (let i = 0; i < this.characterLength; i++) {
                  const ci = this.input.charAt(this.fromPosition + i);
                  if (
            Severity: Major
            Found in src/core/datamatrix/encoder/MinimalEncoder.ts - About 2 hrs to fix

              Function selectBestPatterns has 54 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private selectBestPatterns(): FinderPattern[] /*throws NotFoundException */ {
              
                      const startSize = this.possibleCenters.length;
                      if (startSize < 3) {
                          // Couldn't find enough finder patterns
              Severity: Major
              Found in src/core/qrcode/detector/FinderPatternFinder.ts - About 2 hrs to fix

                Function encode has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  public encode(context: EncoderContext) {
                    // step B
                    const n = HighLevelEncoder.determineConsecutiveDigitCount(
                      context.getMessage(),
                      context.pos
                Severity: Major
                Found in src/core/datamatrix/encoder/ASCIIEncoder.ts - About 2 hrs to fix

                  Function encodeHighLevel has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    public static encodeHighLevel(
                      msg: string,
                      shape = SymbolShapeHint.FORCE_NONE,
                      minSize: Dimension = null,
                      maxSize: Dimension = null,
                  Severity: Major
                  Found in src/core/datamatrix/encoder/HighLevelEncoder.ts - About 2 hrs to fix

                    Function crossCheckHorizontal has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private crossCheckHorizontal(startJ: number /*int*/, centerI: number /*int*/, maxCount: number /*int*/,
                            originalStateCountTotal: number /*int*/): number/*float*/ {
                            const image: BitMatrix = this.image;
                    
                            const maxJ = image.getWidth();
                    Severity: Major
                    Found in src/core/qrcode/detector/FinderPatternFinder.ts - About 2 hrs to fix

                      Function crossCheckVertical has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private crossCheckVertical(startI: number /*int*/, centerJ: number /*int*/, maxCount: number /*int*/,
                              originalStateCountTotal: number /*int*/): number/*float*/ {
                              const image: BitMatrix = this.image;
                      
                              const maxI = image.getHeight();
                      Severity: Major
                      Found in src/core/qrcode/detector/FinderPatternFinder.ts - About 2 hrs to fix

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

                          static decode(codewords: Int32Array, ecLevel: string): DecoderResult {
                            // pass encoding to result (will be used for decode symbols in byte mode)
                            let result: StringBuilder = new StringBuilder('');
                            // let encoding: Charset = StandardCharsets.ISO_8859_1;
                            let encoding = CharacterSetECI.ISO8859_1;
                        Severity: Major
                        Found in src/core/pdf417/decoder/DecodedBitStreamParser.ts - About 2 hrs to fix

                          File Encoder.ts has 254 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          import BitArray from '../../common/BitArray';
                          import IllegalArgumentException from '../../IllegalArgumentException';
                          import StringUtils from '../../common/StringUtils';
                          import BitMatrix from '../../common/BitMatrix';
                          import AztecCode from './AztecCode';
                          Severity: Minor
                          Found in src/core/aztec/encoder/Encoder.ts - About 2 hrs to fix

                            Function extractDataRegion has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                            Open

                              private extractDataRegion(bitMatrix: BitMatrix): BitMatrix {
                                const symbolSizeRows = this.version.getSymbolSizeRows();
                                const symbolSizeColumns = this.version.getSymbolSizeColumns();
                            
                                if (bitMatrix.getHeight() !== symbolSizeRows) {
                            Severity: Minor
                            Found in src/core/datamatrix/decoder/BitMatrixParser.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 decodeAnsiX12Segment has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                            Open

                              private static decodeAnsiX12Segment(bits: BitSource,
                                                                       result: StringBuilder): void {
                                // Three ANSI X12 values are encoded in a 16-bit value as
                                // (1600 * C1) + (40 * C2) + C3 + 1
                            
                            
                            Severity: Minor
                            Found in src/core/datamatrix/decoder/DecodedBitStreamParser.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

                            Severity
                            Category
                            Status
                            Source
                            Language