tunnckoCore/gibon

View on GitHub
yaro/yaro-create-cli/src/index.js

Summary

Maintainability
D
2 days
Test Coverage

Function getCommands has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

function getCommands(cfg) {
  const cmds = { ...cfg.commands };
  let commands = Object.entries(cmds);
  let rootCmd = null;

Severity: Minor
Found in yaro/yaro-create-cli/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 findMatchCommand has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

function findMatchCommand(entries, meta) {
  const match = entries.find(([name, cmd]) => {
    if (cmd.isYaroCommand) {
      let matched = false;

Severity: Minor
Found in yaro/yaro-create-cli/src/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 yaroCreateCli has 67 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function yaroCreateCli(argv, config) {
  const cfg = Array.isArray(argv) ? { argv, ...config } : { argv: [], ...argv };

  if (cfg.buildOutput && typeof cfg.buildOutput !== 'function') {
    throw new TypeError('option `buildOutput` should be function when given');
Severity: Major
Found in yaro/yaro-create-cli/src/index.js - About 2 hrs to fix

    Function yaroCreateCli has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    async function yaroCreateCli(argv, config) {
      const cfg = Array.isArray(argv) ? { argv, ...config } : { argv: [], ...argv };
    
      if (cfg.buildOutput && typeof cfg.buildOutput !== 'function') {
        throw new TypeError('option `buildOutput` should be function when given');
    Severity: Minor
    Found in yaro/yaro-create-cli/src/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 getCommands has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function getCommands(cfg) {
      const cmds = { ...cfg.commands };
      let commands = Object.entries(cmds);
      let rootCmd = null;
    
    
    Severity: Minor
    Found in yaro/yaro-create-cli/src/index.js - About 1 hr to fix

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

      function findMatchCommand(entries, meta) {
        const match = entries.find(([name, cmd]) => {
          if (cmd.isYaroCommand) {
            let matched = false;
      
      
      Severity: Minor
      Found in yaro/yaro-create-cli/src/index.js - About 1 hr to fix

        Function tryCatch has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        async function tryCatch(code, meta, fn) {
          let result = null;
          try {
            result = await fn(meta.argv);
          } catch (err) {
        Severity: Minor
        Found in yaro/yaro-create-cli/src/index.js - About 1 hr to fix

          Function tryCatch has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          async function tryCatch(code, meta, fn) {
            let result = null;
            try {
              result = await fn(meta.argv);
            } catch (err) {
          Severity: Minor
          Found in yaro/yaro-create-cli/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 getCliInfo has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          function getCliInfo(rootCommand, commands, cfg) {
            const version = cfg.version || '0.0.0';
          
            if (rootCommand && rootCommand.cli) {
              const { name, usage } = rootCommand.cli;
          Severity: Minor
          Found in yaro/yaro-create-cli/src/index.js - About 45 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

          Avoid too many return statements within this function.
          Open

              return;
          Severity: Major
          Found in yaro/yaro-create-cli/src/index.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                  return;
            Severity: Major
            Found in yaro/yaro-create-cli/src/index.js - About 30 mins to fix

              There are no issues that match your filters.

              Category
              Status