eslint/babel-eslint-parser/src/analyze-scope.js

Summary

Maintainability
D
1 day
Test Coverage

Function _visitTypeAnnotation has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

  _visitTypeAnnotation(node) {
    if (!node) {
      return;
    }
    if (Array.isArray(node)) {
Severity: Minor
Found in eslint/babel-eslint-parser/src/analyze-scope.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 analyze-scope.js has 266 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { types as t } from "@babel/core";
import escope from "eslint-scope";
import { Definition } from "eslint-scope/lib/definition";
import OriginalPatternVisitor from "eslint-scope/lib/pattern-visitor";
import OriginalReferencer from "eslint-scope/lib/referencer";
Severity: Minor
Found in eslint/babel-eslint-parser/src/analyze-scope.js - About 2 hrs to fix

    Referencer has 21 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Referencer extends OriginalReferencer {
      // inherits.
      visitPattern(node, options, callback) {
        if (!node) {
          return;
    Severity: Minor
    Found in eslint/babel-eslint-parser/src/analyze-scope.js - About 2 hrs to fix

      Function _visitTypeAnnotation has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _visitTypeAnnotation(node) {
          if (!node) {
            return;
          }
          if (Array.isArray(node)) {
      Severity: Minor
      Found in eslint/babel-eslint-parser/src/analyze-scope.js - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                    for (let k = 0; k < propertyType.values.length; k++) {
                      const loopPropertyNode = nodeProperty[j][propertyType.values[k]];
                      if (loopPropertyNode) {
                        this._checkIdentifierOrVisit(loopPropertyNode);
                      }
        Severity: Major
        Found in eslint/babel-eslint-parser/src/analyze-scope.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                  if (node.id.type === "Identifier") {
                    this._checkIdentifierOrVisit(node.id);
                  } else {
                    this._visitTypeAnnotation(node.id);
                  }
          Severity: Major
          Found in eslint/babel-eslint-parser/src/analyze-scope.js - About 45 mins to fix

            There are no issues that match your filters.

            Category
            Status