Showing 28 of 52 total issues
Function make
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function make(options: {
/** 项目的 package.json 内容 */
pkg: any
/** 入口文件 */
entry: string
- Create a ticketCreate a ticket
Function makeCli
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function makeCli(
srcKeys: string[] = [],
options: Omit<RollupOptions, 'input' | 'plugins'> & { plugins?: Parameters<typeof getPlugins>[0] } = {}
) {
const { plugins, ...restOptions } = options
- Create a ticketCreate a ticket
Function getPlugins
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
export function getPlugins(
options: {
tsConfigPaths?: boolean | Parameters<typeof tsConfigPaths>[0]
run?: boolean | Parameters<typeof run>[0]
replace?: boolean | Parameters<typeof replace>[0]
- Read upRead up
- Create a ticketCreate a ticket
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 makeLib
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function makeLib(options: Omit<RollupOptions, 'input'> & { modules?: Record<string, string> } = {}) {
const { modules, ...rest } = options
const rootDir = getRootDir()
const srcDir = path.join(rootDir, 'src')
const pkg = require(path.join(rootDir, 'package.json'))
- Create a ticketCreate a ticket
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)
- Read upRead up
- Create a ticketCreate a ticket
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 tryGetProjectBinFile
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
export function tryGetProjectBinFile(rootDir: string, cmdName?: string) {
let bin = ''
let file = ''
try {
- Read upRead up
- Create a ticketCreate a ticket
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 cmd
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function cmd<Opts, Env>(
params: {
/**
* **字符串的表示法:**
* ```
- Create a ticketCreate a ticket
Function installDurkaScript
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
export function installDurkaScript(options: {
name: string
subname: string
content: string
devOnly?: boolean
- Read upRead up
- Create a ticketCreate a ticket
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)) {
- Read upRead up
- Create a ticketCreate a ticket
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 fetch
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function fetch(url) {
return new Promise((resolve, reject) => {
const isHTTPS = url.startsWith('https:')
let client
if (isHTTPS) {
- Create a ticketCreate a ticket
Function fetch
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function fetch(url: string) {
return new Promise<{ status?: number; message?: string; data?: any }>((resolve, reject) => {
const isHTTPS = url.startsWith('https:')
let client: http.ClientRequest
if (isHTTPS) {
- Create a ticketCreate a ticket
Function _getRemotePackageDetail
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
async function _getRemotePackageDetail(name: string, registry?: string, retryCount = 0): Promise<Detail> {
const pkgUrl = url.resolve(registry || getDurkaRegistry(), name)
try {
const { timeout, data: res = {} } = await wait(fetch(pkgUrl), 5000)
- Read upRead up
- Create a ticketCreate a ticket
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 installDurkaScript
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function installDurkaScript(options: {
name: string
subname: string
content: string
devOnly?: boolean
- Create a ticketCreate a ticket
Function filterVersions
has 29 lines of code (exceeds 25 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[]
- Create a ticketCreate a ticket
Function walk
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function walk(result: copy.Result, dir: string, walkOptions: copy.WalkOptions) {
const { fromDir, distDir } = walkOptions
const { includes, excludes, duplicate, rename } = walkOptions.options
fs.readdirSync(dir).forEach(name => {
const srcFile = path.join(dir, name)
- Create a ticketCreate a ticket
Function getPlugins
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function getPlugins(
options: {
tsConfigPaths?: boolean | Parameters<typeof tsConfigPaths>[0]
run?: boolean | Parameters<typeof run>[0]
replace?: boolean | Parameters<typeof replace>[0]
- Create a ticketCreate a ticket
Function copy
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function copy(fromDir: string, distDir: string, options: copy.Options = {}) {
const requiredOptions: copy.RequiredOptions = {
includes,
excludes,
rename,
- Create a ticketCreate a ticket
Function tryGetProjectBinFile
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function tryGetProjectBinFile(rootDir: string, cmdName?: string) {
let bin = ''
let file = ''
try {
- Create a ticketCreate a ticket
Function runDurkaScript
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export async function runDurkaScript(options: { name: string; subname?: string; args?: string[] }) {
const { name, args = [], subname: onlyRunSubname } = options
const root = tryGetProjectRootDir()
if (!root) throw new Error(`Not a valid node project, can not run durka script.`)
- Read upRead up
- Create a ticketCreate a ticket
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 getEnvSingly
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export function getEnvSingly<T>(key: string, options: env.Options<T>) {
const prefixedKey = options.prefix + key
const value = process.env[prefixedKey]
const defaultEnv = options.defaultEnv as any
- Read upRead up
- Create a ticketCreate a ticket
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"