Codibre/remembered-redis

View on GitHub

Showing 6 of 6 total issues

File remembered-redis.ts has 356 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { v4 } from 'uuid';
import { Remembered } from 'remembered';
import { LockOptions, Mutex } from 'redis-semaphore';
import {
    RememberedRedisConfig,
Severity: Minor
Found in src/remembered-redis.ts - About 4 hrs to fix

    Function updateCache has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        async updateCache<T>(
            cacheKey: string,
            result: T,
            ttl = this.redisTtl?.(result),
        ): Promise<void> {
    Severity: Minor
    Found in src/remembered-redis.ts - About 2 hrs 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 updateCache has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        async updateCache<T>(
            cacheKey: string,
            result: T,
            ttl = this.redisTtl?.(result),
        ): Promise<void> {
    Severity: Major
    Found in src/remembered-redis.ts - About 2 hrs to fix

      Function prepareConfig has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      function prepareConfig(config: RememberedRedisConfig) {
          const { redisTtl, ttl } = config;
      
          if (!redisTtl) {
              config.ttl = 0;
      Severity: Minor
      Found in src/remembered-redis.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 getFromCacheInternal has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          private async getFromCacheInternal<T>(
              key: string,
              firstCheck: boolean,
          ): Promise<T | typeof EMPTY> {
              const redisKey = this.getRedisKey(key);
      Severity: Minor
      Found in src/remembered-redis.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 getFromCacheInternal has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private async getFromCacheInternal<T>(
              key: string,
              firstCheck: boolean,
          ): Promise<T | typeof EMPTY> {
              const redisKey = this.getRedisKey(key);
      Severity: Minor
      Found in src/remembered-redis.ts - About 1 hr to fix
        Severity
        Category
        Status
        Source
        Language