ember-cli/ember-cli

View on GitHub
lib/models/command.js

Summary

Maintainability
C
1 day
Test Coverage
A
95%

Function validateAndRun has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  async validateAndRun(args) {
    let commandOptions = this.parseArgs(args);

    // If the `help` option was passed, resolve with `callHelp` to call the `help` command:
    if (commandOptions && (commandOptions.options.help || commandOptions.options.h)) {
Severity: Minor
Found in lib/models/command.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 validateAndRun has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async validateAndRun(args) {
    let commandOptions = this.parseArgs(args);

    // If the `help` option was passed, resolve with `callHelp` to call the `help` command:
    if (commandOptions && (commandOptions.options.help || commandOptions.options.h)) {
Severity: Minor
Found in lib/models/command.js - About 1 hr to fix

Function parseArgs has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  parseArgs(commandArgs) {
    let knownOpts = {}; // Parse options
    let commandOptions = {};
    let parsedOptions;

Severity: Minor
Found in lib/models/command.js - About 1 hr to fix

Function assignOption has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  assignOption(option, parsedOptions, commandOptions) {
    let isValid = isValidParsedOption(option, parsedOptions[option.name]);
    if (isValid) {
      if (parsedOptions[option.name] === undefined) {
        if (option.default !== undefined) {
Severity: Minor
Found in lib/models/command.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 isValidAlias has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

function isValidAlias(alias, expectedType) {
  let type = typeof alias;
  let value, valueType;
  if (type === 'string') {
    return true;
Severity: Minor
Found in lib/models/command.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 parseAlias has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  parseAlias(option, alias) {
    let aliasType = typeof alias;
    let key, value, aliasValue;

    if (isValidAlias(alias, option.type)) {
Severity: Minor
Found in lib/models/command.js - About 1 hr to fix

Function parseAlias has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  parseAlias(option, alias) {
    let aliasType = typeof alias;
    let key, value, aliasValue;

    if (isValidAlias(alias, option.type)) {
Severity: Minor
Found in lib/models/command.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 validateAlias has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  validateAlias(option, alias) {
    let key = alias.key;
    let value = alias.value;

    if (!this.optionsAliases[key]) {
Severity: Minor
Found in lib/models/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

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

  parseArgs(commandArgs) {
    let knownOpts = {}; // Parse options
    let commandOptions = {};
    let parsedOptions;

Severity: Minor
Found in lib/models/command.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

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

function isValidParsedOption(option, parsedOption) {
  // option.name didn't parse
  if (parsedOption === undefined) {
    // no default
    if (option.default === undefined) {
Severity: Minor
Found in lib/models/command.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