Showing 26 of 58 total issues
File inspect.test.ts
has 635 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* eslint-disable unicorn/prefer-number-properties, func-names, @typescript-eslint/no-empty-function, new-cap, no-new-func,
no-new-object, no-new-wrappers, unicorn/new-for-builtins, no-regex-spaces, unicorn/error-message, no-inner-declarations */
import assert from 'node:assert';
import { inspect as nodeInspect } from 'node:util';
Function str
has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring. Open
function str(key: string | number | symbol, holder: any, recurseTimes: number): string {
recurseTimes++;
const value = holder[key];
- 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 format
has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring. Open
export function format(str?: any, ...values: any[]) {
if (typeof str !== 'string') {
return (str === undefined ? values : [str, ...values])
.map(value => (typeof value === 'string' ? value : inspect(value)))
.join(' ');
- 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 str
has 101 lines of code (exceeds 25 allowed). Consider refactoring. Open
function str(key: string | number | symbol, holder: any, recurseTimes: number): string {
recurseTimes++;
const value = holder[key];
Function format
has 100 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function format(str?: any, ...values: any[]) {
if (typeof str !== 'string') {
return (str === undefined ? values : [str, ...values])
.map(value => (typeof value === 'string' ? value : inspect(value)))
.join(' ');
Function o
has 82 lines of code (exceeds 25 allowed). Consider refactoring. Open
.replace(/%[%sdifjoOc]/g, match => {
if (match === '%%') return '%';
if (nbSpecifiers >= values.length) return match;
Function getName
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function getName(object: any) {
let name = '';
if (object.constructor === undefined) {
name = '[Object: null prototype]';
- 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 loopObject
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function loopObject(keys: Key[], object: object, recurseTimes: number) {
const items: string[] = [];
for (const k of keys) {
const key = strKey(k, recurseTimes);
- 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 throwOnConsole
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export function throwOnConsole(methodName: ConsoleMethodName, options: Options = {}) {
const { ignore } = options;
if (methodName === 'assert') {
console.assert = (condition?: boolean, ...data: any[]) => {
- 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 (res.length > 0) res += ' ';
Function loopArray
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function loopArray(array: any[] | TypedArray, recurseTimes: number) {
const items: string[] = [];
for (let i = 0; i < array.length; i++) {
try {
- 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 strKey
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function strKey(key: Key, recurseTimes: number) {
switch (typeof key) {
case 'string': {
// Because Object.keys() return (string | symbol)[] thus
// const arr = []; arr[10] = 11;
- 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 loopSet
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function loopSet(set: Set<any>, recurseTimes: number) {
const items: string[] = [];
for (const v of set) {
try {
- 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 too many return
statements within this function. Open
return String(value);
Avoid too many return
statements within this function. Open
return Number.NaN.toString();
Avoid too many return
statements within this function. Open
return '[Circular]';
Avoid too many return
statements within this function. Open
return Number.NaN.toString();
Avoid too many return
statements within this function. Open
return Number.parseFloat(value).toString();
Avoid too many return
statements within this function. Open
return Number.parseInt(value, 10).toString();
Avoid too many return
statements within this function. Open
return JSON.stringify(value);