Showing 1,251 of 1,982 total issues

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

export default gensync<[any], ResolvedConfig | null>(function* loadFullConfig(
  inputOpts: mixed,
): Handler<ResolvedConfig | null> {
  const result = yield* loadPrivatePartialConfig(inputOpts);
  if (!result) {
Severity: Minor
Found in packages/babel-core/src/config/full.js - About 1 day to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function 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

File transformClass.js has 559 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import type { NodePath } from "@babel/traverse";
import nameFunction from "@babel/helper-function-name";
import ReplaceSupers, {
  environmentVisitor,
} from "@babel/helper-replace-supers";
Severity: Major
Found in packages/babel-plugin-transform-classes/src/transformClass.js - About 1 day to fix

    File flow.js has 543 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import * as t from "@babel/types";
    import { ExportAllDeclaration } from "./modules";
    
    export function AnyTypeAnnotation() {
      this.word("any");
    Severity: Major
    Found in packages/babel-generator/src/generators/flow.js - About 1 day to fix

      Consider simplifying this complex logical expression.
      Open

        if (
          nodeType === "Declaration" ||
          "FunctionDeclaration" === nodeType ||
          "VariableDeclaration" === nodeType ||
          "ClassDeclaration" === nodeType ||
      Severity: Critical
      Found in packages/babel-types/src/validators/generated/index.js - About 1 day to fix

        File typescript.js has 512 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        export function TSTypeAnnotation(node) {
          this.token(":");
          this.space();
          if (node.optional) this.token("?");
          this.print(node.typeAnnotation, node);
        Severity: Major
        Found in packages/babel-generator/src/generators/typescript.js - About 1 day to fix

          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

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

            import { declare } from "@babel/helper-plugin-utils";
            import hoistVariables from "@babel/helper-hoist-variables";
            import { template, types as t } from "@babel/core";
            import { getImportSource } from "babel-plugin-dynamic-import-node/utils";
            import { rewriteThis, getModuleName } from "@babel/helper-module-transforms";
            Severity: Major
            Found in packages/babel-plugin-transform-modules-systemjs/src/index.js - About 1 day to fix

              Function applyReplacement has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
              Open

              function applyReplacement(
                placeholder: Placeholder,
                ast: BabelNodeFile,
                replacement: any,
              ) {
              Severity: Minor
              Found in packages/babel-template/src/populate.js - About 1 day to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Function default has 200 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export default function (opts) {
                const visitor = {};
              
                visitor.JSXNamespacedName = function (path) {
                  if (opts.throwIfNamespace) {
              Severity: Major
              Found in packages/babel-helper-builder-react-jsx/src/index.js - About 1 day to fix

                Function default has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
                Open

                export default async function ({
                  cliOptions,
                  babelOptions,
                }: CmdOptions): Promise<void> {
                  const filenames = cliOptions.filenames;
                Severity: Minor
                Found in packages/babel-cli/src/babel/dir.js - About 7 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

                File flow.js has 487 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                // @flow
                import defineType, {
                  arrayOfType,
                  assertOneOf,
                  assertValueType,
                Severity: Minor
                Found in packages/babel-types/src/definitions/flow.js - About 7 hrs to fix

                  Function handle has 192 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    handle(member) {
                      const { node, parent, parentPath } = member;
                  
                      if (member.isOptionalMemberExpression()) {
                        // Transforming optional chaining requires we replace ancestors.
                  Severity: Major
                  Found in packages/babel-helper-member-expression-to-functions/src/index.js - About 7 hrs to fix

                    File conversion.js has 484 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    // This file contains methods that convert the path node into another node or some other type of data.
                    
                    import * as t from "@babel/types";
                    import nameFunction from "@babel/helper-function-name";
                    
                    
                    Severity: Minor
                    Found in packages/babel-traverse/src/path/conversion.js - About 7 hrs to fix

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

                      // @flow
                      
                      import * as charCodes from "charcodes";
                      
                      import XHTMLEntities from "./xhtml";
                      Severity: Minor
                      Found in packages/babel-parser/src/plugins/jsx/index.js - About 7 hrs to fix

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

                        import { declare } from "@babel/helper-plugin-utils";
                        import syntaxObjectRestSpread from "@babel/plugin-syntax-object-rest-spread";
                        import { types as t } from "@babel/core";
                        import { convertFunctionParams } from "@babel/plugin-transform-parameters";
                        
                        
                        Severity: Minor
                        Found in packages/babel-plugin-proposal-object-rest-spread/src/index.js - About 7 hrs to fix

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

                            function run(task) {
                              const {
                                actual,
                                expect: expected,
                                exec,
                            Severity: Minor
                            Found in packages/babel-helper-transform-fixture-test-runner/src/index.js - About 7 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

                            Consider simplifying this complex logical expression.
                            Open

                              if (
                                nodeType === "FlowType" ||
                                "AnyTypeAnnotation" === nodeType ||
                                "ArrayTypeAnnotation" === nodeType ||
                                "BooleanTypeAnnotation" === nodeType ||
                            Severity: Critical
                            Found in packages/babel-types/src/validators/generated/index.js - About 7 hrs to fix

                              File typescript.js has 458 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              // @flow
                              import defineType, {
                                arrayOfType,
                                assertEach,
                                assertNodeType,
                              Severity: Minor
                              Found in packages/babel-types/src/definitions/typescript.js - About 7 hrs to fix
                                Severity
                                Category
                                Status
                                Source
                                Language