antongolub/push-it-to-the-limit

View on GitHub

Showing 4 of 4 total issues

Function debounce has 64 lines of code (exceeds 25 allowed). Consider refactoring.
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 = []
Severity: Major
Found in src/main/ts/wrappers/debounce.ts - About 2 hrs to fix

    Function debounce has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    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 = []
    Severity: Minor
    Found in src/main/ts/wrappers/debounce.ts - About 1 hr to fix

    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

    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 = []
    Severity: Minor
    Found in src/main/ts/wrappers/ratelimit.ts - About 1 hr to fix

      Function res has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        const res = (..._args: IAny[]): Promise<IAny> => {
          dropTimeout(timeout)
          args.push(_args)
      
          if (queueLimit === undefined) {
      Severity: Minor
      Found in src/main/ts/wrappers/debounce.ts - About 1 hr to fix
        Severity
        Category
        Status
        Source
        Language