Showing 101 of 125 total issues
Function traverseReturns
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function traverseReturns(ASTNode, context, enterFunc) {
const nodeType = ASTNode.type;
if (nodeType === 'ReturnStatement') {
return enterFunc(ASTNode);
Function sorter
has 28 lines of code (exceeds 25 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) {
Function list
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
list() {
const thisList = Lists.get(this);
const list = {};
const usedPropTypes = {};
Function getPropertyName
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getPropertyName(node, context, utils, checkAsyncSafeLifeCycles) {
const property = node.property;
if (property) {
switch (property.type) {
case 'Identifier':
Function MemberExpression
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
MemberExpression(node) {
const isDefaultProp = propsUtil.isDefaultPropsDeclaration(node);
if (!isDefaultProp) {
return;
Consider simplifying this complex logical expression. Open
if (
(ancestor.type !== 'Property' && ancestor.type !== 'MethodDefinition' && ancestor.type !== 'ClassProperty' && ancestor.type !== 'PropertyDefinition')
|| !nameMatches(ancestor.key.name)
|| (mode !== 'disallow-in-func' && depth > 1)
) {
Consider simplifying this complex logical expression. Open
if (
value
&& value.type === 'CallExpression'
&& value.callee
&& value.callee.property
Function isPropTypesUsageByMemberExpression
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function isPropTypesUsageByMemberExpression(node, context, utils, checkAsyncSafeLifeCycles) {
const unwrappedObjectNode = ast.unwrapTSAsExpression(node.object);
if (isInClassComponent(utils)) {
// 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, checkAsyncSafeLifeCycles) {
let scope = context.getScope();
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 fixPropTypesSort
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
function fixPropTypesSort(fixer, context, declarations, ignoreCase, requiredFirst, callbacksLast, sortShapeProp) {
Function getReactVersionFromContext
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function getReactVersionFromContext(context) {
let confVer = '999.999.999';
// .eslintrc shared settings (https://eslint.org/docs/user-guide/configuring#adding-shared-settings)
if (context.settings && context.settings.react && context.settings.react.version) {
let settingsVersion = context.settings.react.version;
- 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 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function sorter(a, b, context, ignoreCase, requiredFirst, callbacksLast) {
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 getFlowVersionFromContext
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function getFlowVersionFromContext(context) {
let confVer = '999.999.999';
// .eslintrc shared settings (https://eslint.org/docs/user-guide/configuring#adding-shared-settings)
if (context.settings.react && context.settings.react.flowVersion) {
let flowVersion = context.settings.react.flowVersion;
- 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
Consider simplifying this complex logical expression. Open
if (
unwrappedParentCalleeNode
&& unwrappedParentCalleeNode.property
&& unwrappedParentCalleeNode.property.name === 'setState'
// Make sure we are in the updater not the callback
Consider simplifying this complex logical expression. Open
if (node.type === 'FunctionExpression' || node.type === 'ArrowFunctionExpression') {
const isMethod = parent.type === 'Property' && parent.method;
const isPropertyAssignment = parent.type === 'AssignmentExpression'
&& parent.left.type === 'MemberExpression';
const isModuleExportsAssignment = isPropertyAssignment
Consider simplifying this complex logical expression. Open
if (((n.type === 'AssignmentExpression') && propsUtil.isPropTypesDeclaration(n.left))
|| ((n.type === 'ClassProperty' || n.type === 'PropertyDefinition' || n.type === 'Property') && propsUtil.isPropTypesDeclaration(n))) {
// Found a propType used inside of another propType. This is not considered usage, we'll still validate
// this component.
isUsedInPropTypes = true;
Function isReturningJSX
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function isReturningJSX(isCreateElement, ASTnode, context, strict, ignoreNull) {
Function detectReactVersion
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function detectReactVersion(context) {
if (cachedDetectedReactVersion) {
return cachedDetectedReactVersion;
}
- 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"