@packages/jest-runner-rollup/src/runner.js
Function jestRunnerRollup
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
Open
module.exports = async function jestRunnerRollup({ testPath, config }) {
const start = new Date();
/** Load config from possible places */
const cfg = await tryLoadConfig({ testPath, config, start });
- 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
File runner.js
has 273 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
const fs = require('fs');
const path = require('path');
const crypto = require('crypto');
const builtins = require('builtin-modules');
Function tryLoadConfig
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
Open
async function tryLoadConfig({ testPath, config: jestConfig, start }) {
const cfg = await tryCatch(testPath, start, () => {
let result = null;
result = jestRunnerConfig.search();
- 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
Open
if (
// if `jest-runner.config.js` not found
!result ||
// or found
(result && // but // the `rollup` property is not an object
Avoid too many return
statements within this function. Open
Open
if (res.hasError) return res.error;
Avoid too many return
statements within this function. Open
Open
return res;
Avoid too many return
statements within this function. Open
Open
return ret;