Showing 502 of 700 total issues
Consider simplifying this complex logical expression. Open
if (
relatedComponent
&& (componentUtil.isES6Component(relatedComponent.node, context) || (
relatedComponent.node.type !== 'ClassDeclaration' && utils.isReturningJSX(relatedComponent.node)))
&& (node.parent && node.parent.type === 'AssignmentExpression' && node.parent.right)
Function loopNodes
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function loopNodes(nodes) {
for (let i = nodes.length - 1; i >= 0; i--) {
if (nodes[i].type === 'ReturnStatement') {
return nodes[i];
}
- 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
Function isPropTypesUsageByMemberExpression
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function isPropTypesUsageByMemberExpression(context, node, utils, checkAsyncSafeLifeCycles) {
const unwrappedObjectNode = ast.unwrapTSAsExpression(node.object);
if (isInClassComponent(context, node)) {
// this.props.*
- 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
Function inLifeCycleMethod
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function inLifeCycleMethod(context, node, checkAsyncSafeLifeCycles) {
let scope = getScope(context, node);
while (scope) {
if (scope.block && scope.block.parent && scope.block.parent.key) {
const name = scope.block.parent.key.name;
- 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
Function checkAttribute
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function checkAttribute(context, node) {
const attribute = node.name.name;
const parentNodeName = node.parent.name.name;
if (!COMPONENT_ATTRIBUTE_MAP.has(attribute) || !COMPONENT_ATTRIBUTE_MAP.get(attribute).has(parentNodeName)) {
- 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
Function create
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
create(context) {
return {
CallExpression(node) {
if (isCreateElement(context, node) && node.arguments.length > 0 && node.arguments[0].type === 'Literal') {
const name = node.arguments[0].value;
- 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
Function validateReservedFirstConfig
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function validateReservedFirstConfig(context, reservedFirst) {
if (reservedFirst) {
if (Array.isArray(reservedFirst)) {
// Only allow a subset of reserved words in customized lists
const nonReservedWords = reservedFirst.filter((word) => !isReservedPropName(
- 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
Function sorter
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
function sorter(a, b, context, ignoreCase, requiredFirst, callbacksLast, noSortAlphabetically) {
Avoid deeply nested control flow statements. Open
if (name) {
classInfo.aliases.add(name);
} else if (prop.value.type === 'ObjectPattern') {
handleStateDestructuring(prop.value);
}
Avoid deeply nested control flow statements. Open
if (returnTypeFunction.length === 0) {
// Cannot find identifier in current scope. It might be an exported type.
this.shouldIgnorePropTypes = true;
return;
}
Avoid deeply nested control flow statements. Open
if (isFunctionType(func)) {
let res = func.body;
if (res.type === 'BlockStatement') {
res = astUtil.findReturnStatement(func);
if (res) {
Function getKeyValue
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function getKeyValue(context, node) {
if (node.type === 'ObjectTypeProperty') {
const tokens = getFirstTokens(context, node, 2);
return (tokens[0].value === '+' || tokens[0].value === '-'
? tokens[1].value
- 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
Avoid deeply nested control flow statements. Open
if (!siblings.has(lastValue)) {
const message = secondValue ? messages.notPaired : messages.notAlone;
const messageId = secondValue ? 'notPaired' : 'notAlone';
report(context, message, messageId, {
node,
Avoid deeply nested control flow statements. Open
if (c === entities[j]) {
report(context, messages.unescapedEntity, 'unescapedEntity', {
node,
loc: { line: i, column: start + index },
data: {
Avoid deeply nested control flow statements. Open
} else if (c === entities[j].char) {
report(context, messages.unescapedEntityAlts, 'unescapedEntityAlts', {
node,
loc: { line: i, column: start + index },
data: {
Function validateAfterOpening
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function validateAfterOpening(context, node, option) {
const sourceCode = getSourceCode(context);
const openingToken = sourceCode.getTokenBefore(node.name);
if (option === 'allow-multiline') {
- 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
Avoid deeply nested control flow statements. Open
if (attributeline + 1 === commentline && nextAttribute) {
attributeMap.set(attribute, { end: nextAttribute.range[1], hasComment: true });
addtoSortableAttributeGroups(attribute);
i += 1;
} else if (attributeline === commentline) {
Avoid deeply nested control flow statements. Open
if (typeof relAttribute.value.expression.value === 'string') {
const parts = relAttribute.value.expression.value
.split('noreferrer')
.filter(Boolean);
return fixer.replaceText(relAttribute.value.expression, `"${parts.concat('noreferrer').join(' ')}"`);
Avoid deeply nested control flow statements. Open
} else if (comment.length > 1 && attributeline + 1 === comment[1].loc.start.line && nextAttribute) {
const commentNextAttribute = sourceCode.getCommentsAfter(nextAttribute);
attributeMap.set(attribute, { end: nextAttribute.range[1], hasComment: true });
if (
commentNextAttribute.length === 1
Function validateBeforeSelfClosing
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function validateBeforeSelfClosing(context, node, option) {
const sourceCode = getSourceCode(context);
const leftToken = getTokenBeforeClosingBracket(node);
const closingSlash = sourceCode.getTokenAfter(leftToken);
- 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"