Showing 101 of 125 total issues
Function makeNoMethodSetStateRule
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function makeNoMethodSetStateRule(methodName, shouldCheckUnsafeCb) {
return {
meta: {
docs: {
description: `Prevent usage of setState in ${methodName}`,
Function getStatelessComponent
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
getStatelessComponent(node) {
const parent = node.parent;
if (
node.type === 'FunctionDeclaration'
&& (!node.id || isFirstLetterCapitalized(node.id.name))
Function findReturnStatement
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
function findReturnStatement(node) {
if (
(!node.value || !node.value.body || !node.value.body.body)
&& (!node.body || !node.body.body)
) {
- 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 isReturningJSX
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
function isReturningJSX(isCreateElement, ASTnode, context, strict, ignoreNull) {
let found = false;
astUtil.traverseReturns(ASTnode, context, (node) => {
// Traverse return statement
astUtil.traverse(node, {
Function isReactHookCall
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
isReactHookCall(node, expectedHookNames) {
if (node.type !== 'CallExpression') {
return false;
}
File ast.js
has 257 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* @fileoverview Utility functions for AST
*/
'use strict';
Function isDestructuredFromPragmaImport
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function isDestructuredFromPragmaImport(variable, context) {
const pragma = pragmaUtil.getFromContext(context);
const variables = variableUtil.variablesInScope(context);
const variableInScope = variableUtil.getVariable(variables, variable);
if (variableInScope) {
Function searchDeclarationByName
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
searchDeclarationByName(node) {
let typeName;
if (astUtil.isTSTypeReference(node)) {
typeName = node.typeName.name;
const leftMostName = getLeftMostTypeName(node.typeName);
Function makeNoMethodSetStateRule
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function makeNoMethodSetStateRule(methodName, shouldCheckUnsafeCb) {
return {
meta: {
docs: {
description: `Prevent usage of setState in ${methodName}`,
- 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 enter
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
enter(childNode) {
const setFound = () => {
found = true;
this.skip();
};
Function create
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
create(context) {
const mode = context.options[0] || 'allow-in-func';
function nameMatches(name) {
if (name === methodName) {
Consider simplifying this complex logical expression. Open
if (
node.parent
&& node.parent.callee
&& node.parent.typeParameters
&& node.parent.typeParameters.params
Function sorter
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function sorter(a, b, context, ignoreCase, requiredFirst, callbacksLast) {
const aKey = String(astUtil.getKeyValue(context, a));
const bKey = String(astUtil.getKeyValue(context, b));
if (requiredFirst) {
- 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 ObjectTypeAnnotation
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
ObjectTypeAnnotation(annotation, parentName, seen) {
let containsUnresolvedObjectTypeSpread = false;
let containsSpread = false;
const containsIndexers = Boolean(annotation.indexers && annotation.indexers.length);
const shapeTypeDefinition = {
Function fixPropTypesSort
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function fixPropTypesSort(fixer, context, declarations, ignoreCase, requiredFirst, callbacksLast, sortShapeProp) {
function sortInSource(allNodes, source) {
const originalSource = source;
const nodeGroups = allNodes.reduce((acc, curr) => {
if (curr.type === 'ExperimentalSpreadProperty' || curr.type === 'SpreadElement') {
Function isReturningOnlyNull
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function isReturningOnlyNull(isCreateElement, ASTnode, context) {
let found = false;
let foundSomethingElse = false;
astUtil.traverseReturns(ASTnode, context, (node) => {
// Traverse return statement
Function VariableDeclarator
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
VariableDeclarator(node) {
const unwrappedInitNode = ast.unwrapTSAsExpression(node.init);
// let props = this.props
if (isThisDotProps(unwrappedInitNode) && isInClassComponent(utils) && node.id.type === 'Identifier') {
Function CallExpression
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
CallExpression(node) {
if (shouldBeNoop(context, methodName)) {
return;
}
Function resolveBasedir
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function resolveBasedir(contextOrFilename) {
if (contextOrFilename) {
const filename = typeof contextOrFilename === 'string' ? contextOrFilename : contextOrFilename.getFilename();
const dirname = path.dirname(filename);
try {
- 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 sortInSource
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function sortInSource(allNodes, source) {
const originalSource = source;
const nodeGroups = allNodes.reduce((acc, curr) => {
if (curr.type === 'ExperimentalSpreadProperty' || curr.type === 'SpreadElement') {
acc.push([]);