qiu8310/serpent

View on GitHub

Showing 28 of 52 total issues

Function peer has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export function peer(rootDir: string) {
  const pkgFile = path.join(rootDir, 'package.json')
  /* eslint-disable @typescript-eslint/no-var-requires */
  const pkg = require(pkgFile)

Severity: Minor
Found in projects/serpent-cli/src/serpent-peer.ts - 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 getAllExportFiles has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

function getAllExportFiles(file: string) {
  const entries: string[] = []
  const stat = fs.statSync(file)
  if (stat.isFile() && isModuleFile(file)) {
    entries.push(file)
Severity: Minor
Found in projects/serpent-cli/src/serpent-index.ts - 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 generateModule has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

  rootDir: string,
  srcDir: string,
  distDir: string,
  key: string,
  entries: string[],
Severity: Minor
Found in projects/serpent-cli/src/serpent-index.ts - About 45 mins to fix

Function make has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export function make(options: {
  /** 项目的 package.json 内容 */
  pkg: any
  /** 入口文件 */
  entry: string
Severity: Minor
Found in projects/serpent-rollup-kits/src/make.ts - 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 mkdir has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function mkdir(dir: string, originalDir?: string) {
  const parent = path.dirname(dir)
  if (parent && parent !== dir) {
    if (!fs.existsSync(parent)) mkdir(parent, originalDir || dir)
    fs.mkdirSync(dir)
Severity: Minor
Found in projects/serpent-cli/src/copy.ts - 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

Function filterVersions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export function filterVersions(versions: string[], mode: VERSION_FILTER_MODE = 'all') {
  const map = new Map<string, string>()
  let maxMajor = -1
  const targets = versions.map(v => parseVersion(v)).filter(t => t != null) as VERSION_INSTANCE[]

Severity: Minor
Found in projects/serpent-common-cli/src/version.ts - 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

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

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

export function parseProjectInstallName(installName: string) {
  let scope = ''
  let range = ''
  let tag = ''
  let name = ''
Severity: Minor
Found in projects/serpent-common-cli/src/fs/project.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

Severity
Category
Status
Source
Language