yannickcr/eslint-plugin-react

View on GitHub
lib/rules/boolean-prop-naming.js

Summary

Maintainability
F
3 days
Test Coverage

Function create has 258 lines of code (exceeds 25 allowed). Consider refactoring.
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'];

Severity: Major
Found in lib/rules/boolean-prop-naming.js - About 1 day to fix

    Function create has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
    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'];
    
    
    Severity: Minor
    Found in lib/rules/boolean-prop-naming.js - About 1 day to fix

    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

    /**
     * @fileoverview Enforces consistent naming for boolean props
     * @author Ev Haus
     */
    
    
    Severity: Minor
    Found in lib/rules/boolean-prop-naming.js - About 3 hrs to fix

      Function Program:exit has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            'Program:exit'() {
              if (!rule) {
                return;
              }
      
      
      Severity: Minor
      Found in lib/rules/boolean-prop-naming.js - About 1 hr to fix

        Function getComponentTypeAnnotation has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        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
        Severity: Minor
        Found in lib/rules/boolean-prop-naming.js - About 1 hr to fix

          Function findAllTypeAnnotations has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function findAllTypeAnnotations(identifier, node) {
                if (node.type === 'TSTypeLiteral' || node.type === 'ObjectTypeAnnotation' || node.type === 'TSInterfaceBody') {
                  const currentNode = [].concat(
                    objectTypeAnnotations.get(identifier.name) || [],
                    node
          Severity: Minor
          Found in lib/rules/boolean-prop-naming.js - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                  if (
                    !component.node.parent
                    || component.node.parent.type !== 'VariableDeclarator'
                    || !component.node.parent.id
                    || component.node.parent.id.type !== 'Identifier'
            Severity: Major
            Found in lib/rules/boolean-prop-naming.js - About 40 mins to fix

              Avoid too many return statements within this function.
              Open

                    return null;
              Severity: Major
              Found in lib/rules/boolean-prop-naming.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return node.value.name;
                Severity: Major
                Found in lib/rules/boolean-prop-naming.js - About 30 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status