qiu8310/serpent

View on GitHub
projects/serpent-common-cli/src/run/index.ts

Summary

Maintainability
A
3 hrs
Test Coverage

Function run has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

export function run(args: string | string[], options: any = {}): any {
  const { debug, output, ...opts } = options
  // 开启 debug 后还需要将环境变量 DURKA_NODE_DEBUG 设置成 true
  if (debug && process.env[typeof debug === 'string' ? debug : 'DURKA_NODE_DEBUG']) {
    return runNodeDebug(args, opts)
Severity: Minor
Found in projects/serpent-common-cli/src/run/index.ts - 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 runNodeDebug has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

export function runNodeDebug(args: string | string[], options: runTypes.Options & SilentOptions = {}) {
  const { silent, ...opts } = options
  if (typeof args === 'string') {
    let cmd = args
    if (/^\s*node\s/.test(cmd)) {
Severity: Minor
Found in projects/serpent-common-cli/src/run/index.ts - 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 runOutput has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export function runOutput(args: string | string[], options: runTypes.Options & SilentOptions = {}) {
  const { silent = true, ...opts } = options
  if (typeof args === 'string') {
    if (!silent) log(args)
    return execa.command(args, { ...opts, stdio: 'pipe' }).then(d => d.stdout)
Severity: Minor
Found in projects/serpent-common-cli/src/run/index.ts - 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