yannickcr/eslint-plugin-react

View on GitHub

Showing 696 of 696 total issues

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

  create(context) {
    function getOption(type) {
      const userOptions = context.options[0] || {};
      if (has(userOptions, type)) {
        return userOptions[type];
Severity: Major
Found in lib/rules/jsx-wrap-multilines.js - About 6 hrs to fix

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

        function findVariableByName(name) {
          const variable = variableUtil.variablesInScope(context).find((item) => item.name === name);
    
          if (!variable || !variable.defs[0] || !variable.defs[0].node) {
            return null;
    Severity: Major
    Found in lib/rules/sort-default-props.js and 1 other location - About 6 hrs to fix
    lib/rules/jsx-sort-default-props.js on lines 93..105

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 157.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

        function findVariableByName(name) {
          const variable = variableUtil.variablesInScope(context).find((item) => item.name === name);
    
          if (!variable || !variable.defs[0] || !variable.defs[0].node) {
            return null;
    Severity: Major
    Found in lib/rules/jsx-sort-default-props.js and 1 other location - About 6 hrs to fix
    lib/rules/sort-default-props.js on lines 88..100

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 157.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

      create(context) {
        const defaults = {
          noStrings: false,
          allowedStrings: [],
          ignoreProps: false,
    Severity: Minor
    Found in lib/rules/jsx-no-literals.js - About 6 hrs 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 jsx-sort-props.js has 413 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /**
     * @fileoverview Enforce props alphabetical sorting
     * @author Ilya Volodin, Yannick Croissant
     */
    
    
    Severity: Minor
    Found in lib/rules/jsx-sort-props.js - About 5 hrs to fix

      Function checkLiteralValueNode has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
      Open

      function checkLiteralValueNode(context, attributeName, node, parentNode, parentNodeName) {
        if (typeof node.value !== 'string') {
          report(context, messages.onlyStrings, 'onlyStrings', {
            node,
            data: { attributeName },
      Severity: Minor
      Found in lib/rules/no-invalid-html-attribute.js - About 5 hrs 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 handleJSX has 143 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function handleJSX(node) {
            const children = node.children;
      
            if (!children || !children.length) {
              return;
      Severity: Major
      Found in lib/rules/jsx-one-expression-per-line.js - About 5 hrs to fix

        File no-unused-state.js has 403 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /**
         * @fileoverview  Attempts to discover all state fields in a React component and
         * warn if any of them are never read.
         *
         * State field definitions are collected from `this.state = {}` assignments in
        Severity: Minor
        Found in lib/rules/no-unused-state.js - About 5 hrs to fix

          Function getGroupsOfSortableAttributes has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
          Open

          function getGroupsOfSortableAttributes(attributes, context) {
            const sourceCode = context.getSourceCode();
          
            const sortableAttributeGroups = [];
            let groupCount = 0;
          Severity: Minor
          Found in lib/rules/jsx-sort-props.js - About 5 hrs 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 defaultPropsInstructions has 136 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          module.exports = function defaultPropsInstructions(context, components, utils) {
            const sourceCode = context.getSourceCode();
          
            /**
             * Try to resolve the node passed in to a variable in the current scope. If the node passed in is not
          Severity: Major
          Found in lib/util/defaultProps.js - About 5 hrs to fix

            Function contextCompare has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
            Open

            function contextCompare(a, b, options) {
              let aProp = propName(a);
              let bProp = propName(b);
            
              const aSortToEnd = shouldSortToEnd(a);
            Severity: Minor
            Found in lib/rules/jsx-sort-props.js - About 5 hrs 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 134 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              create: Components.detect((context, components) => {
                const configuration = context.options[0] || {};
                const allowDecorators = configuration.allowDecorators || [];
            
                /**
            Severity: Major
            Found in lib/rules/require-optimization.js - About 5 hrs to fix

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

                create(context) {
                  const configuration = context.options[0] || 'syntax';
                  const reactPragma = pragmaUtil.getFromContext(context);
                  const fragmentPragma = pragmaUtil.getFragmentFromContext(context);
                  const openFragShort = '<>';
              Severity: Major
              Found in lib/rules/jsx-fragments.js - About 5 hrs to fix

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

                  create(context) {
                    function isSetStateCall(node) {
                      return node.type === 'CallExpression'
                        && node.callee.property
                        && node.callee.property.name === 'setState'
                Severity: Major
                Found in lib/rules/no-access-state-in-setstate.js - About 5 hrs to fix

                  Function markPropTypesAsDeclared has 130 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    function markPropTypesAsDeclared(node, propTypes) {
                      let componentNode = node;
                      while (componentNode && !components.get(componentNode)) {
                        componentNode = componentNode.parent;
                      }
                  Severity: Major
                  Found in lib/util/propTypes.js - About 5 hrs to fix

                    File usedPropTypes.js has 382 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    /**
                     * @fileoverview Common used propTypes detection functionality.
                     */
                    
                    'use strict';
                    Severity: Minor
                    Found in lib/util/usedPropTypes.js - About 5 hrs to fix

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

                        create: Components.detect((context, components, util) => {
                          const configuration = context.options[0] || {};
                          const allowDestructuredState = configuration.allowDestructuredState || false;
                      
                          return {
                      Severity: Major
                      Found in lib/rules/hook-use-state.js - About 5 hrs to fix

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

                          create(context) {
                            const DEFAULT_DEPTH = 2;
                        
                            const option = context.options[0] || {};
                            const maxDepth = has(option, 'max') ? option.max : DEFAULT_DEPTH;
                        Severity: Minor
                        Found in lib/rules/jsx-max-depth.js - About 5 hrs 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 ruleFixer has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function ruleFixer(context, fixStrategy, fixer, reportedNode, leftNode, rightNode) {
                          const sourceCode = context.getSourceCode();
                          const rightSideText = sourceCode.getText(rightNode);
                        
                          if (fixStrategy === COERCE_STRATEGY) {
                        Severity: Minor
                        Found in lib/rules/jsx-no-leaked-render.js - About 5 hrs 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

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                          if (node.loc.start.line !== node.loc.end.line && option === 'proportional-always') {
                            if (leftToken.loc.end.line === closingSlash.loc.start.line) {
                              report(context, messages.beforeSelfCloseNeedNewline, 'beforeSelfCloseNeedNewline', {
                                node,
                                loc: leftToken.loc.end,
                        Severity: Major
                        Found in lib/rules/jsx-tag-spacing.js and 1 other location - About 4 hrs to fix
                        lib/rules/jsx-tag-spacing.js on lines 191..202

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 133.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Severity
                        Category
                        Status
                        Source
                        Language