File findExports.js
has 354 lines of code (exceeds 250 allowed). Consider refactoring. Open
import fs from 'fs';
import path from 'path';
import requireRelative from 'require-relative';
Function findCommonJSExports
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
function findCommonJSExports(
node,
{ definedNames, absolutePathToFile, aliasesForExports },
) {
if (node.type !== 'ExpressionStatement') {
- 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 findExports
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function findExports(data, absolutePathToFile) {
if (/\.json$/.test(absolutePathToFile)) {
return {
named: Object.keys(JSON.parse(data)),
typed: [],
Consider simplifying this complex logical expression. Open
if (
node.expression.type === 'CallExpression' &&
node.expression.callee.type === 'MemberExpression' &&
node.expression.callee.object.name === 'Object' &&
node.expression.callee.property.name === 'defineProperty' &&
Function resolveNestedNamedExports
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function resolveNestedNamedExports(node, absolutePathToFile) {
if (node.type === 'ConditionalExpression') {
// Potential ternary-style export - we pick the first one
// module.exports = foo ? require('a') : require('b');
return resolveNestedNamedExports(node.consequent, absolutePathToFile);
Function findDefinedNames
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function findDefinedNames(node, definedNames) {
if (node.type === 'ExpressionStatement') {
const { left, right } = node.expression;
if (left && right) {
if (left.object) {
- 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 (
node.expression.type === 'CallExpression' &&
node.expression.callee.type === 'MemberExpression' &&
aliasesForExports.has(node.expression.callee.object.name) &&
node.expression.callee.property.name === 'use' &&
Function findESNamedExports
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function findESNamedExports(node, { absolutePathToFile }) {
if (node.type === 'ExportAllDeclaration') {
// Recurse the file referenced by the declaration
// eslint-disable-next-line no-use-before-define
return resolveNestedNamedExports(node, absolutePathToFile);
- 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
return definedNames[right.name] || [];
Avoid too many return
statements within this function. Open
return left.object.name === 'module' && left.property.name === 'exports';
Avoid too many return
statements within this function. Open
return [];
Avoid too many return
statements within this function. Open
return false;
Avoid too many return
statements within this function. Open
return result;
Avoid too many return
statements within this function. Open
return nestedNamed;
Avoid too many return
statements within this function. Open
return [left.property.name];
Avoid too many return
statements within this function. Open
return [left.property.name];
Avoid too many return
statements within this function. Open
return right.properties.map(({ key }) => key.name).filter(Boolean);
Avoid too many return
statements within this function. Open
return result;
Avoid too many return
statements within this function. Open
return [node.declaration.id.name];
Avoid too many return
statements within this function. Open
return [];