Showing 4 of 4 total issues
Function debounce
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const debounce: IExposedWrapper = adapter((fn: ITarget, opts: IWrapperOpts): IControlled => {
const { delay, limit, context, rejectOnCancel, maxWait, leading, order, limiter: _limiter } = ({ ...DEFAULT_OPTS, ...opts } as IWrapperOpts)
const limiter = _limiter || new Limiter(normalizeDelay(limit || delay))
const args: any[] = []
const calls: ICallStack = []
Function debounce
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
Open
export const debounce: IExposedWrapper = adapter((fn: ITarget, opts: IWrapperOpts): IControlled => {
const { delay, limit, context, rejectOnCancel, maxWait, leading, order, limiter: _limiter } = ({ ...DEFAULT_OPTS, ...opts } as IWrapperOpts)
const limiter = _limiter || new Limiter(normalizeDelay(limit || delay))
const args: any[] = []
const calls: ICallStack = []
- 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 ratelimit
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const ratelimit: IExposedWrapper = adapter((fn: ITarget, opts: IWrapperOpts): IControlled => {
let timeout: TimeoutID | undefined
const { delay, limit, context, rejectOnCancel, limiter } = opts
const _limiter = limiter || new Limiter(normalizeDelay(limit || delay))
const calls: ICallStack = []
Function res
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const res = (..._args: IAny[]): Promise<IAny> => {
dropTimeout(timeout)
args.push(_args)
if (queueLimit === undefined) {