59naga/chopsticks

View on GitHub

Showing 28 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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                assert.deepStrictEqual(
                  parse('beep -t [ boop -o a.txt -o b.txt -q ] -v'.split(' '), {
                    nest: true,
                  }),
                  {
            Severity: Major
            Found in test/use-options/nest.js and 1 other location - About 2 hrs to fix
            test/use-options/nest.js on lines 73..88

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 79.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                assert.deepStrictEqual(
                  parse('beep -t [boop -o a.txt -o b.txt -q] -v'.split(' '), {
                    nest: true,
                  }),
                  {
            Severity: Major
            Found in test/use-options/nest.js and 1 other location - About 2 hrs to fix
            test/use-options/nest.js on lines 56..71

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 79.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            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

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                          if (array === false) {
                            if (opts.arrays && opts.arrays.indexOf(name) > -1) {
                              array = true;
                            }
                          }
                    Severity: Minor
                    Found in src/Flag.js and 1 other location - About 50 mins to fix
                    src/Flag.js on lines 90..94

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 51.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                          if (string === false) {
                            if (opts.strings && opts.strings.indexOf(name) > -1) {
                              string = true;
                            }
                          }
                    Severity: Minor
                    Found in src/Flag.js and 1 other location - About 50 mins to fix
                    src/Flag.js on lines 95..99

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 51.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                          assert.deepStrictEqual(
                            utils.parseArg('-foo0xdeadbeef', 'foo'),
                            {
                              flags: [
                                new Flag('short', 'f'),
                    Severity: Minor
                    Found in test/parse-arg.js and 1 other location - About 50 mins to fix
                    test/parse-arg.js on lines 76..86

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 51.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                          assert.deepStrictEqual(
                            utils.parseArg('-foo', 'bar'),
                            {
                              flags: [
                                new Flag('short', 'f'),
                    Severity: Minor
                    Found in test/parse-arg.js and 1 other location - About 50 mins to fix
                    test/parse-arg.js on lines 138..148

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 51.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Severity
                    Category
                    Status
                    Source
                    Language