packages/babel-traverse/src/path/introspection.js

Summary

Maintainability
F
4 days
Test Coverage

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;

Severity: Minor
Found in packages/babel-traverse/src/path/introspection.js - About 6 hrs to fix

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";
Severity: Minor
Found in packages/babel-traverse/src/path/introspection.js - About 4 hrs to fix

    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 = {
    Severity: Major
    Found in packages/babel-traverse/src/path/introspection.js - About 2 hrs to fix

      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;
      Severity: Minor
      Found in packages/babel-traverse/src/path/introspection.js - About 2 hrs to fix

      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 = {
      Severity: Minor
      Found in packages/babel-traverse/src/path/introspection.js - About 2 hrs to fix

      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() ||
      Severity: Minor
      Found in packages/babel-traverse/src/path/introspection.js - About 1 hr to fix

      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;
      
      
      Severity: Minor
      Found in packages/babel-traverse/src/path/introspection.js - About 1 hr to fix

        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;
        Severity: Minor
        Found in packages/babel-traverse/src/path/introspection.js - About 1 hr to fix

        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;
        Severity: Minor
        Found in packages/babel-traverse/src/path/introspection.js - About 1 hr to fix

        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;
        Severity: Minor
        Found in packages/babel-traverse/src/path/introspection.js - About 1 hr to fix

          Function _guessExecutionStatusRelativeToDifferentFunctions has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function _guessExecutionStatusRelativeToDifferentFunctions(
            target: NodePath,
          ): RelativeExecutionStatus {
            if (
              !target.isFunctionDeclaration() ||
          Severity: Minor
          Found in packages/babel-traverse/src/path/introspection.js - About 1 hr to fix

            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":
            Severity: Minor
            Found in packages/babel-traverse/src/path/introspection.js - About 1 hr to fix

              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);
                  }
              Severity: Major
              Found in packages/babel-traverse/src/path/introspection.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                      for (const prop of (props: Array)) {
                        if (!prop.isProperty()) continue;
                
                        const key = prop.get("key");
                
                
                Severity: Major
                Found in packages/babel-traverse/src/path/introspection.js - About 45 mins to fix

                  Avoid too many return statements within this function.
                  Open

                        if (elem) return elem.resolve(dangerous, resolved);
                  Severity: Major
                  Found in packages/babel-traverse/src/path/introspection.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        return false;
                    Severity: Major
                    Found in packages/babel-traverse/src/path/introspection.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                          if (!t.isLiteral(targetKey)) return;
                      Severity: Major
                      Found in packages/babel-traverse/src/path/introspection.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                            return true;
                        Severity: Major
                        Found in packages/babel-traverse/src/path/introspection.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                            return allStatus;
                          Severity: Major
                          Found in packages/babel-traverse/src/path/introspection.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                return true;
                            Severity: Major
                            Found in packages/babel-traverse/src/path/introspection.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                  return divergence.target.key > divergence.this.key ? "before" : "after";
                              Severity: Major
                              Found in packages/babel-traverse/src/path/introspection.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                    if (binding.kind === "module") return;
                                Severity: Major
                                Found in packages/babel-traverse/src/path/introspection.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                        return false;
                                  Severity: Major
                                  Found in packages/babel-traverse/src/path/introspection.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                        return this.get("expression").resolve(dangerous, resolved);
                                    Severity: Major
                                    Found in packages/babel-traverse/src/path/introspection.js - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                        return false;
                                      Severity: Major
                                      Found in packages/babel-traverse/src/path/introspection.js - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                                if (match) return prop.get("value").resolve(dangerous, resolved);
                                        Severity: Major
                                        Found in packages/babel-traverse/src/path/introspection.js - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                              return this.get("argument").isConstantExpression();
                                          Severity: Major
                                          Found in packages/babel-traverse/src/path/introspection.js - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                              return keyPosition.target > keyPosition.this ? "before" : "after";
                                            Severity: Major
                                            Found in packages/babel-traverse/src/path/introspection.js - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                  return (
                                                    this.get("left").isConstantExpression() &&
                                                    this.get("right").isConstantExpression()
                                                  );
                                              Severity: Major
                                              Found in packages/babel-traverse/src/path/introspection.js - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                        return true;
                                                Severity: Major
                                                Found in packages/babel-traverse/src/path/introspection.js - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                      return true;
                                                  Severity: Major
                                                  Found in packages/babel-traverse/src/path/introspection.js - About 30 mins to fix

                                                    Avoid too many return statements within this function.
                                                    Open

                                                        return true;
                                                    Severity: Major
                                                    Found in packages/babel-traverse/src/path/introspection.js - About 30 mins to fix

                                                      Avoid too many return statements within this function.
                                                      Open

                                                        return false;
                                                      Severity: Major
                                                      Found in packages/babel-traverse/src/path/introspection.js - About 30 mins to fix

                                                        Avoid too many return statements within this function.
                                                        Open

                                                              if (this.find(parent => parent.node === ret.node)) return;
                                                        Severity: Major
                                                        Found in packages/babel-traverse/src/path/introspection.js - About 30 mins to fix

                                                          Avoid too many return statements within this function.
                                                          Open

                                                                return ret;
                                                          Severity: Major
                                                          Found in packages/babel-traverse/src/path/introspection.js - About 30 mins to fix

                                                            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 {
                                                            Severity: Minor
                                                            Found in packages/babel-traverse/src/path/introspection.js - About 25 mins to fix

                                                            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

                                                            There are no issues that match your filters.

                                                            Category
                                                            Status