Showing 1,982 of 1,982 total issues

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

export function createDescriptor(
  pair: PluginItem,
  dirname: string,
  {
    type,
Severity: Minor
Found in packages/babel-core/src/config/config-descriptors.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 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 assertPluginItem has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

function assertPluginItem(loc: GeneralPath, value: mixed): PluginItem {
  if (Array.isArray(value)) {
    if (value.length === 0) {
      throw new Error(`${msg(loc)} must include an object`);
    }
Severity: Minor
Found in packages/babel-core/src/config/validation/option-assertions.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 getDeepestCommonAncestorFrom has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

export function getDeepestCommonAncestorFrom(
  paths: Array<NodePath>,
  filter?: Function,
): NodePath {
  if (!paths.length) {
Severity: Minor
Found in packages/babel-traverse/src/path/ancestry.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

File plugins.js has 274 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// @flow
/*
 * This file is auto-generated! Do not modify it directly.
 * To re-generate run 'make build'
 */
Severity: Minor
Found in packages/babel-standalone/src/generated/plugins.js - About 2 hrs to fix

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

            exit(path, state) {
              if (!isModule(path)) return;
    
              // Rename the bindings auto-injected into the scope so there is no
              // risk of conflict between the bindings.
    Severity: Major
    Found in packages/babel-plugin-transform-modules-commonjs/src/index.js - About 2 hrs to fix

      Function validatePlugins has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function validatePlugins(plugins: PluginList) {
        if (hasPlugin(plugins, "decorators")) {
          if (hasPlugin(plugins, "decorators-legacy")) {
            throw new Error(
              "Cannot use the decorators and decorators-legacy plugin together",
      Severity: Major
      Found in packages/babel-parser/src/plugin-utils.js - About 2 hrs to fix

        Function explode has 64 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function explode(visitor) {
          if (visitor._exploded) return visitor;
          visitor._exploded = true;
        
          // normalise pipes
        Severity: Major
        Found in packages/babel-traverse/src/visitors.js - About 2 hrs to fix

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

                  } else if (isNewLine(ch)) {
                    out += this.input.slice(chunkStart, this.state.pos);
                    out += this.jsxReadNewLine(false);
                    chunkStart = this.state.pos;
                  } else {
          Severity: Major
          Found in packages/babel-parser/src/plugins/jsx/index.js and 1 other location - About 2 hrs to fix
          packages/babel-parser/src/plugins/jsx/index.js on lines 124..130

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

          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 (isNewLine(ch)) {
                        out += this.input.slice(chunkStart, this.state.pos);
                        out += this.jsxReadNewLine(true);
                        chunkStart = this.state.pos;
                      } else {
          Severity: Major
          Found in packages/babel-parser/src/plugins/jsx/index.js and 1 other location - About 2 hrs to fix
          packages/babel-parser/src/plugins/jsx/index.js on lines 168..174

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

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

              flowParseObjectTypeProperty(
                node: N.FlowObjectTypeProperty | N.FlowObjectTypeSpreadProperty,
                isStatic: boolean,
                protoStart: ?number,
                variance: ?N.FlowVariance,
          Severity: Major
          Found in packages/babel-parser/src/plugins/flow.js - About 2 hrs to fix

            Function isStatement has 63 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function isStatement(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 - About 2 hrs to fix

              Function toAssignable has 63 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                toAssignable(node: Node): Node {
                  let parenthesized = undefined;
                  if (node.type === "ParenthesizedExpression" || node.extra?.parenthesized) {
                    parenthesized = unwrapParenthesizedExpression(node);
                    if (
              Severity: Major
              Found in packages/babel-parser/src/parser/lval.js - About 2 hrs to fix

                Function cloneNode has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export default function cloneNode<T: Object>(
                  node: T,
                  deep: boolean = true,
                  withoutLoc: boolean = false,
                ): T {
                Severity: Major
                Found in packages/babel-types/src/clone/cloneNode.js - About 2 hrs to fix

                  Function flowParseDeclareModule has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      flowParseDeclareModule(node: N.FlowDeclareModule): N.FlowDeclareModule {
                        this.scope.enter(SCOPE_OTHER);
                  
                        if (this.match(tt.string)) {
                          node.id = this.parseExprAtom();
                  Severity: Major
                  Found in packages/babel-parser/src/plugins/flow.js - About 2 hrs to fix

                    Function VariableDeclaration has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          VariableDeclaration(path) {
                            const { node, scope, parent } = path;
                            if (t.isForXStatement(parent)) return;
                            if (!parent || !path.container) return; // i don't know why this is necessary - TODO
                            if (!variableDeclarationHasPattern(node)) return;
                    Severity: Major
                    Found in packages/babel-plugin-transform-destructuring/src/index.js - About 2 hrs to fix

                      File utils.js has 270 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      // @flow
                      import is from "../validators/is";
                      import { validateField, validateChild } from "../validators/validate";
                      
                      export const VISITOR_KEYS: { [string]: Array<string> } = {};
                      Severity: Minor
                      Found in packages/babel-types/src/definitions/utils.js - About 2 hrs to fix

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

                        // @flow
                        import corejs3Polyfills from "core-js-compat/data";
                        import findSuggestion from "levenary";
                        import invariant from "invariant";
                        import { coerce, SemVer } from "semver";
                        Severity: Minor
                        Found in packages/babel-preset-env/src/normalize-options.js - About 2 hrs to fix

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

                          function collect(
                            value: string | any,
                            previousValue: Array<string>,
                          ): Array<string> {
                            // If the user passed the option with no value, like "babel file.js --presets", do nothing.
                          Severity: Major
                          Found in packages/babel-cli/src/babel/options.js and 1 other location - About 2 hrs to fix
                          packages/babel-cli/src/babel-external-helpers.js on lines 6..16

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

                          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 collect(
                            value: string | any,
                            previousValue: Array<string>,
                          ): Array<string> {
                            // If the user passed the option with no value, like "babel-external-helpers --whitelist", do nothing.
                          Severity: Major
                          Found in packages/babel-cli/src/babel-external-helpers.js and 1 other location - About 2 hrs to fix
                          packages/babel-cli/src/babel/options.js on lines 341..351

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

                          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