zxing-js/library

View on GitHub

Showing 958 of 958 total issues

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

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

  private constructor_1( image: BitMatrix,
               topLeft: ResultPoint,
               bottomLeft: ResultPoint,
               topRight: ResultPoint,
               bottomRight: ResultPoint)  {
Severity: Minor
Found in src/core/pdf417/decoder/BoundingBox.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 findErrorLocations has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private findErrorLocations(errorLocator: GenericGFPoly): Int32Array /*throws ReedSolomonException*/ {
        // This is a direct application of Chien's search
        const numErrors = errorLocator.getDegree();
        if (numErrors === 1) { // shortcut
            return Int32Array.from([errorLocator.getCoefficient(1)]);
Severity: Minor
Found in src/core/common/reedsolomon/ReedSolomonDecoder.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 constructor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  public constructor(size?: number /*int*/, bits?: Int32Array) {
    if (undefined === size) {
      this.size = 0;
      this.bits = new Int32Array(1);
    } else {
Severity: Minor
Found in src/core/common/BitArray.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 thresholdBlock has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static thresholdBlock(luminances: Uint8ClampedArray,
        xoffset: number /*int*/,
        yoffset: number /*int*/,
        threshold: number /*int*/,
        stride: number /*int*/,
Severity: Minor
Found in src/core/common/HybridBinarizer.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 setRegion has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public setRegion(left: number /*int*/, top: number /*int*/, width: number /*int*/, height: number /*int*/): void {
        if (top < 0 || left < 0) {
            throw new IllegalArgumentException('Left and top must be nonnegative');
        }
        if (height < 1 || width < 1) {
Severity: Minor
Found in src/core/common/BitMatrix.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 verifyCodewordCount has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  private static verifyCodewordCount(codewords: Int32Array, numECCodewords: int): void {
    if (codewords.length < 4) {
      // Codeword array size should be at least 4 allowing for
      // Count CW, At least one Data CW, Error Correction CW, Error Correction CW
      throw FormatException.getFormatInstance();
Severity: Minor
Found in src/core/pdf417/decoder/PDF417ScanningDecoder.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 getBitCountForCodeword has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  private static getBitCountForCodeword(codeword: int): Int32Array {
    let result: Int32Array = new Int32Array(8);
    let previousValue: int = 0;
    let i: int = result.length - 1;
    while (true) {
Severity: Minor
Found in src/core/pdf417/decoder/PDF417ScanningDecoder.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