Showing 1,982 of 1,982 total issues

Function _resyncKey has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

export function _resyncKey() {
  if (!this.container) return;

  if (this.node === this.container[this.key]) return;

Severity: Minor
Found in packages/babel-traverse/src/path/context.js - About 1 hr 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 updateScopeInfo has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  updateScopeInfo(wrappedInClosure) {
    const blockScope = this.blockPath.scope;

    const parentScope =
      blockScope.getFunctionParent() || blockScope.getProgramParent();
Severity: Minor
Found in packages/babel-plugin-transform-block-scoping/src/index.js - About 1 hr 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 3 locations. Consider refactoring.
Open

  if (node.extends && node.extends.length) {
    this.space();
    this.word("extends");
    this.space();
    this.printList(node.extends, node);
Severity: Major
Found in packages/babel-generator/src/generators/flow.js and 2 other locations - About 1 hr to fix
packages/babel-generator/src/generators/flow.js on lines 313..318
packages/babel-generator/src/generators/flow.js on lines 319..324

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

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 3 locations. Consider refactoring.
Open

  if (node.implements && node.implements.length) {
    this.space();
    this.word("implements");
    this.space();
    this.printList(node.implements, node);
Severity: Major
Found in packages/babel-generator/src/generators/flow.js and 2 other locations - About 1 hr to fix
packages/babel-generator/src/generators/flow.js on lines 313..318
packages/babel-generator/src/generators/flow.js on lines 353..358

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

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 3 locations. Consider refactoring.
Open

  if (node.mixins && node.mixins.length) {
    this.space();
    this.word("mixins");
    this.space();
    this.printList(node.mixins, node);
Severity: Major
Found in packages/babel-generator/src/generators/flow.js and 2 other locations - About 1 hr to fix
packages/babel-generator/src/generators/flow.js on lines 319..324
packages/babel-generator/src/generators/flow.js on lines 353..358

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

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

  parseClassBody(
    constructorAllowsSuper: boolean,
    oldStrict?: boolean,
  ): N.ClassBody {
    this.classScope.enter();
Severity: Minor
Found in packages/babel-parser/src/parser/statement.js - About 1 hr to fix

    Function buildNamespaceInitStatements has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function buildNamespaceInitStatements(
      metadata: ModuleMetadata,
      sourceMetadata: SourceModuleMetadata,
      loose: boolean = false,
    ) {
    Severity: Minor
    Found in packages/babel-helper-module-transforms/src/index.js - About 1 hr to fix

      Function verifyUsedFeatures has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function verifyUsedFeatures(path, file) {
        if (hasOwnDecorators(path.node)) {
          if (!hasFeature(file, FEATURES.decorators)) {
            throw path.buildCodeFrameError(
              "Decorators are not enabled." +
      Severity: Minor
      Found in packages/babel-helper-create-class-features-plugin/src/features.js - About 1 hr to fix

        Function generateCode has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export default function generateCode(
          pluginPasses: PluginPasses,
          file: File,
        ): {
          outputCode: string,
        Severity: Minor
        Found in packages/babel-core/src/transformation/file/generate.js - About 1 hr to fix

          Function ObjectExpression has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                ObjectExpression(path, file) {
                  if (!hasSpread(path.node)) return;
          
                  let helper;
                  if (loose) {
          Severity: Minor
          Found in packages/babel-plugin-proposal-object-rest-spread/src/index.js - About 1 hr to fix

            Function buildHas has 43 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              buildHas(ret: string) {
                const body = this.body;
            
                let retCheck;
                const has = this.has;
            Severity: Minor
            Found in packages/babel-plugin-transform-block-scoping/src/index.js - About 1 hr to fix

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

                      for (const name of Object.keys(path.getOuterBindingIdentifiers(path))) {
                        specifiers.push(
                          t.exportSpecifier(t.identifier(name), t.identifier(name)),
                        );
                      }
              packages/babel-plugin-transform-destructuring/src/index.js on lines 473..477

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

              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

                      for (const name of Object.keys(path.getOuterBindingIdentifiers(path))) {
                        specifiers.push(
                          t.exportSpecifier(t.identifier(name), t.identifier(name)),
                        );
                      }
              Severity: Major
              Found in packages/babel-plugin-transform-destructuring/src/index.js and 1 other location - About 1 hr to fix
              packages/babel-plugin-proposal-object-rest-spread/src/index.js on lines 407..411

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

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

                  Program(path) {
                    // We need to compute these in advance because removing nodes would
                    // invalidate the paths.
                    const exp = path.get(exportPath);
                    const imps = importPaths.map(p => path.get(p));
              Severity: Minor
              Found in packages/babel-helpers/src/index.js - About 1 hr to fix

                Function wrapSuperCall has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  function wrapSuperCall(bareSuper, superRef, thisRef, body) {
                    const bareSuperNode = bareSuper.node;
                    let call;
                
                    if (classState.isLoose) {
                Severity: Minor
                Found in packages/babel-plugin-transform-classes/src/transformClass.js - About 1 hr to fix

                  Function ImportDeclaration has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function ImportDeclaration(node: Object) {
                    this.word("import");
                    this.space();
                  
                    if (node.importKind === "type" || node.importKind === "typeof") {
                  Severity: Minor
                  Found in packages/babel-generator/src/generators/modules.js - About 1 hr to fix

                    Function enter has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          enter(path: NodePath) {
                            const { node } = path;
                            const { object, property } = node;
                    
                            // ignore namespace
                    Severity: Minor
                    Found in packages/babel-preset-env/src/polyfills/corejs2/usage-plugin.js - About 1 hr to fix

                      Consider simplifying this complex logical expression.
                      Open

                            if (
                              this.hasPrecedingLineBreak() ||
                              // All the following expressions are ambiguous:
                              //   await + 0, await - 0, await ( 0 ), await [ 0 ], await / 0 /u, await ``
                              this.match(tt.plusMin) ||
                      Severity: Critical
                      Found in packages/babel-parser/src/parser/expression.js - About 1 hr to fix

                        Consider simplifying this complex logical expression.
                        Open

                          if (
                            nodeType === "PatternLike" ||
                            "Identifier" === nodeType ||
                            "RestElement" === nodeType ||
                            "AssignmentPattern" === nodeType ||
                        Severity: Critical
                        Found in packages/babel-types/src/validators/generated/index.js - About 1 hr to fix

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

                                    if (node.body.body.length === 0 && path.isCompletionRecord()) {
                                      node.body.body.unshift(
                                        t.expressionStatement(scope.buildUndefinedNode()),
                                      );
                                    }
                          Severity: Major
                          Found in packages/babel-plugin-transform-destructuring/src/index.js and 1 other location - About 1 hr to fix
                          packages/babel-plugin-proposal-object-rest-spread/src/index.js on lines 489..493

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

                          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