specs/debug-console/logger.ts
Function formatTestSummary
has a Cognitive Complexity of 28 (exceeds 15 allowed). Consider refactoring. Open
Open
function formatTestSummary(text: string): string {
if (!text.includes('\n')) {
return '';
}
- 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 formatSnapshotMessage
has a Cognitive Complexity of 18 (exceeds 15 allowed). Consider refactoring. Open
Open
function formatSnapshotMessage(text: string): string {
if (text.endsWith('updated.') || text.endsWith('written.') || text.endsWith('removed.')) {
return bold(green(text));
}
- 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 too many return
statements within this function. Open
Open
return formatSnapshotSummary(text, 'written', green);
Avoid too many return
statements within this function. Open
Open
return `${formatSnapshotSummary(text, 'failed', red)} ${darkGray(
'Inspect your code changes or re-run jest with `JEST_RUNNER_UPDATE_SNAPSHOTS=true` to update them.'
)}`;
Avoid too many return
statements within this function. Open
Open
return formatSnapshotSummary(text, 'removed', green);
Avoid too many return
statements within this function. Open
Open
return ` ↳ ${darkGray(`${testPath}/`)}${bold(testFilename)}`;
Avoid too many return
statements within this function. Open
Open
return '';
Avoid too many return
statements within this function. Open
Open
return '';
Avoid too many return
statements within this function. Open
Open
return formatSnapshotSummary(text, 'updated', green);
Avoid too many return
statements within this function. Open
Open
return ` ${bold(
green(`› ${numSnapshots} snapshot ${Number(numSnapshots) > 1 ? 'files' : 'file'} removed`)
)} from ${numTestSuites} ${Number(numTestSuites) > 1 ? 'test suites' : 'test suite'}.`;
Avoid too many return
statements within this function. Open
Open
return `${formatSnapshotSummary(text, 'obsolete', yellow)} ${darkGray(
'To remove them all, re-run jest with `JEST_RUNNER_UPDATE_SNAPSHOTS=true`.'
)}`;