Showing 52 of 52 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
export function findupFile(name: string, refRootPath?: string) {
const ref = refRootPath || process.cwd()
try {
return _findup.file(ref, name)
} catch (e) {
- Read upRead up
- Create a ticketCreate a ticket
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 88.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
test('duplicate:ignore', () => {
createSameFileInSrcAndDistDir('a2', 'new', 'old')
const { ignored, copied } = runCopy({ duplicate: 'ignore' })
testFile('a2', 'old')
expect(ignored).toHaveLength(1)
- Read upRead up
- Create a ticketCreate a ticket
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 88.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
test('duplicate:overwrite', () => {
createSameFileInSrcAndDistDir('a3', 'new', 'old')
const { overwritten, copied } = runCopy({ duplicate: 'overwrite' })
testFile('a3', 'new')
expect(overwritten).toHaveLength(1)
- Read upRead up
- Create a ticketCreate a ticket
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 88.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
export function findupDir(name: string, refRootPath?: string) {
const ref = refRootPath || process.cwd()
try {
return _findup.dir(ref, name)
} catch (e) {
- Read upRead up
- Create a ticketCreate a ticket
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 88.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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