packages/babel-helpers/src/index.js

Summary

Maintainability
D
2 days
Test Coverage

Function getHelperMetadata has 94 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function getHelperMetadata(file) {
  const globals = new Set();
  const localBindingNames = new Set();
  // Maps imported identifier -> helper name
  const dependencies = new Map();
Severity: Major
Found in packages/babel-helpers/src/index.js - About 3 hrs to fix

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

    function getHelperMetadata(file) {
      const globals = new Set();
      const localBindingNames = new Set();
      // Maps imported identifier -> helper name
      const dependencies = new Map();
    Severity: Minor
    Found in packages/babel-helpers/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 a Cognitive Complexity of 22 (exceeds 5 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: Minor
    Found in packages/babel-helpers/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

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

        function loadHelper(name) {
          if (!helperData[name]) {
            const helper = helpers[name];
            if (!helper) {
              throw Object.assign(new ReferenceError(`Unknown helper ${name}`), {
        Severity: Minor
        Found in packages/babel-helpers/src/index.js - About 1 hr to fix

          Function permuteHelperAST has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          function permuteHelperAST(file, metadata, id, localBindings, getDependency) {
          Severity: Minor
          Found in packages/babel-helpers/src/index.js - About 35 mins to fix

            Function loadHelper has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            function loadHelper(name) {
              if (!helperData[name]) {
                const helper = helpers[name];
                if (!helper) {
                  throw Object.assign(new ReferenceError(`Unknown helper ${name}`), {
            Severity: Minor
            Found in packages/babel-helpers/src/index.js - About 25 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