NodeRedis/node-redis

View on GitHub

Showing 13 of 539 total issues

File index.spec.ts has 990 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { strict as assert } from 'node:assert';
import { setTimeout } from 'node:timers/promises';
import { WatchError } from "../errors";
import { RedisSentinelConfig, SentinelFramework } from "./test-util";
import { RedisNode, RedisSentinelClientType, RedisSentinelEvent, RedisSentinelType } from "./types";
Severity: Major
Found in packages/client/lib/sentinel/index.spec.ts - About 2 days to fix

    File index.spec.ts has 679 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { strict as assert } from 'node:assert';
    import testUtils, { GLOBAL, waitTillBeenCalled } from '../test-utils';
    import RedisClient, { RedisClientType } from '.';
    import { AbortError, ClientClosedError, ClientOfflineError, ConnectionTimeoutError, DisconnectsClientError, ErrorReply, MultiErrorReply, SocketClosedUnexpectedlyError, WatchError } from '../errors';
    import { defineScript } from '../lua-script';
    Severity: Major
    Found in packages/client/lib/client/index.spec.ts - About 1 day to fix

      File AGGREGATE.spec.ts has 485 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { strict as assert } from 'node:assert';
      import testUtils, { GLOBAL } from '../test-utils';
      import AGGREGATE from './AGGREGATE';
      import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
      
      
      Severity: Minor
      Found in packages/search/lib/commands/AGGREGATE.spec.ts - About 7 hrs to fix

        File CREATE.spec.ts has 434 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import { strict as assert } from 'node:assert';
        import testUtils, { GLOBAL } from '../test-utils';
        import CREATE, { SCHEMA_FIELD_TYPE, SCHEMA_TEXT_FIELD_PHONETIC, SCHEMA_VECTOR_FIELD_ALGORITHM, REDISEARCH_LANGUAGE } from './CREATE';
        import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
        
        
        Severity: Minor
        Found in packages/search/lib/commands/CREATE.spec.ts - About 6 hrs to fix

          File decoder.spec.ts has 368 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import { strict as assert } from 'node:assert';
          import { SinonSpy, spy } from 'sinon';
          import { Decoder, RESP_TYPES } from './decoder';
          import { BlobError, SimpleError } from '../errors';
          import { TypeMapping } from './types';
          Severity: Minor
          Found in packages/client/lib/RESP/decoder.spec.ts - About 4 hrs to fix

            Function attachConfig has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
            Open

            export function attachConfig<
              M extends RedisModules,
              F extends RedisFunctions,
              S extends RedisScripts,
              RESP extends RespVersions
            Severity: Minor
            Found in packages/client/lib/commander.ts - About 3 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

            File SEARCH.spec.ts has 298 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import { strict as assert } from 'node:assert';
            import testUtils, { GLOBAL } from '../test-utils';
            import SEARCH from './SEARCH';
            import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
            
            
            Severity: Minor
            Found in packages/search/lib/commands/SEARCH.spec.ts - About 3 hrs to fix

              File index.spec.ts has 277 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import { strict as assert } from 'node:assert';
              import testUtils, { GLOBAL, waitTillBeenCalled } from '../test-utils';
              import RedisCluster from '.';
              import { SQUARE_SCRIPT } from '../client/index.spec';
              import { RootNodesUnavailableError } from '../errors';
              Severity: Minor
              Found in packages/client/lib/cluster/index.spec.ts - About 2 hrs to fix

                Function steadyState has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                async function steadyState(frame: SentinelFramework) {
                  let checkedMaster = false;
                  let checkedReplicas = false;
                  while (!checkedMaster || !checkedReplicas) {
                    if (!checkedMaster) {
                Severity: Minor
                Found in packages/client/lib/sentinel/index.spec.ts - About 1 hr to fix

                  Function steadyState has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                  async function steadyState(frame: SentinelFramework) {
                    let checkedMaster = false;
                    let checkedReplicas = false;
                    while (!checkedMaster || !checkedReplicas) {
                      if (!checkedMaster) {
                  Severity: Minor
                  Found in packages/client/lib/sentinel/index.spec.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 spawnRedisClusterNodeDockers has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  async function spawnRedisClusterNodeDockers(
                    dockersConfig: RedisClusterDockersConfig,
                    serverArguments: Array<string>,
                    fromSlot: number,
                    toSlot: number
                  Severity: Minor
                  Found in packages/test-utils/lib/dockers.ts - About 1 hr to fix

                    Function spawnRedisClusterDockers has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    async function spawnRedisClusterDockers(
                      dockersConfig: RedisClusterDockersConfig,
                      serverArguments: Array<string>
                    ): Promise<Array<RedisServerDocker>> {
                      const numberOfMasters = dockersConfig.numberOfMasters ?? 2,
                    Severity: Minor
                    Found in packages/test-utils/lib/dockers.ts - About 1 hr to fix

                      Avoid deeply nested control flow statements.
                      Open

                                  if (testUtils.isVersionGreaterThan([7, 0, 3])) {
                                    assert.equal(typeof item.ssub, 'number');
                                  }
                      Severity: Major
                      Found in packages/client/lib/commands/CLIENT_LIST.spec.ts - About 45 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language