hdachev/fakeredis

View on GitHub

Showing 133 of 133 total issues

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

, SUNION: function () {
    var i, n = arguments.length, out = [];
    if (!n) return BAD_ARGS;

    for (i = 0; i < n; i++) {
Severity: Minor
Found in lib/backend.js - 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 _scan has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

, _scan: function (allKeys, size, cursor, opt1, opt1val, opt2, opt2val) {
    cursor = str2int(cursor);
    if (cursor instanceof ERROR)
      return cursor;

Severity: Minor
Found in lib/backend.js - About 1 hr to fix

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

          if (typeof data === 'number')
            data = String(data);
    
          else if (data.length && data.map)
            data = data.map(finnerdata);
    Severity: Major
    Found in lib/connection.js and 1 other location - About 1 hr to fix
    lib/connection.js on lines 380..387

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 64.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

          if (typeof data === 'string' && !isNaN(data))
            data = Number(data);
    
          else if (data.length && data.map)
            data = data.map(finnerdata);
    Severity: Major
    Found in lib/connection.js and 1 other location - About 1 hr to fix
    lib/connection.js on lines 398..405

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 64.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Function sCombine has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    , sCombine: function (diff, args) {
        var i, n = args.length;
        if (!n)
          return BAD_ARGS;
    
    
    Severity: Minor
    Found in lib/backend.js - 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 structPut has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    , structPut: function (type, validate, revArgs, args) {
        var key = args[0], i, n = args.length, x = 0;
    
        if (n < 3 || ((n - 1) % 2)) return BAD_ARGS;
        var K = this.getKey(type, key, true);
    Severity: Minor
    Found in lib/backend.js - 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 override has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          entry.override = function(queue) {
            if (!queue) throw new Error('WOOT! no queue.');
            var w = watch, key, entry;
            watch = null;
            if (w) for (key in w)
    Severity: Minor
    Found in lib/connection.js - About 1 hr to fix

      Function zOpStore has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      , zOpStore: function (union, key, keys, weights, aggregate) {
          var K = this.getSetOrZsetKey(keys[0]);
          if (K instanceof ERROR) return K;
      
          var out = {}, member, x = 0, weight = (weights === null ? 1 : weights[0]);
      Severity: Minor
      Found in lib/backend.js - About 1 hr to fix

        Function HMGET has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        tests.HMGET = function () {
            var key1 = "test hash 1", key2 = "test hash 2", key3 = 123456789, name = "HMGET";
        
            // redis-like hmset syntax
            client.HMSET(key1, "0123456789", "abcdefghij", "some manner of key", "a type of value", require_string("OK", name));
        Severity: Minor
        Found in redis.test.js - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

                else if (func.length && func.length !== entry.args.length) {
                  err = new Error('Wrong number of arguments for \'' + entry.command.toLowerCase() + '\' command');
                  data = null;
                }
          
          
          Severity: Critical
          Found in lib/connection.js - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                  if ((p && sub.pattern !== null && (channel === null || sub.pattern === channel)) || (!p && sub.pattern === null && (channel === null || sub.channel === channel))) {
                    x--;
                    subs.splice(i, 1);
                    process.nextTick(client.pushMessage.bind(client, p ? 'punsubscribe' : 'unsubscribe', p ? sub.pattern : sub.channel, x));
                    i--; n--;
            Severity: Critical
            Found in lib/backend.js - About 1 hr to fix

              Function getKeyspace has 33 lines of code (exceeds 25 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 1 hr to fix

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                var ERROR = function (message) {
                  this.getError = function () { return message; };
                  this.toString = function () { return "<ERROR<" + message + ">>"; };
                };
                Severity: Major
                Found in lib/backend.js and 1 other location - About 1 hr to fix
                lib/backend.js on lines 28..31

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 61.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    client.sort('y', 'asc', 'alpha', function (err, sorted) {
                        if (err) {
                            assert.fail(err, name);
                        }
                        assert.deepEqual(buffers_to_strings(sorted), ['a', 'b', 'c', 'd'], name);
                Severity: Major
                Found in redis.test.js and 1 other location - About 1 hr to fix
                redis.test.js on lines 1919..1924

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 61.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    client.sort('y', 'desc', 'alpha', function (err, sorted) {
                        if (err) {
                            assert.fail(err, name);
                        }
                        assert.deepEqual(buffers_to_strings(sorted), ['d', 'c', 'b', 'a'], name);
                Severity: Major
                Found in redis.test.js and 1 other location - About 1 hr to fix
                redis.test.js on lines 1912..1917

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 61.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                var STATUS = function (message) {
                  this.getStatus = function () { return message; };
                  this.toString = function () { return "<STATUS<" + message + ">>"; };
                };
                Severity: Major
                Found in lib/backend.js and 1 other location - About 1 hr to fix
                lib/backend.js on lines 6..9

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 61.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Function lPopMany has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                , lPopMany: function (left, keys) {
                    var K = [], value, i, n = keys.length;
                    if (!n) return BAD_ARGS;
                    for (i = 0; i < n; i++) {
                      K[i] = this.getKey(LIST, keys[i]);
                Severity: Minor
                Found in lib/backend.js - 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

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    client.sort('x', 'desc', function (err, sorted) {
                        if (err) {
                            assert.fail(err, name);
                        }
                        assert.deepEqual(buffers_to_strings(sorted), [9, 4, 3, 2], name);
                Severity: Major
                Found in redis.test.js and 1 other location - About 1 hr to fix
                redis.test.js on lines 1929..1934

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 60.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    client.sort('x', 'asc', function (err, sorted) {
                        if (err) {
                            assert.fail(err, name);
                        }
                        assert.deepEqual(buffers_to_strings(sorted), [2, 3, 4, 9], name);
                Severity: Major
                Found in redis.test.js and 1 other location - About 1 hr to fix
                redis.test.js on lines 1936..1941

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 60.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                , HSCAN: function () {
                    return this._scan(this.HGETALL(arguments[0]), 2, arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]);
                  }
                Severity: Major
                Found in lib/backend.js and 1 other location - About 1 hr to fix
                lib/backend.js on lines 530..532

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 59.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Severity
                Category
                Status
                Source
                Language