yannickcr/eslint-plugin-react

View on GitHub
lib/rules/jsx-curly-brace-presence.js

Summary

Maintainability
F
4 days
Test Coverage

Function create has a Cognitive Complexity of 96 (exceeds 5 allowed). Consider refactoring.
Open

  create(context) {
    const HTML_ENTITY_REGEX = () => /&[A-Za-z\d#]+;/g;
    const ruleOptions = context.options[0];
    const userConfig = typeof ruleOptions === 'string'
      ? { props: ruleOptions, children: ruleOptions, propElementValues: OPTION_IGNORE }
Severity: Minor
Found in lib/rules/jsx-curly-brace-presence.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

Function create has 275 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  create(context) {
    const HTML_ENTITY_REGEX = () => /&[A-Za-z\d#]+;/g;
    const ruleOptions = context.options[0];
    const userConfig = typeof ruleOptions === 'string'
      ? { props: ruleOptions, children: ruleOptions, propElementValues: OPTION_IGNORE }
Severity: Major
Found in lib/rules/jsx-curly-brace-presence.js - About 1 day to fix

    File jsx-curly-brace-presence.js has 325 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /**
     * @fileoverview Enforce curly braces or disallow unnecessary curly brace in JSX
     * @author Jacky Ho
     * @author Simon Lydell
     */
    Severity: Minor
    Found in lib/rules/jsx-curly-brace-presence.js - About 3 hrs to fix

      Consider simplifying this complex logical expression.
      Open

            if (
              (expressionType === 'Literal' || expressionType === 'JSXText')
                && typeof expression.value === 'string'
                && (
                  (JSXExpressionNode.parent.type === 'JSXAttribute' && !isWhiteSpaceLiteral(expression))
      Severity: Critical
      Found in lib/rules/jsx-curly-brace-presence.js - About 2 hrs to fix

        Function lintUnnecessaryCurly has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function lintUnnecessaryCurly(JSXExpressionNode) {
              const expression = JSXExpressionNode.expression;
              const expressionType = expression.type;
        
              const sourceCode = context.getSourceCode();
        Severity: Minor
        Found in lib/rules/jsx-curly-brace-presence.js - About 1 hr to fix

          Function reportUnnecessaryCurly has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function reportUnnecessaryCurly(JSXExpressionNode) {
                report(context, messages.unnecessaryCurly, 'unnecessaryCurly', {
                  node: JSXExpressionNode,
                  fix(fixer) {
                    const expression = JSXExpressionNode.expression;
          Severity: Minor
          Found in lib/rules/jsx-curly-brace-presence.js - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                  if (
                    parent.type && parent.type === 'JSXAttribute'
                    && (node.expression && node.expression.type
                      && node.expression.type !== 'Literal'
                      && node.expression.type !== 'StringLiteral'
            Severity: Major
            Found in lib/rules/jsx-curly-brace-presence.js - About 1 hr to fix

              Consider simplifying this complex logical expression.
              Open

                    } else if (
                      expressionType === 'TemplateLiteral'
                      && expression.expressions.length === 0
                      && expression.quasis[0].value.raw.indexOf('\n') === -1
                      && !isStringWithTrailingWhiteSpaces(expression.quasis[0].value.raw)
              Severity: Major
              Found in lib/rules/jsx-curly-brace-presence.js - About 40 mins to fix

                Avoid too many return statements within this function.
                Open

                      return areRuleConditionsSatisfied(parent, config, OPTION_NEVER);
                Severity: Major
                Found in lib/rules/jsx-curly-brace-presence.js - About 30 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status