hdachev/fakeredis

View on GitHub
main.js

Summary

Maintainability
D
1 day
Test Coverage

Function createClient has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
Open

exports.createClient = function(port, host, options) {
  if (arguments.length == 1 && typeof port == "object") { 
    options = port;
    if (options.port || options.host) {
      port = options.port;
Severity: Minor
Found in main.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 createClient has 86 lines of code (exceeds 25 allowed). Consider refactoring.
Open

exports.createClient = function(port, host, options) {
  if (arguments.length == 1 && typeof port == "object") { 
    options = port;
    if (options.port || options.host) {
      port = options.port;
Severity: Major
Found in main.js - About 3 hrs to fix

    Function send_command has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      cl.send_command = function(command, args, callback) {
    
        // Interpret arguments, copy-paste from mranney/redis/index.js for best compat.
        if (typeof command !== "string") {
          throw new Error("First argument to send_command must be the command name string, not " + typeof command);
    Severity: Minor
    Found in main.js - About 1 hr to fix

      Function packageBuffer has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      function packageBuffer(buf) {
      
        // If possible, try storing the buffer as a utf8 string.
        // For this to work baking the string back to a buffer must yield the exact same bytes.
        var asString = buf.toString('utf8');
      Severity: Minor
      Found in main.js - About 45 mins 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

      There are no issues that match your filters.

      Category
      Status