yannickcr/eslint-plugin-react

View on GitHub

Showing 696 of 696 total issues

Function propTypesInstructions has a Cognitive Complexity of 304 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function propTypesInstructions(context, components, utils) {
  // Used to track the type annotations in scope.
  // Necessary because babel's scopes do not track type annotations.
  let stack = null;

Severity: Minor
Found in lib/util/propTypes.js - About 6 days 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 componentRule has a Cognitive Complexity of 221 (exceeds 5 allowed). Consider refactoring.
Open

function componentRule(rule, context) {
  const pragma = pragmaUtil.getFromContext(context);
  const sourceCode = context.getSourceCode();
  const components = new Components();
  const wrapperFunctions = getWrapperFunctions(context, pragma);
Severity: Minor
Found in lib/util/Components.js - About 4 days 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 propTypesInstructions has 866 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function propTypesInstructions(context, components, utils) {
  // Used to track the type annotations in scope.
  // Necessary because babel's scopes do not track type annotations.
  let stack = null;

Severity: Major
Found in lib/util/propTypes.js - About 4 days to fix

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

      create(context) {
        // Non-null when we are inside a React component ClassDeclaration and we have
        // not yet encountered any use of this.state which we have chosen not to
        // analyze. If we encounter any such usage (like this.state being spread as
        // JSX attributes), then this is again set to null.
    Severity: Minor
    Found in lib/rules/no-unused-state.js - About 2 days 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 componentRule has 494 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function componentRule(rule, context) {
      const pragma = pragmaUtil.getFromContext(context);
      const sourceCode = context.getSourceCode();
      const components = new Components();
      const wrapperFunctions = getWrapperFunctions(context, pragma);
    Severity: Major
    Found in lib/util/Components.js - About 2 days to fix

      File propTypes.js has 921 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /**
       * @fileoverview Common propTypes detection functionality.
       */
      
      'use strict';
      Severity: Major
      Found in lib/util/propTypes.js - About 2 days to fix

        Function usedPropTypesInstructions has a Cognitive Complexity of 99 (exceeds 5 allowed). Consider refactoring.
        Open

        module.exports = function usedPropTypesInstructions(context, components, utils) {
          const checkAsyncSafeLifeCycles = testReactVersion(context, '>= 16.3.0');
        
          const propVariables = createPropVariables();
          const pushScope = propVariables.pushScope;
        Severity: Minor
        Found in lib/util/usedPropTypes.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 a Cognitive Complexity of 96 (exceeds 5 allowed). Consider refactoring.
        Open

          create(context) {
            const configuration = Object.assign(
              {
                allowReferrer: false,
                warnOnSpreadAttributes: false,
        Severity: Minor
        Found in lib/rules/jsx-no-target-blank.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 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 a Cognitive Complexity of 88 (exceeds 5 allowed). Consider refactoring.
        Open

          create(context) {
            function normalizeConfig(configOrTrue, defaults, lastPass) {
              const config = configOrTrue === true ? {} : configOrTrue;
              const when = config.when || defaults.when;
              const allowMultiline = has(config, 'allowMultiline') ? config.allowMultiline : defaults.allowMultiline;
        Severity: Minor
        Found in lib/rules/jsx-curly-spacing.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 343 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          create(context) {
            // Non-null when we are inside a React component ClassDeclaration and we have
            // not yet encountered any use of this.state which we have chosen not to
            // analyze. If we encounter any such usage (like this.state being spread as
            // JSX attributes), then this is again set to null.
        Severity: Major
        Found in lib/rules/no-unused-state.js - About 1 day to fix

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

            create(context) {
              const extraColumnStart = 0;
              let indentType = 'space';
              let indentSize = 4;
          
          
          Severity: Minor
          Found in lib/rules/jsx-indent.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 Components.js has 680 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          /**
           * @fileoverview Utility class and functions for React components detection
           * @author Yannick Croissant
           */
          
          
          Severity: Major
          Found in lib/util/Components.js - About 1 day to fix

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

              } else {
                const firstTokens = sourceCode.getFirstTokens(node, 2);
            
                adjacent = !sourceCode.isSpaceBetweenTokens(firstTokens[0], firstTokens[1]);
            
            
            Severity: Major
            Found in lib/rules/jsx-tag-spacing.js and 1 other location - About 1 day to fix
            lib/rules/jsx-tag-spacing.js on lines 36..66

            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 273.

            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

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

              if (node.selfClosing) {
                const lastTokens = sourceCode.getLastTokens(node, 2);
            
                adjacent = !sourceCode.isSpaceBetweenTokens(lastTokens[0], lastTokens[1]);
            
            
            Severity: Major
            Found in lib/rules/jsx-tag-spacing.js and 1 other location - About 1 day to fix
            lib/rules/jsx-tag-spacing.js on lines 66..96

            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 273.

            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 74 (exceeds 5 allowed). Consider refactoring.
            Open

              create: Components.detect((context, components) => {
                /**
                 * @param {Array} properties list of component properties
                 */
                function reportNoArrowFunctionLifecycle(properties) {
            Severity: Minor
            Found in lib/rules/no-arrow-function-lifecycle.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

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

                create: Components.detect((context, components, utils) => {
                  let propTypesPackageName = null;
                  let reactPackageName = null;
              
                  function checkValidPropTypeQualifier(node) {
              Severity: Minor
              Found in lib/rules/no-typos.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 254 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(context) {
                    const MESSAGE_LOCATION = {
                      'after-props': 'placed after the last prop',
                      'after-tag': 'placed after the opening tag',
                      'props-aligned': 'aligned with the last prop',
                Severity: Minor
                Found in lib/rules/jsx-closing-bracket-location.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

                Severity
                Category
                Status
                Source
                Language