hdachev/fakeredis

View on GitHub

Showing 133 of 133 total issues

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

                      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

                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

                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

                  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

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

                    , BLPOP: function () {
                        var a = this.bArgs(arguments);
                        if (a instanceof ERROR) return a;
                        return this.lPopMany(true, a);
                      }
                    Severity: Minor
                    Found in lib/backend.js and 1 other location - About 40 mins to fix
                    lib/backend.js on lines 1091..1095

                    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 48.

                    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

                    , BRPOP: function () {
                        var a = this.bArgs(arguments);
                        if (a instanceof ERROR) return a;
                        return this.lPopMany(false, a);
                      }
                    Severity: Minor
                    Found in lib/backend.js and 1 other location - About 40 mins to fix
                    lib/backend.js on lines 1085..1089

                    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 48.

                    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 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

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

                      client3.on("error", function (err) {
                          console.error("client3: " + err.stack);
                          process.exit();
                      });
                      Severity: Minor
                      Found in redis.test.js and 2 other locations - About 35 mins to fix
                      redis.test.js on lines 2322..2325
                      redis.test.js on lines 2330..2333

                      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 47.

                      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 3 locations. Consider refactoring.
                      Open

                      client2.on("error", function (err) {
                          console.error("client2: " + err.stack);
                          process.exit();
                      });
                      Severity: Minor
                      Found in redis.test.js and 2 other locations - About 35 mins to fix
                      redis.test.js on lines 2326..2329
                      redis.test.js on lines 2330..2333

                      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 47.

                      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 3 locations. Consider refactoring.
                      Open

                      bclient.on("error", function (err) {
                          console.error("bclient: " + err.stack);
                          process.exit();
                      });
                      Severity: Minor
                      Found in redis.test.js and 2 other locations - About 35 mins to fix
                      redis.test.js on lines 2322..2325
                      redis.test.js on lines 2326..2329

                      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 47.

                      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 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 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

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language