yannickcr/eslint-plugin-react

View on GitHub
lib/rules/destructuring-assignment.js

Summary

Maintainability
F
3 days
Test Coverage

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

  create: Components.detect((context, components, utils) => {
    const configuration = context.options[0] || DEFAULT_OPTION;
    const ignoreClassFields = (context.options[1] && (context.options[1].ignoreClassFields === true)) || false;
    const destructureInSignature = (context.options[1] && context.options[1].destructureInSignature) || 'ignore';
    const sfcParams = createSFCParams();
Severity: Minor
Found in lib/rules/destructuring-assignment.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 156 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  create: Components.detect((context, components, utils) => {
    const configuration = context.options[0] || DEFAULT_OPTION;
    const ignoreClassFields = (context.options[1] && (context.options[1].ignoreClassFields === true)) || false;
    const destructureInSignature = (context.options[1] && context.options[1].destructureInSignature) || 'ignore';
    const sfcParams = createSFCParams();
Severity: Major
Found in lib/rules/destructuring-assignment.js - About 6 hrs to fix

    Function VariableDeclarator has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          VariableDeclarator(node) {
            const classComponent = utils.getParentComponent(node);
            const SFCComponent = components.get(context.getScope(node).block);
    
            const destructuring = (node.init && node.id && node.id.type === 'ObjectPattern');
    Severity: Major
    Found in lib/rules/destructuring-assignment.js - About 2 hrs to fix

      Consider simplifying this complex logical expression.
      Open

              if (
                classComponent && destructuringClass && configuration === 'never'
                && !(ignoreClassFields && (node.parent.type === 'ClassProperty' || node.parent.type === 'PropertyDefinition'))
              ) {
                report(context, messages.noDestructAssignment, 'noDestructAssignment', {
      Severity: Major
      Found in lib/rules/destructuring-assignment.js - About 40 mins to fix

        Consider simplifying this complex logical expression.
        Open

                if (
                  SFCComponent
                  && destructuringSFC
                  && configuration === 'always'
                  && destructureInSignature === 'always'
        Severity: Major
        Found in lib/rules/destructuring-assignment.js - About 40 mins to fix

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

              propsName() {
                const found = queue.find((params) => {
                  const props = params[0];
                  return props && !props.destructuring && props.name;
                });
          Severity: Major
          Found in lib/rules/destructuring-assignment.js and 1 other location - About 2 hrs to fix
          lib/rules/destructuring-assignment.js on lines 31..37

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

          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

              contextName() {
                const found = queue.find((params) => {
                  const context = params[1];
                  return context && !context.destructuring && context.name;
                });
          Severity: Major
          Found in lib/rules/destructuring-assignment.js and 1 other location - About 2 hrs to fix
          lib/rules/destructuring-assignment.js on lines 24..30

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

          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

                  node.object.type === 'MemberExpression' && node.object.object.type === 'ThisExpression'
                  && (node.object.property.name === 'props' || node.object.property.name === 'context' || node.object.property.name === 'state')
          Severity: Major
          Found in lib/rules/destructuring-assignment.js and 1 other location - About 1 hr to fix
          lib/rules/destructuring-assignment.js on lines 219..221

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

          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 destructuringClass = destructuring && node.init.object && node.init.object.type === 'ThisExpression' && (
                    node.init.property.name === 'props' || node.init.property.name === 'context' || node.init.property.name === 'state'
                  );
          Severity: Major
          Found in lib/rules/destructuring-assignment.js and 1 other location - About 1 hr to fix
          lib/rules/destructuring-assignment.js on lines 162..163

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

          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 (
                    classComponent && destructuringClass && configuration === 'never'
                    && !(ignoreClassFields && (node.parent.type === 'ClassProperty' || node.parent.type === 'PropertyDefinition'))
                  ) {
                    report(context, messages.noDestructAssignment, 'noDestructAssignment', {
          Severity: Minor
          Found in lib/rules/destructuring-assignment.js and 1 other location - About 35 mins to fix
          lib/rules/destructuring-assignment.js on lines 167..177

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

          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 (
                  isPropUsed && configuration === 'always'
                  && !(ignoreClassFields && isInClassProperty(node))
                ) {
                  report(context, messages.useDestructAssignment, 'useDestructAssignment', {
          Severity: Minor
          Found in lib/rules/destructuring-assignment.js and 1 other location - About 35 mins to fix
          lib/rules/destructuring-assignment.js on lines 232..242

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

          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

          There are no issues that match your filters.

          Category
          Status