Function _evaluate
has a Cognitive Complexity of 131 (exceeds 5 allowed). Consider refactoring. Open
function _evaluate(path, state) {
if (!state.confident) return;
const { node } = path;
- 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 _evaluate
has 263 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _evaluate(path, state) {
if (!state.confident) return;
const { node } = path;
File evaluation.js
has 326 lines of code (exceeds 250 allowed). Consider refactoring. Open
import type NodePath from "./index";
// This file contains Babels metainterpreter that can evaluate static code.
const VALID_CALLEES = ["String", "Number", "Math"];
Consider simplifying this complex logical expression. Open
if (path.isLogicalExpression()) {
// If we are confident that the left side of an && is false, or the left
// side of an || is true, we can be confident about the entire expression
const wasConfident = state.confident;
const left = evaluateCached(path.get("left"), state);
Function evaluateQuasis
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function evaluateQuasis(path, quasis: Array<Object>, state, raw = false) {
let str = "";
let i = 0;
const exprs = path.get("expressions");
- 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 evaluateCached
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function evaluateCached(path, state) {
const { node } = path;
const { seen } = state;
if (seen.has(node)) {
- 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 deopt(path, state);
Avoid too many return
statements within this function. Open
return "function";
Avoid too many return
statements within this function. Open
return binding ? deopt(binding.path, state) : Infinity;
Avoid too many return
statements within this function. Open
return undefined;
Avoid too many return
statements within this function. Open
return deopt(elem, state);
Avoid too many return
statements within this function. Open
return evaluateCached(path.get("consequent"), state);
Avoid too many return
statements within this function. Open
return deopt(prop, state);
Avoid too many return
statements within this function. Open
if (!state.confident) return;
Avoid too many return
statements within this function. Open
return func.apply(context, args);
Avoid too many return
statements within this function. Open
return evaluateCached(resolved, state);
Avoid too many return
statements within this function. Open
return left || right;
Avoid too many return
statements within this function. Open
return deopt(binding.path, state);
Avoid too many return
statements within this function. Open
if (!state.confident) return;
Avoid too many return
statements within this function. Open
return deopt(binding.path, state);
Avoid too many return
statements within this function. Open
return evaluateCached(path.get("expression"), state);
Avoid too many return
statements within this function. Open
return binding ? deopt(binding.path, state) : undefined;
Avoid too many return
statements within this function. Open
return obj;
Avoid too many return
statements within this function. Open
if (!state.confident) return;
Avoid too many return
statements within this function. Open
return arr;
Avoid too many return
statements within this function. Open
if (!state.confident) return;
Avoid too many return
statements within this function. Open
return deopt(valuePath, state);
Avoid too many return
statements within this function. Open
if (!state.confident) return;
Avoid too many return
statements within this function. Open
return evaluateQuasis(path, node.quasi.quasis, state, true);
Avoid too many return
statements within this function. Open
if (!state.confident) return;
Avoid too many return
statements within this function. Open
return evaluateCached(path.get("alternate"), state);
Avoid too many return
statements within this function. Open
return binding ? deopt(binding.path, state) : NaN;
Avoid too many return
statements within this function. Open
return deopt(keyPath, state);
Avoid too many return
statements within this function. Open
return left && right;
Avoid too many return
statements within this function. Open
return evaluateQuasis(path, node.quasis, state);
Avoid too many return
statements within this function. Open
if (!state.confident) return;
Avoid too many return
statements within this function. Open
return value[property.node.name];
Avoid too many return
statements within this function. Open
return binding.value;