packages/babel-traverse/src/path/lib/hoister.js

Summary

Maintainability
C
1 day
Test Coverage

Function getAttachmentPath has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

  getAttachmentPath() {
    let path = this._getAttachmentPath();
    if (!path) return;

    let targetScope = path.scope;
Severity: Minor
Found in packages/babel-traverse/src/path/lib/hoister.js - About 3 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 _getAttachmentPath has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  _getAttachmentPath() {
    const scopes = this.scopes;

    const scope = scopes.pop();
    // deopt: no compatible scopes
Severity: Minor
Found in packages/babel-traverse/src/path/lib/hoister.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 ReferencedIdentifier has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  ReferencedIdentifier(path, state) {
    // Don't hoist regular JSX identifiers ('div', 'span', etc).
    // We do have to consider member expressions for hoisting (e.g. `this.component`)
    if (
      path.isJSXIdentifier() &&
Severity: Minor
Found in packages/babel-traverse/src/path/lib/hoister.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 ReferencedIdentifier has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  ReferencedIdentifier(path, state) {
    // Don't hoist regular JSX identifiers ('div', 'span', etc).
    // We do have to consider member expressions for hoisting (e.g. `this.component`)
    if (
      path.isJSXIdentifier() &&
Severity: Minor
Found in packages/babel-traverse/src/path/lib/hoister.js - About 1 hr to fix

    Function getAttachmentPath has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      getAttachmentPath() {
        let path = this._getAttachmentPath();
        if (!path) return;
    
        let targetScope = path.scope;
    Severity: Minor
    Found in packages/babel-traverse/src/path/lib/hoister.js - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                  if (this.getAttachmentParentForPath(violationPath).key > path.key) {
                    path = violationPath;
                  }
      Severity: Major
      Found in packages/babel-traverse/src/path/lib/hoister.js - About 45 mins to fix

        Function run has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          run() {
            this.path.traverse(referenceVisitor, this);
        
            if (this.mutableBinding) return;
        
        
        Severity: Minor
        Found in packages/babel-traverse/src/path/lib/hoister.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 this.getNextScopeAttachmentParent();
        Severity: Major
        Found in packages/babel-traverse/src/path/lib/hoister.js - About 30 mins to fix

          Function getCompatibleScopes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            getCompatibleScopes() {
              let scope = this.path.scope;
              do {
                if (this.isCompatibleScope(scope)) {
                  this.scopes.push(scope);
          Severity: Minor
          Found in packages/babel-traverse/src/path/lib/hoister.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