twada/espower

View on GitHub
lib/instrumentor.js

Summary

Maintainability
D
1 day
Test Coverage

Function createVisitor has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

  createVisitor (ast) {
    verifyAstPrerequisites(ast, this.options);
    const that = this;
    let assertionVisitor;
    const storage = {};
Severity: Minor
Found in lib/instrumentor.js - About 5 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 createVisitor has 93 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  createVisitor (ast) {
    verifyAstPrerequisites(ast, this.options);
    const that = this;
    let assertionVisitor;
    const storage = {};
Severity: Major
Found in lib/instrumentor.js - About 3 hrs to fix

    Function leave has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          leave: function (currentNode, parentNode) {
            try {
              const controller = this;
              const path = controller.path();
              const espath = path ? path.join('/') : '';
    Severity: Minor
    Found in lib/instrumentor.js - About 1 hr to fix

      Function enter has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            enter: function (currentNode, parentNode) {
              if (/Function/.test(currentNode.type)) {
                scopeStack.push(scopeManager.acquire(currentNode));
              }
              const controller = this;
      Severity: Minor
      Found in lib/instrumentor.js - About 1 hr to fix

        Avoid too many return statements within this function.
        Open

                    return assertionVisitor.leaveArgument(controller);
        Severity: Major
        Found in lib/instrumentor.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return undefined;
          Severity: Major
          Found in lib/instrumentor.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return undefined;
            Severity: Major
            Found in lib/instrumentor.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return assertionVisitor.captureNode(controller);
              Severity: Major
              Found in lib/instrumentor.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                          return undefined;
                Severity: Major
                Found in lib/instrumentor.js - About 30 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status