packages/testing/src/specialized-assertions.ts
Function verifyBindingInstructionsEqual
has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring. Open
Open
export function verifyBindingInstructionsEqual(actual: any, expected: any, errors?: string[], path?: string): any {
if (path === undefined) {
path = 'instruction';
}
if (errors === undefined) {
- 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 verifyBindingInstructionsEqual
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function verifyBindingInstructionsEqual(actual: any, expected: any, errors?: string[], path?: string): any {
if (path === undefined) {
path = 'instruction';
}
if (errors === undefined) {
Function verifyEqual
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
Open
export function verifyEqual(actual: any, expected: any, depth?: number, property?: string, index?: number): any {
if (depth === undefined) {
depth = 0;
}
if (typeof expected !== 'object' || expected === null) {
- 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 instructionTypeName
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function instructionTypeName(type: string): string {
switch (type) {
case InstructionType.textBinding:
return 'textBinding';
case InstructionType.interpolation:
Function verifyEqual
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function verifyEqual(actual: any, expected: any, depth?: number, property?: string, index?: number): any {
if (depth === undefined) {
depth = 0;
}
if (typeof expected !== 'object' || expected === null) {
Avoid deeply nested control flow statements. Open
Open
if (typeof actual === 'object' && actual != null) {
actual = JSON.stringify(actual);
}
Avoid deeply nested control flow statements. Open
Open
if (typeof expected === 'object' && expected != null) {
expected = JSON.stringify(expected);
}
Avoid deeply nested control flow statements. Open
Open
for (const prop in actual) {
if (!seen[prop]) {
verifyBindingInstructionsEqual(actual[prop], expected[prop], errors, `${path}.${prop}`);
}
}
Avoid deeply nested control flow statements. Open
Open
if (String(expected).endsWith('unnamed') && /unnamed-\d+$/.test(String(actual))) {
errors.push(`OK : ${path} === ${expected} (${actual})`);
}
Avoid deeply nested control flow statements. Open
Open
for (const prop in expected) {
verifyBindingInstructionsEqual(actual[prop], expected[prop], errors, `${path}.${prop}`);
seen[prop] = true;
}
Avoid deeply nested control flow statements. Open
Open
if (actual.outerHTML !== expected['outerHTML']) {
errors.push(`WRONG: ${path}.outerHTML === ${actual.outerHTML} (expected: ${expected['outerHTML']})`);
} else {
errors.push(`OK : ${path}.outerHTML === ${expected}`);
}
Avoid deeply nested control flow statements. Open
Open
if (path.endsWith('type')) {
expected = instructionTypeName(expected);
actual = instructionTypeName(actual);
}
Avoid deeply nested control flow statements. Open
Open
for (let i = 0, ii = Math.max(expected.childNodes.length, actual.childNodes.length); i < ii; ++i) {
verifyBindingInstructionsEqual(actual.childNodes.item(i), expected.childNodes.item(i), errors, `${path}.childNodes[${i}]`);
}
Function verifyEqual
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
export function verifyEqual(actual: any, expected: any, depth?: number, property?: string, index?: number): any {