gerard2p/cmd-line

View on GitHub

Showing 5 of 7 total issues

Function parse has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    static parse (/* istanbul ignore next */params = []) {
        let ARGS = params.slice();
        let arg;
        let finalargs = [];
        for (const idx in this.args) {
Severity: Minor
Found in src/Command.js - About 4 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 parse has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    static parse (/* istanbul ignore next */params = []) {
        let ARGS = params.slice();
        let arg;
        let finalargs = [];
        for (const idx in this.args) {
Severity: Major
Found in src/Command.js - About 2 hrs to fix

    Avoid deeply nested control flow statements.
    Open

                            if (options[camelizedOption] === undefined) {
                                throw new Error(`The option ${option.tag || /* istanbul ignore next */option.shortag} needs a value`);
                            }
    Severity: Major
    Found in src/Command.js - About 45 mins to fix

      Function execute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          static execute (args) {
              if (this.args.length > 0 && args.length === 0) {
                  print(this.Info);
                  return 1;
              } else if (args.length === 1 && (args[0] === '-h' || args[0] === '--help')) {
      Severity: Minor
      Found in src/Command.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 deeply nested control flow statements.
      Open

                          if (arg.indexOf('--') === -1 && len > 0) {
                              options[camelizedOption] = true;
                              opts[index] = opts[index].replace(st, '');
                          }
      Severity: Major
      Found in src/Command.js - About 45 mins to fix
        Severity
        Category
        Status
        Source
        Language