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[] {
- Read upRead up
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[] {
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*/,
- Read upRead up
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;
}
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;
}
}
Avoid deeply nested control flow statements. Open
if (pixel > max) {
max = pixel;
}
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();
- Read upRead up
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;
}
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*/,
- Read upRead up
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"