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');
}
- Read upRead up
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');
}
Function resolveNest
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
resolveNest(args) {
const resolvedArgs = [];
let level = 0;
let nest = null;
- Read upRead up
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';
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) {
Function resolveNest
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
resolveNest(args) {
const resolvedArgs = [];
let level = 0;
let nest = null;
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]);
});
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]);
});
- Read upRead up
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;
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) {
- Read upRead up
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"