packages/babel-cli/src/babel/file.js

Summary

Maintainability
C
1 day
Test Coverage

Function default has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

export default async function ({
  cliOptions,
  babelOptions,
}: CmdOptions): Promise<void> {
  function buildResult(fileResults: Array<Object>): CompilationOutput {
Severity: Minor
Found in packages/babel-cli/src/babel/file.js - About 5 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 walk has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async function walk(filenames: Array<string>): Promise<void> {
    const _filenames = [];

    filenames.forEach(function (filename) {
      if (!fs.existsSync(filename)) return;
Severity: Major
Found in packages/babel-cli/src/babel/file.js - About 2 hrs to fix

    Function buildResult has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      function buildResult(fileResults: Array<Object>): CompilationOutput {
        const map = new sourceMap.SourceMapGenerator({
          file:
            cliOptions.sourceMapTarget ||
            path.basename(cliOptions.outFile || "") ||
    Severity: Major
    Found in packages/babel-cli/src/babel/file.js - About 2 hrs to fix

      Function files has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        async function files(filenames: Array<string>): Promise<void> {
          if (!cliOptions.skipInitialBuild) {
            await walk(filenames);
          }
      
      
      Severity: Minor
      Found in packages/babel-cli/src/babel/file.js - About 1 hr to fix

        Function results has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              _filenames.map(async function (filename: string): Promise<Object> {
                let sourceFilename = filename;
                if (cliOptions.outFile) {
                  sourceFilename = path.relative(
                    path.dirname(cliOptions.outFile),
        Severity: Minor
        Found in packages/babel-cli/src/babel/file.js - About 1 hr to fix

          There are no issues that match your filters.

          Category
          Status