Showing 1,982 of 1,982 total issues

Function processComment has a Cognitive Complexity of 74 (exceeds 5 allowed). Consider refactoring.
Open

  processComment(node: Node): void {
    if (node.type === "Program" && node.body.length > 0) return;

    const stack = this.state.commentStack;

Severity: Minor
Found in packages/babel-parser/src/parser/comments.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

Consider simplifying this complex logical expression.
Open

  } else if (
    type === tt.semi ||
    type === tt.comma ||
    type === tt.parenL ||
    type === tt.parenR ||
Severity: Critical
Found in eslint/babel-eslint-parser/src/convert/convertTokens.js - About 1 day to fix

    ExpressionParser has 76 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export default class ExpressionParser extends LValParser {
      // Forward-declaration: defined in statement.js
      /*::
      +parseBlock: (
        allowDirectives?: boolean,
    Severity: Major
    Found in packages/babel-parser/src/parser/expression.js - About 1 day to fix

      Function convertFunctionParams has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
      Open

      export default function convertFunctionParams(
        path,
        loose,
        shouldTransformParam,
        replaceRestElement,
      Severity: Minor
      Found in packages/babel-plugin-transform-parameters/src/params.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 _evaluate has 263 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function _evaluate(path, state) {
        if (!state.confident) return;
      
        const { node } = path;
      
      
      Severity: Major
      Found in packages/babel-traverse/src/path/evaluation.js - About 1 day to fix

        Consider simplifying this complex logical expression.
        Open

          if (
            nodeType === "TSType" ||
            "TSAnyKeyword" === nodeType ||
            "TSBooleanKeyword" === nodeType ||
            "TSBigIntKeyword" === nodeType ||
        Severity: Critical
        Found in packages/babel-types/src/validators/generated/index.js - About 1 day to fix

          File config-chain.js has 596 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          // @flow
          
          import path from "path";
          import buildDebug from "debug";
          import type { Handler } from "gensync";
          Severity: Major
          Found in packages/babel-core/src/config/config-chain.js - About 1 day to fix

            Function parseExprAtom has 239 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              parseExprAtom(refExpressionErrors?: ?ExpressionErrors): N.Expression {
                // If a division operator appears in an expression position, the
                // tokenizer got confused, and we force it to read a regexp instead.
                if (this.state.type === tt.slash) this.readRegexp();
            
            
            Severity: Major
            Found in packages/babel-parser/src/parser/expression.js - About 1 day to fix

              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

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

                  function convertJSXIdentifier(node, parent) {
                    if (t.isJSXIdentifier(node)) {
                      if (node.name === "this" && t.isReferenced(node, parent)) {
                        return t.thisExpression();
                      } else if (t.isValidIdentifier(node.name, false)) {
                packages/babel-helper-builder-react-jsx/src/index.js on lines 55..78

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

                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 convertJSXIdentifier(node, parent) {
                    if (t.isJSXIdentifier(node)) {
                      if (node.name === "this" && t.isReferenced(node, parent)) {
                        return t.thisExpression();
                      } else if (t.isValidIdentifier(node.name, false)) {
                Severity: Major
                Found in packages/babel-helper-builder-react-jsx/src/index.js and 1 other location - About 1 day to fix
                packages/babel-helper-builder-react-jsx-experimental/src/index.js on lines 466..489

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

                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 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
                            Severity
                            Category
                            Status
                            Source
                            Language