packages/babel-plugin-transform-destructuring/src/index.js

Summary

Maintainability
F
3 days
Test Coverage

File index.js has 507 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { declare } from "@babel/helper-plugin-utils";
import { types as t } from "@babel/core";

export default declare((api, options) => {
  api.assertVersion(7);
Severity: Major
Found in packages/babel-plugin-transform-destructuring/src/index.js - About 1 day to fix

    Function VariableDeclaration has 62 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          VariableDeclaration(path) {
            const { node, scope, parent } = path;
            if (t.isForXStatement(parent)) return;
            if (!parent || !path.container) return; // i don't know why this is necessary - TODO
            if (!variableDeclarationHasPattern(node)) return;
    Severity: Major
    Found in packages/babel-plugin-transform-destructuring/src/index.js - About 2 hrs to fix

      Function pushObjectPattern has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          pushObjectPattern(pattern, objRef) {
            // https://github.com/babel/babel/issues/681
      
            if (!pattern.properties.length) {
              this.nodes.push(
      Severity: Minor
      Found in packages/babel-plugin-transform-destructuring/src/index.js - About 1 hr to fix

        Function ForXStatement has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              ForXStatement(path) {
                const { node, scope } = path;
                const left = node.left;
        
                if (t.isPattern(left)) {
        Severity: Minor
        Found in packages/babel-plugin-transform-destructuring/src/index.js - About 1 hr to fix

          Function pushObjectRest has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              pushObjectRest(pattern, objRef, spreadProp, spreadPropIndex) {
                // get all the keys that appear in this object before the current spread
          
                const keys = [];
                let allLiteral = true;
          Severity: Minor
          Found in packages/babel-plugin-transform-destructuring/src/index.js - About 1 hr to fix

            Function AssignmentExpression has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  AssignmentExpression(path) {
                    const { node, scope } = path;
                    if (!t.isPattern(node.left)) return;
            
                    const nodes = [];
            Severity: Minor
            Found in packages/babel-plugin-transform-destructuring/src/index.js - About 1 hr to fix

              Function pushArrayPattern has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  pushArrayPattern(pattern, arrayRef) {
                    if (!pattern.elements) return;
              
                    // optimise basic array destructuring of an array expression
                    //
              Severity: Minor
              Found in packages/babel-plugin-transform-destructuring/src/index.js - About 1 hr to fix

                Function pushAssignmentPattern has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    pushAssignmentPattern({ left, right }, valueRef) {
                      // we need to assign the current value of the assignment to avoid evaluating
                      // it more than once
                      const tempId = this.scope.generateUidIdentifierBasedOnNode(valueRef);
                
                
                Severity: Minor
                Found in packages/babel-plugin-transform-destructuring/src/index.js - About 1 hr to fix

                  Avoid too many return statements within this function.
                  Open

                          if (t.isMemberExpression(elem)) return false;
                  Severity: Major
                  Found in packages/babel-plugin-transform-destructuring/src/index.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                          return !state.deopt;
                    Severity: Major
                    Found in packages/babel-plugin-transform-destructuring/src/index.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              if (t.isSpreadElement(elem)) return false;
                      Severity: Major
                      Found in packages/babel-plugin-transform-destructuring/src/index.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                if (t.isCallExpression(elem)) return false;
                        Severity: Major
                        Found in packages/babel-plugin-transform-destructuring/src/index.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  if (t.isMemberExpression(elem)) return false;
                          Severity: Major
                          Found in packages/babel-plugin-transform-destructuring/src/index.js - About 30 mins to fix

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

                                    for (const name of Object.keys(path.getOuterBindingIdentifiers(path))) {
                                      specifiers.push(
                                        t.exportSpecifier(t.identifier(name), t.identifier(name)),
                                      );
                                    }
                            Severity: Major
                            Found in packages/babel-plugin-transform-destructuring/src/index.js and 1 other location - About 1 hr to fix
                            packages/babel-plugin-proposal-object-rest-spread/src/index.js on lines 407..411

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

                            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

                                      if (node.body.body.length === 0 && path.isCompletionRecord()) {
                                        node.body.body.unshift(
                                          t.expressionStatement(scope.buildUndefinedNode()),
                                        );
                                      }
                            Severity: Major
                            Found in packages/babel-plugin-transform-destructuring/src/index.js and 1 other location - About 1 hr to fix
                            packages/babel-plugin-proposal-object-rest-spread/src/index.js on lines 489..493

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

                            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 destructuring = new DestructuringTransformer({
                                      kind: left.kind,
                                      scope: scope,
                                      nodes: nodes,
                                      arrayOnlySpread,
                            Severity: Major
                            Found in packages/babel-plugin-transform-destructuring/src/index.js and 1 other location - About 1 hr to fix
                            packages/babel-plugin-transform-destructuring/src/index.js on lines 571..578

                            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 destructuring = new DestructuringTransformer({
                                      operator: node.operator,
                                      scope: scope,
                                      nodes: nodes,
                                      arrayOnlySpread,
                            Severity: Major
                            Found in packages/babel-plugin-transform-destructuring/src/index.js and 1 other location - About 1 hr to fix
                            packages/babel-plugin-transform-destructuring/src/index.js on lines 526..533

                            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 (t.isPattern(pattern)) {
                                    this.push(pattern, objRef);
                                  } else {
                                    this.nodes.push(this.buildVariableAssignment(pattern, objRef));
                                  }
                            Severity: Major
                            Found in packages/babel-plugin-transform-destructuring/src/index.js and 1 other location - About 1 hr to fix
                            packages/babel-plugin-transform-destructuring/src/index.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 55.

                            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

                                  } else if (t.isAssignmentPattern(id)) {
                                    this.pushAssignmentPattern(id, init);
                                  } else {
                                    this.nodes.push(this.buildVariableAssignment(id, init));
                                  }
                            Severity: Major
                            Found in packages/babel-plugin-transform-destructuring/src/index.js and 1 other location - About 1 hr to fix
                            packages/babel-plugin-transform-destructuring/src/index.js on lines 256..260

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

                            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

                              function hasObjectRest(pattern) {
                                for (const elem of (pattern.properties: Array)) {
                                  if (t.isRestElement(elem)) {
                                    return true;
                                  }
                            Severity: Minor
                            Found in packages/babel-plugin-transform-destructuring/src/index.js and 1 other location - About 45 mins to fix
                            packages/babel-plugin-transform-destructuring/src/index.js on lines 42..49

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

                            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

                              function hasRest(pattern) {
                                for (const elem of (pattern.elements: Array)) {
                                  if (t.isRestElement(elem)) {
                                    return true;
                                  }
                            Severity: Minor
                            Found in packages/babel-plugin-transform-destructuring/src/index.js and 1 other location - About 45 mins to fix
                            packages/babel-plugin-transform-destructuring/src/index.js on lines 55..62

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

                            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 getExtendsHelper(file) {
                                return useBuiltIns
                                  ? t.memberExpression(t.identifier("Object"), t.identifier("assign"))
                                  : file.addHelper("extends");
                              }
                            Severity: Minor
                            Found in packages/babel-plugin-transform-destructuring/src/index.js and 1 other location - About 35 mins to fix
                            packages/babel-plugin-proposal-object-rest-spread/src/index.js on lines 26..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 46.

                            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