59naga/chopsticks

View on GitHub

Showing 19 of 28 total issues

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

File parse-arg.js has 347 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// dependencies
import assert from 'assert';

// target
import Flag from '../src/Flag';
Severity: Minor
Found in test/parse-arg.js - About 4 hrs to fix

    File mixin.js has 337 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // dependencies
    import assert from 'assert';
    import sinon from 'sinon';
    
    // target
    Severity: Minor
    Found in test/use-options/mixin.js - About 4 hrs to fix

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

              createAttribute(opts = {}) {
                let boolean = false;
                let string = false;
                let array = false;
                let object = false;
            Severity: Minor
            Found in src/Flag.js - About 1 hr 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 parseShortFlags has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export function parseShortFlags(name, value, opts = {}) {
                    const flags = [];
                  
                    const chunks = arrayFrom(name);
                    const breakWord = /[\/-]/;
                  Severity: Minor
                  Found in src/utils.js - About 1 hr 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 parseArg has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function parseArg(arg, nextArg, opts = {}) {
                    if (isntFlag(arg)) {
                      return { flags: [], validNext: false };
                    }
                  
                  
                  Severity: Minor
                  Found in src/utils.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

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

                    export function parseArg(arg, nextArg, opts = {}) {
                      if (isntFlag(arg)) {
                        return { flags: [], validNext: false };
                      }
                    
                    
                    Severity: Minor
                    Found in src/utils.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 isValidValue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                      isValidValue(arg, opts = {}) {
                        if (arg === undefined) {
                          return false;
                        }
                    
                    
                    Severity: Minor
                    Found in src/Flag.js - About 35 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 false;
                    Severity: Major
                    Found in src/Flag.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

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

                        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

                          Severity
                          Category
                          Status
                          Source
                          Language