zxing-js/library

View on GitHub
src/core/common/HybridBinarizer.ts

Summary

Maintainability
D
1 day
Test Coverage
A
98%

Function calculateBlackPoints has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
Open

    private static calculateBlackPoints(luminances: Uint8ClampedArray,
        subWidth: number /*int*/,
        subHeight: number /*int*/,
        width: number /*int*/,
        height: number /*int*/): Int32Array[] {
Severity: Minor
Found in src/core/common/HybridBinarizer.ts - About 1 day 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 calculateBlackPoints has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private static calculateBlackPoints(luminances: Uint8ClampedArray,
        subWidth: number /*int*/,
        subHeight: number /*int*/,
        width: number /*int*/,
        height: number /*int*/): Int32Array[] {
Severity: Major
Found in src/core/common/HybridBinarizer.ts - About 2 hrs to fix

    Function calculateThresholdForBlock has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        private static calculateThresholdForBlock(luminances: Uint8ClampedArray,
            subWidth: number /*int*/,
            subHeight: number /*int*/,
            width: number /*int*/,
            height: number /*int*/,
    Severity: Minor
    Found in src/core/common/HybridBinarizer.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

    Avoid deeply nested control flow statements.
    Open

                            if (pixel < min) {
                                min = pixel;
                            }
    Severity: Major
    Found in src/core/common/HybridBinarizer.ts - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              for (yy++ , offset += width; yy < HybridBinarizer.BLOCK_SIZE; yy++ , offset += width) {
                                  for (let xx = 0; xx < HybridBinarizer.BLOCK_SIZE; xx++) {
                                      sum += luminances[offset + xx] & 0xFF;
                                  }
                              }
      Severity: Major
      Found in src/core/common/HybridBinarizer.ts - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if (pixel > max) {
                                    max = pixel;
                                }
        Severity: Major
        Found in src/core/common/HybridBinarizer.ts - About 45 mins to fix

          Function getBlackMatrix has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public getBlackMatrix(): BitMatrix /*throws NotFoundException*/ {
                  if (this.matrix !== null) {
                      return this.matrix;
                  }
                  const source = this.getLuminanceSource();
          Severity: Minor
          Found in src/core/common/HybridBinarizer.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 deeply nested control flow statements.
          Open

                                  if (min < averageNeighborBlackPoint) {
                                      average = averageNeighborBlackPoint;
                                  }
          Severity: Major
          Found in src/core/common/HybridBinarizer.ts - About 45 mins to fix

            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

            There are no issues that match your filters.

            Category
            Status