Function applyMaskPenaltyRule1Internal
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
private static applyMaskPenaltyRule1Internal(matrix: ByteMatrix, isHorizontal: boolean): number /*int*/ {
let penalty = 0;
const iLimit = isHorizontal ? matrix.getHeight() : matrix.getWidth();
const jLimit = isHorizontal ? matrix.getWidth() : matrix.getHeight();
const array: Array<Uint8Array> = matrix.getArray();
- 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
Consider simplifying this complex logical expression. Open
if (x + 6 < width &&
arrayY[x] === 1 &&
arrayY[x + 1] === 0 &&
arrayY[x + 2] === 1 &&
arrayY[x + 3] === 1 &&
Consider simplifying this complex logical expression. Open
if (y + 6 < height &&
array[y][x] === 1 &&
array[y + 1][x] === 0 &&
array[y + 2][x] === 1 &&
array[y + 3][x] === 1 &&
Function applyMaskPenaltyRule3
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public static applyMaskPenaltyRule3(matrix: ByteMatrix): number /*int*/ {
let numPenalties = 0;
const array: Array<Uint8Array> = matrix.getArray();
const width: number /*int*/ = matrix.getWidth();
const height: number /*int*/ = matrix.getHeight();
- 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 getDataMaskBit
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static getDataMaskBit(maskPattern: number /*int*/, x: number /*int*/, y: number /*int*/): boolean {
let intermediate: number; /*int*/
let temp: number; /*int*/
switch (maskPattern) {
case 0:
Function applyMaskPenaltyRule3
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static applyMaskPenaltyRule3(matrix: ByteMatrix): number /*int*/ {
let numPenalties = 0;
const array: Array<Uint8Array> = matrix.getArray();
const width: number /*int*/ = matrix.getWidth();
const height: number /*int*/ = matrix.getHeight();
Function applyMaskPenaltyRule2
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static applyMaskPenaltyRule2(matrix: ByteMatrix): number /*int*/ {
let penalty = 0;
const array: Array<Uint8Array> = matrix.getArray();
const width: number /*int*/ = matrix.getWidth();
const height: number /*int*/ = matrix.getHeight();
- 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 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();
- 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"