Showing 1,982 of 1,982 total issues

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

export function loadPreset(
  name: string,
  dirname: string,
): { filepath: string, value: mixed } {
  const filepath = resolvePreset(name, dirname);
Severity: Major
Found in packages/babel-core/src/config/files/plugins.js and 1 other location - About 4 hrs to fix
packages/babel-core/src/config/files/plugins.js on lines 30..43

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

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

File option-assertions.js has 333 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// @flow

import type {
  ConfigFileSearch,
  BabelrcSearch,
Severity: Minor
Found in packages/babel-core/src/config/validation/option-assertions.js - About 4 hrs to fix

    Function wrapClosure has 98 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      wrapClosure() {
        if (this.throwIfClosureRequired) {
          throw this.blockPath.buildCodeFrameError(
            "Compiling let/const in this block would add a closure " +
              "(throwIfClosureRequired).",
    Severity: Major
    Found in packages/babel-plugin-transform-block-scoping/src/index.js - About 3 hrs to fix

      Function getPolyfillPlugins has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

      export const getPolyfillPlugins = ({
        useBuiltIns,
        corejs,
        polyfillTargets,
        include,
      Severity: Minor
      Found in packages/babel-preset-env/src/index.js - About 3 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

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

        Object.keys(t.NODE_FIELDS[type])
          .sort((fieldA, fieldB) => {
            const indexA = t.BUILDER_KEYS[type].indexOf(fieldA);
            const indexB = t.BUILDER_KEYS[type].indexOf(fieldB);
            if (indexA === indexB) return fieldA < fieldB ? -1 : 1;
      Severity: Major
      Found in packages/babel-types/scripts/generators/flow.js and 1 other location - About 3 hrs to fix
      packages/babel-types/scripts/generators/typescript.js on lines 356..363

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

      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

        return fields.sort((fieldA, fieldB) => {
          const indexA = t.BUILDER_KEYS[type].indexOf(fieldA);
          const indexB = t.BUILDER_KEYS[type].indexOf(fieldB);
          if (indexA === indexB) return fieldA < fieldB ? -1 : 1;
          if (indexA === -1) return 1;
      Severity: Major
      Found in packages/babel-types/scripts/generators/typescript.js and 1 other location - About 3 hrs to fix
      packages/babel-types/scripts/generators/flow.js on lines 59..67

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

      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

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

      /* eslint-env jest */
      import * as babel from "@babel/core";
      import { buildExternalHelpers } from "@babel/core";
      import getFixtures from "@babel/helper-fixtures";
      import sourceMap from "source-map";
      Severity: Minor
      Found in packages/babel-helper-transform-fixture-test-runner/src/index.js - About 3 hrs to fix

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

                    if (!isSideEffectImport(metadata)) {
                      const interop = wrapInterop(
                        path,
                        t.identifier(metadata.name),
                        metadata.interop,
        Severity: Major
        Found in packages/babel-plugin-transform-modules-amd/src/index.js and 1 other location - About 3 hrs to fix
        packages/babel-plugin-transform-modules-umd/src/index.js on lines 184..201

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

        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 (!isSideEffectImport(metadata)) {
                      const interop = wrapInterop(
                        path,
                        t.identifier(metadata.name),
                        metadata.interop,
        Severity: Major
        Found in packages/babel-plugin-transform-modules-umd/src/index.js and 1 other location - About 3 hrs to fix
        packages/babel-plugin-transform-modules-amd/src/index.js on lines 124..141

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

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Function checkLVal has 96 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          checkLVal(
            expr: Expression,
            bindingType: BindingTypes = BIND_NONE,
            checkClashes: ?{ [key: string]: boolean },
            contextDescription: string,
        Severity: Major
        Found in packages/babel-parser/src/parser/lval.js - About 3 hrs to fix

          File evaluation.js has 326 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import type NodePath from "./index";
          
          // This file contains Babels metainterpreter that can evaluate static code.
          
          const VALID_CALLEES = ["String", "Number", "Math"];
          Severity: Minor
          Found in packages/babel-traverse/src/path/evaluation.js - About 3 hrs to fix

            Function getHelperMetadata has 94 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function getHelperMetadata(file) {
              const globals = new Set();
              const localBindingNames = new Set();
              // Maps imported identifier -> helper name
              const dependencies = new Map();
            Severity: Major
            Found in packages/babel-helpers/src/index.js - About 3 hrs to fix

              Function getLocalExportMetadata has 94 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function getLocalExportMetadata(
                programPath: NodePath,
                loose: boolean,
              ): Map<string, LocalExportMetadata> {
                const bindingKindLookup = new Map();

                Function valueToNode has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
                Open

                export default function valueToNode(value: any): Object {
                  // undefined
                  if (value === undefined) {
                    return identifier("undefined");
                  }
                Severity: Minor
                Found in packages/babel-types/src/converters/valueToNode.js - About 3 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 defineType has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
                Open

                export default function defineType(
                  type: string,
                  opts: {
                    fields?: {
                      [string]: FieldOptions,
                Severity: Minor
                Found in packages/babel-types/src/definitions/utils.js - About 3 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 hoistFunctionEnvironment has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
                Open

                function hoistFunctionEnvironment(
                  fnPath,
                  specCompliant = false,
                  allowInsertArrow = true,
                ) {
                Severity: Minor
                Found in packages/babel-traverse/src/path/conversion.js - About 3 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

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

                function buildPrivateFieldInitLoose(ref, prop, privateNamesMap) {
                  const { id } = privateNamesMap.get(prop.node.key.id.name);
                  const value = prop.node.value || prop.scope.buildUndefinedNode();
                
                  return template.statement.ast`
                packages/babel-helper-create-class-features-plugin/src/fields.js on lines 399..409

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

                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 buildPrivateInstanceFieldInitSpec(ref, prop, privateNamesMap) {
                  const { id } = privateNamesMap.get(prop.node.key.id.name);
                  const value = prop.node.value || prop.scope.buildUndefinedNode();
                
                  return template.statement.ast`${id}.set(${ref}, {
                packages/babel-helper-create-class-features-plugin/src/fields.js on lines 385..397

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

                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

                File full.js has 322 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                // @flow
                
                import gensync, { type Handler } from "gensync";
                import { forwardAsync } from "../gensync-utils/async";
                
                
                Severity: Minor
                Found in packages/babel-core/src/config/full.js - About 3 hrs to fix

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

                  export function isWhile(node: ?Object, opts?: Object): boolean {
                    if (!node) return false;
                  
                    const nodeType = node.type;
                    if (
                  Severity: Major
                  Found in packages/babel-types/src/validators/generated/index.js and 7 other locations - About 3 hrs to fix
                  packages/babel-types/src/validators/generated/index.js on lines 3524..3541
                  packages/babel-types/src/validators/generated/index.js on lines 3739..3756
                  packages/babel-types/src/validators/generated/index.js on lines 3834..3851
                  packages/babel-types/src/validators/generated/index.js on lines 4130..4147
                  packages/babel-types/src/validators/generated/index.js on lines 4167..4184
                  packages/babel-types/src/validators/generated/index.js on lines 4205..4222
                  packages/babel-types/src/validators/generated/index.js on lines 4449..4466

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

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language