lib/rules/boolean-prop-naming.js
Function create
has 258 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
create: Components.detect((context, components, utils) => {
const config = context.options[0] || {};
const rule = config.rule ? new RegExp(config.rule) : null;
const propTypeNames = config.propTypeNames || ['bool'];
Function create
has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring. Open
Open
create: Components.detect((context, components, utils) => {
const config = context.options[0] || {};
const rule = config.rule ? new RegExp(config.rule) : null;
const propTypeNames = config.propTypeNames || ['bool'];
- 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 boolean-prop-naming.js
has 309 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
/**
* @fileoverview Enforces consistent naming for boolean props
* @author Ev Haus
*/
Function Program:exit
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
'Program:exit'() {
if (!rule) {
return;
}
Function getComponentTypeAnnotation
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function getComponentTypeAnnotation(component) {
// If this is a functional component that uses a global type, check it
if (
(component.node.type === 'FunctionDeclaration' || component.node.type === 'ArrowFunctionExpression')
&& component.node.params
Function findAllTypeAnnotations
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function findAllTypeAnnotations(identifier, node) {
if (node.type === 'TSTypeLiteral' || node.type === 'ObjectTypeAnnotation' || node.type === 'TSInterfaceBody') {
const currentNode = [].concat(
objectTypeAnnotations.get(identifier.name) || [],
node
Consider simplifying this complex logical expression. Open
Open
if (
!component.node.parent
|| component.node.parent.type !== 'VariableDeclarator'
|| !component.node.parent.id
|| component.node.parent.id.type !== 'Identifier'
Avoid too many return
statements within this function. Open
Open
return null;
Avoid too many return
statements within this function. Open
Open
return node.value.name;