yannickcr/eslint-plugin-react

View on GitHub

Showing 710 of 710 total issues

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

      } else if (node.type === 'Identifier') {
        const propTypesObject = variableUtil.findVariableByName(context, node, node.name);
        if (propTypesObject && propTypesObject.properties) {
          checkProperties(propTypesObject.properties);
        }
Severity: Major
Found in lib/rules/forbid-prop-types.js and 2 other locations - About 50 mins to fix
lib/rules/sort-prop-types.js on lines 195..205
lib/rules/sort-prop-types.js on lines 245..250

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

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 3 locations. Consider refactoring.
Open

      } else if (node.type === 'Identifier') {
        const propTypesObject = variableUtil.findVariableByName(context, node, node.name);
        if (propTypesObject && propTypesObject.properties) {
          checkSorted(propTypesObject.properties);
        }
Severity: Major
Found in lib/rules/sort-prop-types.js and 2 other locations - About 50 mins to fix
lib/rules/forbid-prop-types.js on lines 168..181
lib/rules/sort-prop-types.js on lines 245..250

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

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

      const namedClass = (
        (node.type === 'ClassDeclaration' || node.type === 'ClassExpression')
        && node.id
        && !!node.id.name
      );
Severity: Minor
Found in lib/rules/display-name.js and 1 other location - About 50 mins to fix
lib/rules/display-name.js on lines 141..145

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

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 3 locations. Consider refactoring.
Open

        } else if (firstArg.type === 'Identifier') {
          const variable = variableUtil.findVariableByName(context, node, firstArg.name);
          if (variable && variable.properties) {
            checkSorted(variable.properties);
          }
Severity: Major
Found in lib/rules/sort-prop-types.js and 2 other locations - About 50 mins to fix
lib/rules/forbid-prop-types.js on lines 168..181
lib/rules/sort-prop-types.js on lines 195..205

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

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 (callbacksLast) {
            if (!previousIsCallback && currentIsCallback) {
              // Entering the callback prop section
              return decl;
            }
Severity: Minor
Found in lib/rules/jsx-sort-props.js and 1 other location - About 50 mins to fix
lib/rules/jsx-sort-props.js on lines 500..511

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

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

      const namedFunctionDeclaration = (
        (node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression')
        && node.id
        && !!node.id.name
      );
Severity: Minor
Found in lib/rules/display-name.js and 1 other location - About 50 mins to fix
lib/rules/display-name.js on lines 135..139

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

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 readDefaultReactVersionFromContext has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

function readDefaultReactVersionFromContext(context) {
  // .eslintrc shared settings (https://eslint.org/docs/user-guide/configuring#adding-shared-settings)
  if (context.settings && context.settings.react && context.settings.react.defaultVersion) {
    let settingsDefaultVersion = context.settings.react.defaultVersion;
    if (typeof settingsDefaultVersion !== 'string') {
Severity: Minor
Found in lib/util/version.js - About 45 mins 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

Avoid deeply nested control flow statements.
Open

                if (isFunctionType(func)) {
                  let res = func.body;
                  if (res.type === 'BlockStatement') {
                    res = astUtil.findReturnStatement(func);
                    if (res) {
Severity: Major
Found in lib/util/propTypes.js - About 45 mins to fix

    Function getKeyValue has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    function getKeyValue(context, node) {
      if (node.type === 'ObjectTypeProperty') {
        const tokens = getFirstTokens(context, node, 2);
        return (tokens[0].value === '+' || tokens[0].value === '-'
          ? tokens[1].value
    Severity: Minor
    Found in lib/util/ast.js - About 45 mins 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

    Avoid deeply nested control flow statements.
    Open

                  if (returnTypeFunction.length === 0) {
                    // Cannot find identifier in current scope. It might be an exported type.
                    this.shouldIgnorePropTypes = true;
                    return;
                  }
    Severity: Major
    Found in lib/util/propTypes.js - About 45 mins to fix

      Function getFlowVersionFromContext has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      function getFlowVersionFromContext(context) {
        let confVer = defaultVersion;
        // .eslintrc shared settings (https://eslint.org/docs/user-guide/configuring#adding-shared-settings)
        if (context.settings.react && context.settings.react.flowVersion) {
          let flowVersion = context.settings.react.flowVersion;
      Severity: Minor
      Found in lib/util/version.js - About 45 mins 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 8 (exceeds 5 allowed). Consider refactoring.
      Open

        create(context) {
          const config = context.options[0] || {};
          const checkAliases = config.checkAliases || false;
      
          const isApplicable = testReactVersion(context, '>= 16.3.0');
      Severity: Minor
      Found in lib/rules/no-unsafe.js - About 45 mins 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

      Avoid deeply nested control flow statements.
      Open

                    if (c === entities[j]) {
                      report(context, messages.unescapedEntity, 'unescapedEntity', {
                        node,
                        loc: { line: i, column: start + index },
                        data: {
      Severity: Major
      Found in lib/rules/no-unescaped-entities.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                      if (isClosestJSXAncestor || ancestorConfig.applyToNestedElements) {
                        return ancestorConfig;
                      }
        Severity: Major
        Found in lib/rules/jsx-no-literals.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if (typeof relAttribute.value.expression.value === 'string') {
                                const parts = relAttribute.value.expression.value
                                  .split('noreferrer')
                                  .filter(Boolean);
                                return fixer.replaceText(relAttribute.value.expression, `"${parts.concat('noreferrer').join(' ')}"`);
          Severity: Major
          Found in lib/rules/jsx-no-target-blank.js - About 45 mins to fix

            Function validateBeforeSelfClosing has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            function validateBeforeSelfClosing(context, node, option) {
              const sourceCode = getSourceCode(context);
              const leftToken = getTokenBeforeClosingBracket(node);
              const closingSlash = sourceCode.getTokenAfter(leftToken);
            
            
            Severity: Minor
            Found in lib/rules/jsx-tag-spacing.js - About 45 mins 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 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            function ruleFixer(context, fixStrategy, fixer, reportedNode, leftNode, rightNode) {
            Severity: Minor
            Found in lib/rules/jsx-no-leaked-render.js - About 45 mins to fix

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

                create(context) {
                  const options = context.options;
                  const hasLegacyOption = Array.isArray(options[0]);
                  const legacyOptions = hasLegacyOption ? options[0] : [];
                  // eslint-disable-next-line no-nested-ternary
              Severity: Minor
              Found in lib/rules/jsx-no-script-url.js - About 45 mins 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 checkProps has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              function checkProps(context, node) {
                let sandboxAttributeFound = false;
                if (node.arguments.length > 1) {
                  const props = node.arguments[1];
                  const sandboxProp = props.properties && props.properties.find((x) => x.type === 'Property' && x.key.name === 'sandbox');
              Severity: Minor
              Found in lib/rules/iframe-missing-sandbox.js - About 45 mins 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

              Avoid deeply nested control flow statements.
              Open

                        if (targetTestCond === relTestCond) {
                          const targetBlankIndex = [targetValue.expression.consequent.value, targetValue.expression.alternate.value].indexOf('_blank');
                          return relValues[targetBlankIndex];
                        }
              Severity: Major
              Found in lib/rules/jsx-no-target-blank.js - About 45 mins to fix
                Severity
                Category
                Status
                Source
                Language