zxing-js/library

View on GitHub

Showing 605 of 958 total issues

Avoid too many return statements within this function.
Open

          return FieldParser.processVariableAI(4, <number>dataLength[2], rawInformation);
Severity: Major
Found in src/core/oned/rss/expanded/decoders/FieldParser.ts - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

              return FieldParser.processVariableAI(4, <number>dataLength[2], rawInformation);
    Severity: Major
    Found in src/core/oned/rss/expanded/decoders/FieldParser.ts - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return FieldParser.processFixedAI(4, <number>dataLength[1], rawInformation);
      Severity: Major
      Found in src/core/oned/rss/expanded/decoders/FieldParser.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

          Function encodeToCodewords has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            private encodeToCodewords(sb: string): string {
              const len = sb.length;
              if (len === 0) {
                throw new Error('StringBuilder must not be empty');
              }
          Severity: Minor
          Found in src/core/datamatrix/encoder/EdifactEncoder.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

          Function getVersionForDimensions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            public static getVersionForDimensions(numRows: number, numColumns: number): Version {
              if ((numRows & 0x01) !== 0 || (numColumns & 0x01) !== 0) {
                throw new FormatException();
              }
          
          
          Severity: Minor
          Found in src/core/datamatrix/decoder/Version.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

          Function encode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            public encode(context: EncoderContext) {
              // step F
              const buffer = new StringBuilder();
              while (context.hasMoreCharacters()) {
                const c = context.getCurrentChar();
          Severity: Minor
          Found in src/core/datamatrix/encoder/EdifactEncoder.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

          Function encode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            public encode(context: EncoderContext) {
              // step C
              const buffer = new StringBuilder();
              while (context.hasMoreCharacters()) {
                const c = context.getCurrentChar();
          Severity: Minor
          Found in src/core/datamatrix/encoder/X12Encoder.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

          Function getRow has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              public getRow(y: number /*int*/, row: Uint8ClampedArray): Uint8ClampedArray {
                  if (y < 0 || y >= this.getHeight()) {
                      throw new IllegalArgumentException('Requested row is outside the image: ' + y);
                  }
                  const width: number /*int*/ = this.getWidth();
          Severity: Minor
          Found in src/browser/HTMLCanvasElementLuminanceSource.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

          Function decodeKanjiSegment has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            private static decodeKanjiSegment(bits: BitSource,
              result: StringBuilder,
              count: number /*int*/): void /*throws FormatException*/ {
              // Don't crash trying to read more bits than we have available.
              if (count * 13 > bits.available()) {
          Severity: Minor
          Found in src/core/qrcode/decoder/DecodedBitStreamParser.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

          Function getBitValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            private static getBitValue(moduleBitCount: Int32Array): int {
              let result: /*long*/ number = 0;
              for (let /*int*/ i = 0; i < moduleBitCount.length; i++) {
                for (/*int*/ let bit = 0; bit < moduleBitCount[i]; bit++) {
                  result = (result << 1) | (i % 2 === 0 ? 1 : 0);
          Severity: Minor
          Found in src/core/pdf417/decoder/PDF417CodewordDecoder.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

          Function decodeHanziSegment has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            private static decodeHanziSegment(bits: BitSource,
              result: StringBuilder,
              count: number /*int*/): void /*throws FormatException*/ {
              // Don't crash trying to read more bits than we have available.
              if (count * 13 > bits.available()) {
          Severity: Minor
          Found in src/core/qrcode/decoder/DecodedBitStreamParser.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

          Function toString has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              public toString(): string {
                  const result = new StringBuilder(); // (2 * width * height + 2)
                  for (let y = 0, height = this.height; y < height; ++y) {
                      const bytesY = this.bytes[y];
                      for (let x = 0, width = this.width; x < width; ++x) {
          Severity: Minor
          Found in src/core/qrcode/encoder/ByteMatrix.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

          Function correctTopRight has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            private correctTopRight(points: ResultPoint[]): ResultPoint {
              // A..D
              // |  :
              // B--C
              let pointA = points[0];
          Severity: Minor
          Found in src/core/datamatrix/detector/Detector.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

          Function applyMaskPenaltyRule4 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              public static applyMaskPenaltyRule4(matrix: ByteMatrix): number /*int*/ {
                  let numDarkCells = 0;
                  const array: Array<Uint8Array> = matrix.getArray();
                  const width: number /*int*/ = matrix.getWidth();
                  const height: number /*int*/ = matrix.getHeight();
          Severity: Minor
          Found in src/core/qrcode/encoder/MaskUtil.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

          Function decodeVersionInformation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              public static decodeVersionInformation(versionBits: number /*int*/): Version {
                  let bestDifference = Number.MAX_SAFE_INTEGER;
                  let bestVersion = 0;
                  for (let i = 0; i < Version.VERSION_DECODE_INFO.length; i++) {
                      const targetVersion = Version.VERSION_DECODE_INFO[i];
          Severity: Minor
          Found in src/core/qrcode/decoder/Version.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

          Function mirror has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              public mirror(): void {
                  const bitMatrix = this.bitMatrix;
                  for (let x = 0, width = bitMatrix.getWidth(); x < width; x++) {
                      for (let y = x + 1, height = bitMatrix.getHeight(); y < height; y++) {
                          if (bitMatrix.get(x, y) !== bitMatrix.get(y, x)) {
          Severity: Minor
          Found in src/core/qrcode/decoder/BitMatrixParser.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

          Function getNumDataBytesAndNumECBytesForBlockID has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              public static getNumDataBytesAndNumECBytesForBlockID(numTotalBytes: number /*int*/,
                  numDataBytes: number /*int*/,
                  numRSBlocks: number /*int*/,
                  blockID: number /*int*/,
                  numDataBytesInBlock: Int32Array,
          Severity: Minor
          Found in src/core/qrcode/encoder/Encoder.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

          Function binarySearch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            public static binarySearch(ar: Int32Array, el: number, comparator?: (a: number, b: number) => number): number {
              if (undefined === comparator) {
                comparator = Arrays.numberComparator;
              }
              let m = 0;
          Severity: Minor
          Found in src/core/util/Arrays.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

          Function unmaskBitMatrix has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            public unmaskBitMatrix(bits: BitMatrix, dimension: number /*int*/): void {
              for (let i = 0; i < dimension; i++) {
                for (let j = 0; j < dimension; j++) {
                  if (this.isMasked(i, j)) {
                    bits.flip(j, i);
          Severity: Minor
          Found in src/core/qrcode/decoder/DataMask.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

          Severity
          Category
          Status
          Source
          Language