eslint/babel-eslint-parser/src/analyze-scope.js
Function _visitTypeAnnotation
has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring. Open
Open
_visitTypeAnnotation(node) {
if (!node) {
return;
}
if (Array.isArray(node)) {
- Read upRead up
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
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";
Referencer
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
Open
class Referencer extends OriginalReferencer {
// inherits.
visitPattern(node, options, callback) {
if (!node) {
return;
Function _visitTypeAnnotation
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
_visitTypeAnnotation(node) {
if (!node) {
return;
}
if (Array.isArray(node)) {
Avoid deeply nested control flow statements. Open
Open
for (let k = 0; k < propertyType.values.length; k++) {
const loopPropertyNode = nodeProperty[j][propertyType.values[k]];
if (loopPropertyNode) {
this._checkIdentifierOrVisit(loopPropertyNode);
}
Avoid deeply nested control flow statements. Open
Open
if (node.id.type === "Identifier") {
this._checkIdentifierOrVisit(node.id);
} else {
this._visitTypeAnnotation(node.id);
}