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

Summary

Maintainability
F
6 days
Test Coverage

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;

Severity: Minor
Found in packages/babel-traverse/src/path/evaluation.js - About 2 days 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 _evaluate has 263 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function _evaluate(path, state) {
  if (!state.confident) return;

  const { node } = path;

Severity: Major
Found in packages/babel-traverse/src/path/evaluation.js - About 1 day to fix

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

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

        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");
        Severity: Minor
        Found in packages/babel-traverse/src/path/evaluation.js - About 45 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

        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)) {
        Severity: Minor
        Found in packages/babel-traverse/src/path/evaluation.js - About 35 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

        Avoid too many return statements within this function.
        Open

                return deopt(path, state);
        Severity: Major
        Found in packages/babel-traverse/src/path/evaluation.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

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

            Avoid too many return statements within this function.
            Open

                    return binding ? deopt(binding.path, state) : Infinity;
            Severity: Major
            Found in packages/babel-traverse/src/path/evaluation.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

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

                Avoid too many return statements within this function.
                Open

                        return deopt(elem, state);
                Severity: Major
                Found in packages/babel-traverse/src/path/evaluation.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                        return evaluateCached(path.get("consequent"), state);
                  Severity: Major
                  Found in packages/babel-traverse/src/path/evaluation.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return deopt(prop, state);
                    Severity: Major
                    Found in packages/babel-traverse/src/path/evaluation.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                            if (!state.confident) return;
                      Severity: Major
                      Found in packages/babel-traverse/src/path/evaluation.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                              return func.apply(context, args);
                        Severity: Major
                        Found in packages/babel-traverse/src/path/evaluation.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return evaluateCached(resolved, state);
                          Severity: Major
                          Found in packages/babel-traverse/src/path/evaluation.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                    return left || right;
                            Severity: Major
                            Found in packages/babel-traverse/src/path/evaluation.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                    return deopt(binding.path, state);
                              Severity: Major
                              Found in packages/babel-traverse/src/path/evaluation.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                    if (!state.confident) return;
                                Severity: Major
                                Found in packages/babel-traverse/src/path/evaluation.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                        return deopt(binding.path, state);
                                  Severity: Major
                                  Found in packages/babel-traverse/src/path/evaluation.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                        return evaluateCached(path.get("expression"), state);
                                    Severity: Major
                                    Found in packages/babel-traverse/src/path/evaluation.js - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                              return binding ? deopt(binding.path, state) : undefined;
                                      Severity: Major
                                      Found in packages/babel-traverse/src/path/evaluation.js - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

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

                                          Avoid too many return statements within this function.
                                          Open

                                              if (!state.confident) return;
                                          Severity: Major
                                          Found in packages/babel-traverse/src/path/evaluation.js - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

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

                                              Avoid too many return statements within this function.
                                              Open

                                                      if (!state.confident) return;
                                              Severity: Major
                                              Found in packages/babel-traverse/src/path/evaluation.js - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                        return deopt(valuePath, state);
                                                Severity: Major
                                                Found in packages/babel-traverse/src/path/evaluation.js - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                          if (!state.confident) return;
                                                  Severity: Major
                                                  Found in packages/babel-traverse/src/path/evaluation.js - About 30 mins to fix

                                                    Avoid too many return statements within this function.
                                                    Open

                                                          return evaluateQuasis(path, node.quasi.quasis, state, true);
                                                    Severity: Major
                                                    Found in packages/babel-traverse/src/path/evaluation.js - About 30 mins to fix

                                                      Avoid too many return statements within this function.
                                                      Open

                                                          if (!state.confident) return;
                                                      Severity: Major
                                                      Found in packages/babel-traverse/src/path/evaluation.js - About 30 mins to fix

                                                        Avoid too many return statements within this function.
                                                        Open

                                                              return evaluateCached(path.get("alternate"), state);
                                                        Severity: Major
                                                        Found in packages/babel-traverse/src/path/evaluation.js - About 30 mins to fix

                                                          Avoid too many return statements within this function.
                                                          Open

                                                                  return binding ? deopt(binding.path, state) : NaN;
                                                          Severity: Major
                                                          Found in packages/babel-traverse/src/path/evaluation.js - About 30 mins to fix

                                                            Avoid too many return statements within this function.
                                                            Open

                                                                      return deopt(keyPath, state);
                                                            Severity: Major
                                                            Found in packages/babel-traverse/src/path/evaluation.js - About 30 mins to fix

                                                              Avoid too many return statements within this function.
                                                              Open

                                                                      return left && right;
                                                              Severity: Major
                                                              Found in packages/babel-traverse/src/path/evaluation.js - About 30 mins to fix

                                                                Avoid too many return statements within this function.
                                                                Open

                                                                    return evaluateQuasis(path, node.quasis, state);
                                                                Severity: Major
                                                                Found in packages/babel-traverse/src/path/evaluation.js - About 30 mins to fix

                                                                  Avoid too many return statements within this function.
                                                                  Open

                                                                      if (!state.confident) return;
                                                                  Severity: Major
                                                                  Found in packages/babel-traverse/src/path/evaluation.js - About 30 mins to fix

                                                                    Avoid too many return statements within this function.
                                                                    Open

                                                                            return value[property.node.name];
                                                                    Severity: Major
                                                                    Found in packages/babel-traverse/src/path/evaluation.js - About 30 mins to fix

                                                                      Avoid too many return statements within this function.
                                                                      Open

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

                                                                        There are no issues that match your filters.

                                                                        Category
                                                                        Status