Showing 28 of 40 total issues
Function extract
has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring. Open
const extract = (readable: TPseudoReadable, _opts?: TOpts): TCodeRef[] => {
const {re, comments, bufferSize, offset} = normalizeOpts(_opts)
const refs: TCodeRef[] = []
const pushRef = (type: string, value: string, index: number) => refs.push({ type, value, index })
- Read upRead up
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 extract
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
const extract = (readable: TPseudoReadable, _opts?: TOpts): TCodeRef[] => {
const {re, comments, bufferSize, offset} = normalizeOpts(_opts)
const refs: TCodeRef[] = []
const pushRef = (type: string, value: string, index: number) => refs.push({ type, value, index })
Function extendObject
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
export const extendObject = ({result, sources, prefix, rules, index}: TExtendCtx & {result: Record<string, any>}) => {
for (const source of sources) {
for (const key of getProps(source)) {
const p = `${prefix ? prefix + '.' : ''}${key as string}`
const rule = getRule(p, rules)
- Read upRead up
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 sum
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const sum = (lcov: Lcov | string, prefix?: string): LcovDigest => {
if (typeof lcov === 'string') {
return sum(parse(lcov), prefix)
}
let brf = 0
Function processData
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export const processData = (...chunks: any[]) =>
chunks.length === 1
? chunks[0]
: expand(chunks.reduce((m, v, k) => {
if (v === VARARG) {
- Read upRead up
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 getExports
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
const getExports = async (contents: string, file: string): Promise<string[]> => {
const { lines } = parseContentsLayout(contents)
const refs = []
let r = false
for (const line of lines) {
- Read upRead up
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 hybridExportPlugin
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const hybridExportPlugin = (options: Record<string, any> = {}): Plugin => {
return {
name: 'hybrid-export',
setup(build) {
const {
Function formatEntry
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
const formatEntry = (entry: LcovEntry): string => {
const {
tn,
sf,
fn,
Function transformFile
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export const transformFile = async (file: TFileEntry, hooks: TTransformHook[], cwd = process.cwd()): Promise<TFileEntry | undefined> => {
let contents = file.contents
let path = file.path
for (const hook of hooks) {
if (hook.pattern.test(file.path)) {
- Read upRead up
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 setup
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
setup(build) {
const {
entryPoints: entries,
format,
absWorkingDir = process.cwd(),
Function spawn
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
): Promise<{stdout: string, stderr: string}> => new Promise((resolve, reject) => {
let status: number | null = 0
const now = Date.now()
const stderr: string[] = []
const stdout: string[] = []
Function createCtx
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const createCtx = (config: any, opts: TPopulateOpts, loader: TLoad, populate: TPopulate, sync = false): TCtx => {
const _opts = parseOpts(opts)
const rules = _opts.rules || {}
const _extendKeys = Object.keys(rules).filter(k => rules[k] === TStrategy.POPULATE)
const extendKeys = _extendKeys.length > 0 ? _extendKeys : ['extends']
Function mergeHits
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
const mergeHits = (entries: LcovEntry[]) => {
const hits: Record<string, number> = {}
for (const entry of entries) {
for (const [line, name] of entry.fn) {
- Read upRead up
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 get
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export const get = <T = any>(obj: any, path: string, defaultValue?: any): T => {
if (!path || path === '.') return obj
if (path.startsWith('.')) return get(obj, path.slice(1), defaultValue)
const travel = (regexp: RegExp) =>
- Read upRead up
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 getFilesList
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export const getFilesList = async (dir: string, recursive = true, files: string[] = []) => {
if (dir.endsWith('node_modules')) return files
for (const file of await fs.readdir(dir)) {
const name = `${dir}/${file}`
if (fss.statSync(name).isDirectory()) {
- Read upRead up
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 get
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export const get = <T = any>(obj: any, path?: string, defaultValue?: any): T => {
if (!path) return obj
if (path.startsWith('.')) return get(obj, path.slice(1), defaultValue)
const travel = (regexp: RegExp) =>
- Read upRead up
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
Avoid deeply nested control flow statements. Open
if (q === char && prev !== '\\') {
if (strLiteral && isDep(token.slice(-offset), re)) pushRef('dep', strLiteral, i - strLiteral.length)
strLiteral = ''
token = ''
q = null
Avoid deeply nested control flow statements. Open
else if (char === '"' || char === "'" || char === '`') q = char
else if (prev === '/' && (char === '/' || char === '*')) c = char
else token += char
Function collide
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export const collide = (lcov: Lcov, ...patches: (Lcov | [Lcov, string])[]): Lcov => {
const result: Lcov = {}
const prefixes = []
for (const patch of patches) {
const [_lcov, prefix] = Array.isArray(patch) ? patch : [patch]
- Read upRead up
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 parseDtsBundle
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export const parseDtsBundle = (input: string): TAssets => {
let declaration: {name: string, contents: string} | null = null
const lines = input.split('\n')
const declarations: {name: string, contents: string}[] = []
const directives: Set<string> = new Set()
- Read upRead up
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"