packages/babel-helper-module-transforms/src/index.js

Summary

Maintainability
C
1 day
Test Coverage

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

import assert from "assert";
import * as t from "@babel/types";
import template from "@babel/template";
import chunk from "lodash/chunk";

Severity: Minor
Found in packages/babel-helper-module-transforms/src/index.js - About 2 hrs 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 buildExportInitializationStatements has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

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

        Function buildNamespaceReexport has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function buildNamespaceReexport(metadata, namespace, loose) {
          return (loose
            ? template.statement`
                Object.keys(NAMESPACE).forEach(function(key) {
                  if (key === "default" || key === "__esModule") return;
        Severity: Minor
        Found in packages/babel-helper-module-transforms/src/index.js - About 1 hr to fix

          Function buildExportNameListDeclaration has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          function buildExportNameListDeclaration(
            programPath: NodePath,
            metadata: ModuleMetadata,
          ) {
            const exportedVars = Object.create(null);
          Severity: Minor
          Found in packages/babel-helper-module-transforms/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

          Function buildExportInitializationStatements has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          function buildExportInitializationStatements(
            programPath: NodePath,
            metadata: ModuleMetadata,
            loose: boolean = false,
          ) {
          Severity: Minor
          Found in packages/babel-helper-module-transforms/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

          Function buildNamespaceInitStatements has a Cognitive Complexity of 9 (exceeds 5 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 55 mins 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 rewriteModuleStatementsAndPrepareHeader has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          export function rewriteModuleStatementsAndPrepareHeader(
            path: NodePath,
            {
              exportName,
              strict,
          Severity: Minor
          Found in packages/babel-helper-module-transforms/src/index.js - About 35 mins 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

          There are no issues that match your filters.

          Category
          Status