Showing 1,982 of 1,982 total issues

Function stringifyValidator has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function stringifyValidator(validator, nodePrefix) {
  if (validator === undefined) {
    return "any";
  }

Severity: Minor
Found in packages/babel-types/scripts/utils/stringifyValidator.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 createRegExpFeaturePlugin has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

export function createRegExpFeaturePlugin({ name, feature, options = {} }) {
  return {
    name,
    pre() {
      const { file } = this;
Severity: Minor
Found in packages/babel-helper-create-regexp-features-plugin/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

Function getLetReferences has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

  getLetReferences() {
    const block = this.block;

    let declarators = [];

Severity: Minor
Found in packages/babel-plugin-transform-block-scoping/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

Function permuteHelperAST has 75 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function permuteHelperAST(file, metadata, id, localBindings, getDependency) {
  if (localBindings && !id) {
    throw new Error("Unexpected local bindings for module-based helpers.");
  }

Severity: Major
Found in packages/babel-helpers/src/index.js - About 3 hrs to fix

    Consider simplifying this complex logical expression.
    Open

      if (
        // Although parentheses wouldn"t hurt around sequence
        // expressions in the head of for loops, traditional style
        // dictates that e.g. i++, j++ should not be wrapped with
        // parentheses.
    Severity: Critical
    Found in packages/babel-generator/src/node/parentheses.js - About 3 hrs to fix

      Function VariableDeclarator has 75 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            VariableDeclarator(path, file) {
              if (!path.get("id").isObjectPattern()) {
                return;
              }
      
      
      Severity: Major
      Found in packages/babel-plugin-proposal-object-rest-spread/src/index.js - About 3 hrs to fix

        Function flowEnumBody has 74 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            flowEnumBody(node: N.Node, { enumName, nameLoc }): N.Node {
              const explicitType = this.flowEnumParseExplicitType({ enumName });
              this.expect(tt.braceL);
              const members = this.flowEnumMembers({ enumName, explicitType });
        
        
        Severity: Major
        Found in packages/babel-parser/src/plugins/flow.js - About 2 hrs to fix

          Function exit has 74 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              exit(path) {
                const {
                  scope,
                  seen,
                  imported,

            Function buildJSXElementCall has 74 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              function buildJSXElementCall(path, file) {
                const openingPath = path.get("openingElement");
                openingPath.parent.children = t.react.buildChildren(openingPath.parent);
            
                const tagExpr = convertJSXIdentifier(
            Severity: Major
            Found in packages/babel-helper-builder-react-jsx-experimental/src/index.js - About 2 hrs to fix

              File options.js has 290 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              // @flow
              
              import fs from "fs";
              
              import commander from "commander";
              Severity: Minor
              Found in packages/babel-cli/src/babel/options.js - About 2 hrs to fix

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

                    for (const [plugin, pass] of passPairs) {
                      const fn = plugin.post;
                      if (fn) {
                        const result = fn.call(pass, file);
                
                
                Severity: Major
                Found in packages/babel-core/src/transformation/index.js and 1 other location - About 2 hrs to fix
                packages/babel-core/src/transformation/index.js on lines 89..104

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

                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

                    for (const [plugin, pass] of passPairs) {
                      const fn = plugin.pre;
                      if (fn) {
                        const result = fn.call(pass, file);
                
                
                Severity: Major
                Found in packages/babel-core/src/transformation/index.js and 1 other location - About 2 hrs to fix
                packages/babel-core/src/transformation/index.js on lines 114..129

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

                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 Program has 73 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        Program(path, state) {
                          const { file } = state;
                          let fileJsxPragma = null;
                
                          if (!GLOBAL_TYPES.has(path.node)) {
                Severity: Major
                Found in packages/babel-plugin-transform-typescript/src/index.js - About 2 hrs to fix

                  Function convertNodes has 73 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function convertNodes(ast, code) {
                    const astTransformVisitor = {
                      noScope: true,
                      enter(path) {
                        const { node } = path;
                  Severity: Major
                  Found in eslint/babel-eslint-parser/src/convert/convertAST.js - About 2 hrs to fix

                    Function CallExpression has 73 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          CallExpression(path) {
                            if (!hasArgumentPlaceholder(path.node)) {
                              return;
                            }
                            const { node, scope } = path;
                    Severity: Major
                    Found in packages/babel-plugin-proposal-partial-application/src/index.js - About 2 hrs to fix

                      Function isReactCall has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function isReactCall(path) {
                        // If the callee is not a member expression, then check if it matches
                        // a named import, e.g. `import {forwardRef} from 'react'`.
                        if (!t.isMemberExpression(path.node.callee)) {
                          const callee = path.get("callee");
                      Severity: Minor
                      Found in packages/babel-plugin-transform-react-pure-annotations/src/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 parseSwitchStatement has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                      Open

                        parseSwitchStatement(node: N.SwitchStatement): N.SwitchStatement {
                          this.next();
                          node.discriminant = this.parseHeaderExpression();
                          const cases = (node.cases = []);
                          this.expect(tt.braceL);
                      Severity: Minor
                      Found in packages/babel-parser/src/parser/statement.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 transformFile has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function* transformFile(file: File, pluginPasses: PluginPasses): Handler<void> {
                        for (const pluginPairs of pluginPasses) {
                          const passPairs = [];
                          const passes = [];
                          const visitors = [];
                      Severity: Minor
                      Found in packages/babel-core/src/transformation/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 resolveStandardizedName has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function resolveStandardizedName(
                        type: "plugin" | "preset",
                        name: string,
                        dirname: string = process.cwd(),
                      ) {
                      Severity: Minor
                      Found in packages/babel-core/src/config/files/plugins.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 applyTargetDecorators has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function applyTargetDecorators(path, state, decoratedProps) {
                        const name = path.scope.generateDeclaredUidIdentifier(
                          path.isClass() ? "class" : "obj",
                        );
                      
                      
                      Severity: Minor
                      Found in packages/babel-plugin-proposal-decorators/src/transformer-legacy.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

                      Severity
                      Category
                      Status
                      Source
                      Language