Function _resolve
has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring. Open
export function _resolve(dangerous?, resolved?): ?NodePath {
// detect infinite recursion
// todo: possibly have a max length on this just to be safe
if (resolved && resolved.indexOf(this) >= 0) 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
File introspection.js
has 336 lines of code (exceeds 250 allowed). Consider refactoring. Open
// This file contains methods responsible for introspecting the current path for certain values.
import type NodePath from "./index";
import includes from "lodash/includes";
import * as t from "@babel/types";
Function _guessExecutionStatusRelativeTo
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function _guessExecutionStatusRelativeTo(
target: NodePath,
): RelativeExecutionStatus {
// check if the two paths are in different functions, we can't track execution of these
const funcParent = {
Function isInStrictMode
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
export function isInStrictMode() {
const start = this.isProgram() ? this : this.parentPath;
const strictParent = start.find(path => {
if (path.isProgram({ sourceType: "module" })) return true;
- 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 _guessExecutionStatusRelativeTo
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
export function _guessExecutionStatusRelativeTo(
target: NodePath,
): RelativeExecutionStatus {
// check if the two paths are in different functions, we can't track execution of these
const funcParent = {
- 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 _guessExecutionStatusRelativeToDifferentFunctions
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
export function _guessExecutionStatusRelativeToDifferentFunctions(
target: NodePath,
): RelativeExecutionStatus {
if (
!target.isFunctionDeclaration() ||
- 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 _resolve
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function _resolve(dangerous?, resolved?): ?NodePath {
// detect infinite recursion
// todo: possibly have a max length on this just to be safe
if (resolved && resolved.indexOf(this) >= 0) return;
Function isConstantExpression
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
export function isConstantExpression() {
if (this.isIdentifier()) {
const binding = this.scope.getBinding(this.node.name);
if (!binding) return false;
return binding.constant;
- 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 referencesImport
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export function referencesImport(moduleSource, importName) {
if (!this.isReferencedIdentifier()) return false;
const binding = this.scope.getBinding(this.node.name);
if (!binding || binding.kind !== "module") return false;
- 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 isConstantExpression
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function isConstantExpression() {
if (this.isIdentifier()) {
const binding = this.scope.getBinding(this.node.name);
if (!binding) return false;
return binding.constant;
Function _guessExecutionStatusRelativeToDifferentFunctions
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function _guessExecutionStatusRelativeToDifferentFunctions(
target: NodePath,
): RelativeExecutionStatus {
if (
!target.isFunctionDeclaration() ||
Function isExecutionUncertain
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function isExecutionUncertain(type, key) {
switch (type) {
// a && FOO
// a || FOO
case "LogicalExpression":
Avoid deeply nested control flow statements. Open
} else if (target.isArrayExpression() && !isNaN(+targetName)) {
const elems = target.get("elements");
const elem = elems[targetName];
if (elem) return elem.resolve(dangerous, resolved);
}
Avoid deeply nested control flow statements. Open
for (const prop of (props: Array)) {
if (!prop.isProperty()) continue;
const key = prop.get("key");
Avoid too many return
statements within this function. Open
if (elem) return elem.resolve(dangerous, resolved);
Avoid too many return
statements within this function. Open
return false;
Avoid too many return
statements within this function. Open
if (!t.isLiteral(targetKey)) return;
Avoid too many return
statements within this function. Open
return true;
Avoid too many return
statements within this function. Open
return allStatus;
Avoid too many return
statements within this function. Open
return true;
Avoid too many return
statements within this function. Open
return divergence.target.key > divergence.this.key ? "before" : "after";
Avoid too many return
statements within this function. Open
if (binding.kind === "module") return;
Avoid too many return
statements within this function. Open
return false;
Avoid too many return
statements within this function. Open
return this.get("expression").resolve(dangerous, resolved);
Avoid too many return
statements within this function. Open
return false;
Avoid too many return
statements within this function. Open
if (match) return prop.get("value").resolve(dangerous, resolved);
Avoid too many return
statements within this function. Open
return this.get("argument").isConstantExpression();
Avoid too many return
statements within this function. Open
return keyPosition.target > keyPosition.this ? "before" : "after";
Avoid too many return
statements within this function. Open
return (
this.get("left").isConstantExpression() &&
this.get("right").isConstantExpression()
);
Avoid too many return
statements within this function. Open
return true;
Avoid too many return
statements within this function. Open
return true;
Avoid too many return
statements within this function. Open
return true;
Avoid too many return
statements within this function. Open
return false;
Avoid too many return
statements within this function. Open
if (this.find(parent => parent.node === ret.node)) return;
Avoid too many return
statements within this function. Open
return ret;
Function isCompletionRecord
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export function isCompletionRecord(allowInsideFunction?) {
let path = this;
let first = true;
do {
- 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"