NodeRedis/redis-commands

View on GitHub

Showing 6 of 6 total issues

Function getKeyIndexes has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
Open

exports.getKeyIndexes = function (commandName, args, options) {
  var command = commands[commandName]
  if (!command) {
    throw new Error('Unknown command ' + commandName)
  }
Severity: Minor
Found in index.js - About 1 day 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 getKeyIndexes has 86 lines of code (exceeds 25 allowed). Consider refactoring.
Open

exports.getKeyIndexes = function (commandName, args, options) {
  var command = commands[commandName]
  if (!command) {
    throw new Error('Unknown command ' + commandName)
  }
Severity: Major
Found in index.js - About 3 hrs to fix

    Avoid deeply nested control flow statements.
    Open

                if (parseExternalKey) {
                  keys.push([i, getExternalKeyNameLength(args[i])])
                } else {
                  keys.push(i)
                }
    Severity: Major
    Found in index.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

              } else if (directive === 'STORE') {
                i += 1
                keys.push(i)
              }
      Severity: Major
      Found in index.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                  if (parseExternalKey) {
                    keys.push([i, getExternalKeyNameLength(args[i])])
                  } else {
                    keys.push(i)
                  }
        Severity: Major
        Found in index.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                      for (var j = i + 1; j < args.length; j++) {
                        keys.push(j)
                      }
          Severity: Major
          Found in index.js - About 45 mins to fix
            Severity
            Category
            Status
            Source
            Language