59naga/chopsticks

View on GitHub
src/Chopsticks.js

Summary

Maintainability
D
2 days
Test Coverage

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

  parse(args) {
    if (process.env.NODE_ENV === 'production' && args instanceof Array === false) {
      throw new TypeError('args is not an array');
    }

Severity: Minor
Found in src/Chopsticks.js - About 6 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 90 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  parse(args) {
    if (process.env.NODE_ENV === 'production' && args instanceof Array === false) {
      throw new TypeError('args is not an array');
    }

Severity: Major
Found in src/Chopsticks.js - About 3 hrs to fix

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

      resolveNest(args) {
        const resolvedArgs = [];
    
        let level = 0;
        let nest = null;
    Severity: Minor
    Found in src/Chopsticks.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

    File Chopsticks.js has 282 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // dependencies
    import _get from 'lodash.get';
    import _set from 'lodash.set';
    import * as utils from './utils';
    
    
    Severity: Minor
    Found in src/Chopsticks.js - About 2 hrs to fix

      Function finalize has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        finalize(container = {}) {
          if (this.nestArgs.length === 0) {
            Object.keys(this.defaults).forEach((flag) => {
              const value = _get(container.flags, flag);
              if (value === undefined) {
      Severity: Major
      Found in src/Chopsticks.js - About 2 hrs to fix

        Function resolveNest has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          resolveNest(args) {
            const resolvedArgs = [];
        
            let level = 0;
            let nest = null;
        Severity: Minor
        Found in src/Chopsticks.js - About 1 hr to fix

          Function constructor has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            constructor(options = {}) {
              this.aliases = {};
              Object.keys(options.alias || {}).forEach((key) => {
                this.aliases[key] = utils.toArray(options.alias[key]);
              });
          Severity: Minor
          Found in src/Chopsticks.js - About 1 hr to fix

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

              constructor(options = {}) {
                this.aliases = {};
                Object.keys(options.alias || {}).forEach((key) => {
                  this.aliases[key] = utils.toArray(options.alias[key]);
                });
            Severity: Minor
            Found in src/Chopsticks.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

            Avoid too many return statements within this function.
            Open

                return value;
            Severity: Major
            Found in src/Chopsticks.js - About 30 mins to fix

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

                finalize(container = {}) {
                  if (this.nestArgs.length === 0) {
                    Object.keys(this.defaults).forEach((flag) => {
                      const value = _get(container.flags, flag);
                      if (value === undefined) {
              Severity: Minor
              Found in src/Chopsticks.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