hdachev/fakeredis

View on GitHub

Showing 86 of 133 total issues

Function slice has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var slice = function (arr, start, stop, asCount) {
  start = str2int(start);
  stop = str2int(stop);
  if (start instanceof ERROR) return start;
  if (stop instanceof ERROR) return stop;
Severity: Minor
Found in lib/backend.js - About 1 hr to fix

    Function getKeyspace has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    exports.getKeyspace = function(options, callback) {
      var cb;
    
      if (!callback && typeof options === 'function') {
        callback = options;
    Severity: Minor
    Found in lib/helpers.js - About 55 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

    Function zGetRangeByScore has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    , zGetRangeByScore: function (rev, args) {
        var key = args[0], min = args[rev ? 2 : 1], max = args[rev ? 1 : 2]
          , scores, limit, offset, count;
    
        if (args.length < 3)
    Severity: Minor
    Found in lib/backend.js - About 55 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

    Function structDel has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    , structDel: function (type, args) {
        var key = args[0]
          , i, n = args.length
          , x;
    
    
    Severity: Minor
    Found in lib/backend.js - About 55 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

    Function _scan has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    , _scan: function (allKeys, size, cursor, opt1, opt1val, opt2, opt2val) {
    Severity: Major
    Found in lib/backend.js - About 50 mins to fix

      Avoid deeply nested control flow statements.
      Open

              if (w) for (key in w)
                if (backend.getRevision(key) !== w[key]) {
      
                  // Abort because of a change in the watched keyspace.
                  n = 0;
      Severity: Major
      Found in lib/connection.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

              if (queue && !timeout)
                timeout = setTimeout(exec, randLat());
        Severity: Major
        Found in lib/connection.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                    if (entry.command !== "EXEC") {
          
                      // Collect replies for the EXEC output.
                      entry.callback = cb;
          
          
          Severity: Major
          Found in lib/connection.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                      if (resp.length)
                        flush(resp);
            Severity: Major
            Found in lib/connection.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                        if (entry.block && typeof entry.block === 'number')
                          setTimeout(unblock.bind(null, entry), entry.block * 1000);
              Severity: Major
              Found in lib/connection.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                        else for (member in out) if (!(member in K.value)) {
                          delete out[member];
                          x--;
                        }
                Severity: Major
                Found in lib/backend.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                            if (queue[i].command === "MULTI") {
                              queue.splice(i, queue.length);
                  
                              // This will substitute the DISCARD command with an UNWATCH,
                              // hence the recursive call to this.push.
                  Severity: Major
                  Found in lib/connection.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                              if (!(member in out)) {
                                x++;
                                out[member] = K.value[member]* weight;
                              }
                    
                    
                    Severity: Major
                    Found in lib/backend.js - About 45 mins 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

                      Consider simplifying this complex logical expression.
                      Open

                              if ((diff && (K && K.value[out[j]])) || (!diff && !(K && K.value[out[j]]))) {
                                out.splice(j, 1);
                                j--;
                                m--;
                              }
                      Severity: Major
                      Found in lib/backend.js - About 40 mins to fix

                        Function zOpStore has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        , zOpStore: function (union, key, keys, weights, aggregate) {
                        Severity: Minor
                        Found in lib/backend.js - About 35 mins to fix

                          Function zSort has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                          , zSort: function (rev, key, min, max) {
                              var K = this.getKey(ZSET, key);
                              if (K instanceof ERROR) return K;
                              if (!K) return [];
                          
                          
                          Severity: Minor
                          Found in lib/backend.js - About 35 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

                          Function SETBIT has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                          , SETBIT: function (key, offset, state) {
                              /*jshint -W018*/
                              offset = str2int(offset);
                              if (!(offset >  - 1)) return BAD_BIT1;
                              state = str2int(state);
                          Severity: Minor
                          Found in lib/backend.js - About 35 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

                          Function pretty has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                          exports.pretty = function(options) {
                            var pattern, wrap, label;
                          
                            if (typeof options === 'string')
                              options = { pattern: options };
                          Severity: Minor
                          Found in lib/helpers.js - About 35 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

                          Function zUnwrap has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                          , zUnwrap: function (range, scores) {
                              var i, n = range.length, out = n ?[] : range;
                              if (n)
                                for (i = 0; i < n; i++) {
                                  out.push(range[i].member);
                          Severity: Minor
                          Found in lib/backend.js - About 35 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

                          Severity
                          Category
                          Status
                          Source
                          Language