packages/babel-traverse/src/scope/index.js

Summary

Maintainability
F
1 wk
Test Coverage

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

import includes from "lodash/includes";
import repeat from "lodash/repeat";
import Renamer from "./lib/renamer";
import type NodePath from "../path";
import traverse from "../index";
Severity: Major
Found in packages/babel-traverse/src/scope/index.js - About 1 day to fix

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

      isPure(node, constantsOnly?: boolean) {
        if (t.isIdentifier(node)) {
          const binding = this.getBinding(node.name);
          if (!binding) return false;
          if (constantsOnly) return binding.constant;
    Severity: Minor
    Found in packages/babel-traverse/src/scope/index.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

    Scope has 52 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export default class Scope {
      /**
       * This searches the current "scope" and collects all references/bindings
       * within.
       */
    Severity: Major
    Found in packages/babel-traverse/src/scope/index.js - About 7 hrs to fix

      Function gatherNodeParts has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
      Open

      function gatherNodeParts(node: Object, parts: Array) {
        switch (node?.type) {
          default:
            if (t.isModuleDeclaration(node)) {
              if (node.source) {
      Severity: Minor
      Found in packages/babel-traverse/src/scope/index.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

      Function gatherNodeParts has 112 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function gatherNodeParts(node: Object, parts: Array) {
        switch (node?.type) {
          default:
            if (t.isModuleDeclaration(node)) {
              if (node.source) {
      Severity: Major
      Found in packages/babel-traverse/src/scope/index.js - About 4 hrs to fix

        Function registerBinding has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

          registerBinding(kind: string, path: NodePath, bindingPath = path) {
            if (!kind) throw new ReferenceError("no `kind`");
        
            if (path.isVariableDeclaration()) {
              const declarators: Array<NodePath> = path.get("declarations");
        Severity: Minor
        Found in packages/babel-traverse/src/scope/index.js - About 2 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 crawl has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

          crawl() {
            const path = this.path;
        
            this.references = Object.create(null);
            this.bindings = Object.create(null);
        Severity: Minor
        Found in packages/babel-traverse/src/scope/index.js - About 2 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 isPure has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          isPure(node, constantsOnly?: boolean) {
            if (t.isIdentifier(node)) {
              const binding = this.getBinding(node.name);
              if (!binding) return false;
              if (constantsOnly) return binding.constant;
        Severity: Major
        Found in packages/babel-traverse/src/scope/index.js - About 2 hrs to fix

          Function crawl has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            crawl() {
              const path = this.path;
          
              this.references = Object.create(null);
              this.bindings = Object.create(null);
          Severity: Minor
          Found in packages/babel-traverse/src/scope/index.js - About 1 hr to fix

            Function exit has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                exit(path) {
                  const { node, scope } = path;
                  const declar = node.declaration;
                  if (t.isClassDeclaration(declar) || t.isFunctionDeclaration(declar)) {
                    const id = declar.id;
            Severity: Minor
            Found in packages/babel-traverse/src/scope/index.js - About 1 hr 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 registerDeclaration has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              registerDeclaration(path: NodePath) {
                if (path.isLabeledStatement()) {
                  this.registerLabel(path);
                } else if (path.isFunctionDeclaration()) {
                  this.registerBinding("hoisted", path.get("id"), path);
            Severity: Minor
            Found in packages/babel-traverse/src/scope/index.js - About 1 hr 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 toArray has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              toArray(node: Object, i?: number | boolean, allowArrayLike?: boolean) {
                if (t.isIdentifier(node)) {
                  const binding = this.getBinding(node.name);
                  if (binding?.constant && binding.path.isGenericType("Array")) {
                    return node;
            Severity: Minor
            Found in packages/babel-traverse/src/scope/index.js - About 1 hr to fix

              Function registerBinding has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                registerBinding(kind: string, path: NodePath, bindingPath = path) {
                  if (!kind) throw new ReferenceError("no `kind`");
              
                  if (path.isVariableDeclaration()) {
                    const declarators: Array<NodePath> = path.get("declarations");
              Severity: Minor
              Found in packages/babel-traverse/src/scope/index.js - About 1 hr to fix

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

                  registerDeclaration(path: NodePath) {
                    if (path.isLabeledStatement()) {
                      this.registerLabel(path);
                    } else if (path.isFunctionDeclaration()) {
                      this.registerBinding("hoisted", path.get("id"), path);
                Severity: Minor
                Found in packages/babel-traverse/src/scope/index.js - About 1 hr to fix

                  Function getAllBindingsOfKind has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    getAllBindingsOfKind(): Object {
                      const ids = Object.create(null);
                  
                      for (const kind of (arguments: Array)) {
                        let scope = this;
                  Severity: Minor
                  Found in packages/babel-traverse/src/scope/index.js - About 1 hr 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 toArray has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    toArray(node: Object, i?: number | boolean, allowArrayLike?: boolean) {
                      if (t.isIdentifier(node)) {
                        const binding = this.getBinding(node.name);
                        if (binding?.constant && binding.path.isGenericType("Array")) {
                          return node;
                  Severity: Minor
                  Found in packages/babel-traverse/src/scope/index.js - About 1 hr 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 push has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                    push(opts: {
                      id: Object,
                      init: ?Object,
                      unique: ?boolean,
                      _blockHoist: ?number,
                  Severity: Minor
                  Found in packages/babel-traverse/src/scope/index.js - About 55 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

                        for (const elem of (node.elements: Array<Object>)) {
                          if (!this.isPure(elem, constantsOnly)) return false;
                        }
                  Severity: Major
                  Found in packages/babel-traverse/src/scope/index.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                        } else if (t.isObjectExpression(node)) {
                          for (const prop of (node.properties: Array<Object>)) {
                            if (!this.isPure(prop, constantsOnly)) return false;
                          }
                          return true;
                    Severity: Major
                    Found in packages/babel-traverse/src/scope/index.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                  if (binding) binding.reference(path);
                      Severity: Major
                      Found in packages/babel-traverse/src/scope/index.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                if (!this.isPure(method, constantsOnly)) return false;
                        Severity: Major
                        Found in packages/babel-traverse/src/scope/index.js - About 45 mins to fix

                          Function getBinding has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                            getBinding(name: string) {
                              let scope = this;
                              let previousPath;
                          
                              do {
                          Severity: Minor
                          Found in packages/babel-traverse/src/scope/index.js - About 35 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 too many return statements within this function.
                          Open

                                return this.isPure(node.value, constantsOnly);
                          Severity: Major
                          Found in packages/babel-traverse/src/scope/index.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                  return (
                                    this.isPure(node.left, constantsOnly) &&
                                    this.isPure(node.right, constantsOnly)
                                  );
                            Severity: Major
                            Found in packages/babel-traverse/src/scope/index.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                    if (node.computed && !this.isPure(node.key, constantsOnly)) return false;
                              Severity: Major
                              Found in packages/babel-traverse/src/scope/index.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                      if (node.kind === "get" || node.kind === "set") return false;
                                Severity: Major
                                Found in packages/babel-traverse/src/scope/index.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                        return true;
                                  Severity: Major
                                  Found in packages/babel-traverse/src/scope/index.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                        return false;
                                    Severity: Major
                                    Found in packages/babel-traverse/src/scope/index.js - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                            if (node.computed && !this.isPure(node.key, constantsOnly)) return false;
                                      Severity: Major
                                      Found in packages/babel-traverse/src/scope/index.js - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                              return t.isPureish(node);
                                        Severity: Major
                                        Found in packages/babel-traverse/src/scope/index.js - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                                  if (!this.isPure(expression, constantsOnly)) return false;
                                          Severity: Major
                                          Found in packages/babel-traverse/src/scope/index.js - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                  return (
                                                    t.matchesPattern(node.tag, "String.raw") &&
                                                    !this.hasBinding("String", true) &&
                                                    this.isPure(node.quasi, constantsOnly)
                                                  );
                                            Severity: Major
                                            Found in packages/babel-traverse/src/scope/index.js - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                  if (!noGlobals && includes(Scope.globals, name)) return true;
                                              Severity: Major
                                              Found in packages/babel-traverse/src/scope/index.js - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                        if (!this.isPure(method, constantsOnly)) return false;
                                                Severity: Major
                                                Found in packages/babel-traverse/src/scope/index.js - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                          if (!this.isPure(elem, constantsOnly)) return false;
                                                  Severity: Major
                                                  Found in packages/babel-traverse/src/scope/index.js - About 30 mins to fix

                                                    Avoid too many return statements within this function.
                                                    Open

                                                        if (!noGlobals && includes(Scope.contextVariables, name)) return true;
                                                    Severity: Major
                                                    Found in packages/babel-traverse/src/scope/index.js - About 30 mins to fix

                                                      Avoid too many return statements within this function.
                                                      Open

                                                            return this.isPure(node.body, constantsOnly);
                                                      Severity: Major
                                                      Found in packages/babel-traverse/src/scope/index.js - About 30 mins to fix

                                                        Avoid too many return statements within this function.
                                                        Open

                                                              return true;
                                                        Severity: Major
                                                        Found in packages/babel-traverse/src/scope/index.js - About 30 mins to fix

                                                          Avoid too many return statements within this function.
                                                          Open

                                                                  if (!this.isPure(prop, constantsOnly)) return false;
                                                          Severity: Major
                                                          Found in packages/babel-traverse/src/scope/index.js - About 30 mins to fix

                                                            Avoid too many return statements within this function.
                                                            Open

                                                                  return true;
                                                            Severity: Major
                                                            Found in packages/babel-traverse/src/scope/index.js - About 30 mins to fix

                                                              Avoid too many return statements within this function.
                                                              Open

                                                                    return this.isPure(node.argument, constantsOnly);
                                                              Severity: Major
                                                              Found in packages/babel-traverse/src/scope/index.js - About 30 mins to fix

                                                                Avoid too many return statements within this function.
                                                                Open

                                                                      return true;
                                                                Severity: Major
                                                                Found in packages/babel-traverse/src/scope/index.js - About 30 mins to fix

                                                                  Avoid too many return statements within this function.
                                                                  Open

                                                                        return true;
                                                                  Severity: Major
                                                                  Found in packages/babel-traverse/src/scope/index.js - About 30 mins to fix

                                                                    Function hasBinding has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                    Open

                                                                      hasBinding(name: string, noGlobals?) {
                                                                        if (!name) return false;
                                                                        if (this.hasOwnBinding(name)) return true;
                                                                        if (this.parentHasBinding(name, noGlobals)) return true;
                                                                        if (this.hasUid(name)) return true;
                                                                    Severity: Minor
                                                                    Found in packages/babel-traverse/src/scope/index.js - About 25 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

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

                                                                      getBlockParent() {
                                                                        let scope = this;
                                                                        do {
                                                                          if (scope.path.isBlockParent()) {
                                                                            return scope;
                                                                    Severity: Major
                                                                    Found in packages/babel-traverse/src/scope/index.js and 1 other location - About 1 hr to fix
                                                                    packages/babel-traverse/src/scope/index.js on lines 911..919

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

                                                                    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

                                                                      getProgramParent() {
                                                                        let scope = this;
                                                                        do {
                                                                          if (scope.path.isProgram()) {
                                                                            return scope;
                                                                    Severity: Major
                                                                    Found in packages/babel-traverse/src/scope/index.js and 1 other location - About 1 hr to fix
                                                                    packages/babel-traverse/src/scope/index.js on lines 940..950

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

                                                                    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 (t.isTemplateLiteral(node)) {
                                                                          for (const expression of (node.expressions: Array<Object>)) {
                                                                            if (!this.isPure(expression, constantsOnly)) return false;
                                                                          }
                                                                          return true;
                                                                    Severity: Major
                                                                    Found in packages/babel-traverse/src/scope/index.js and 2 other locations - About 1 hr to fix
                                                                    packages/babel-traverse/src/scope/index.js on lines 723..755
                                                                    packages/babel-traverse/src/scope/index.js on lines 728..755

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

                                                                    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 (t.isObjectExpression(node)) {
                                                                          for (const prop of (node.properties: Array<Object>)) {
                                                                            if (!this.isPure(prop, constantsOnly)) return false;
                                                                          }
                                                                          return true;
                                                                    Severity: Major
                                                                    Found in packages/babel-traverse/src/scope/index.js and 2 other locations - About 1 hr to fix
                                                                    packages/babel-traverse/src/scope/index.js on lines 723..755
                                                                    packages/babel-traverse/src/scope/index.js on lines 748..755

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

                                                                    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 (t.isArrayExpression(node)) {
                                                                          for (const elem of (node.elements: Array<Object>)) {
                                                                            if (!this.isPure(elem, constantsOnly)) return false;
                                                                          }
                                                                          return true;
                                                                    Severity: Major
                                                                    Found in packages/babel-traverse/src/scope/index.js and 2 other locations - About 1 hr to fix
                                                                    packages/babel-traverse/src/scope/index.js on lines 728..755
                                                                    packages/babel-traverse/src/scope/index.js on lines 748..755

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

                                                                    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 (
                                                                            path.isFunctionExpression() &&
                                                                            path.has("id") &&
                                                                            !path.get("id").node[t.NOT_LOCAL_BINDING]
                                                                          ) {
                                                                    Severity: Minor
                                                                    Found in packages/babel-traverse/src/scope/index.js and 1 other location - About 35 mins to fix
                                                                    packages/babel-traverse/src/scope/index.js on lines 263..269

                                                                    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

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

                                                                        if (
                                                                          path.isFunctionExpression() &&
                                                                          path.has("id") &&
                                                                          !path.get("id").node[t.NOT_LOCAL_BINDING]
                                                                        ) {
                                                                    Severity: Minor
                                                                    Found in packages/babel-traverse/src/scope/index.js and 1 other location - About 35 mins to fix
                                                                    packages/babel-traverse/src/scope/index.js on lines 809..815

                                                                    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