oleksiyk/no-riak

View on GitHub

Showing 13 of 27 total issues

File client.js has 397 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

var Promise    = require('bluebird');
var Pool       = require('./pool');
var _          = require('lodash');
Severity: Minor
Found in lib/client.js - About 5 hrs to fix

    Function connect has 65 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    Connection.prototype.connect = function () {
        var self = this;
    
        if (self.connected) {
            return Promise.resolve();
    Severity: Major
    Found in lib/connection.js - About 2 hrs to fix

      Function Client has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function Client(options) {
          var self = this;
      
          self.options = _.defaultsDeep(options || {}, {
              clientId: 'no-riak-client',
      Severity: Major
      Found in lib/client.js - About 2 hrs to fix

        Function _next has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        Pool.prototype._next = function () {
            var self = this;
        
            return Promise.try(function () {
                var connection = self.connections.free.shift();
        Severity: Minor
        Found in lib/pool.js - About 2 hrs to fix

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

          Connection.prototype._receive = function (data) {
              var length;
          
              if (!this.connected) {
                  return;
          Severity: Minor
          Found in lib/connection.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 _ping has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          Client.prototype._ping = function (host, port, isFailover) {
              var self = this, connection;
          
              if (self._pinging[host + ':' + port]) {
                  return undefined;
          Severity: Minor
          Found in lib/client.js - About 1 hr to fix

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

            RMap.prototype._setValue = function (v) {
                var self = this;
            
                if (v && v.map_value) {
                    self._fields = v.map_value.map(function (entry) {
            Severity: Minor
            Found in lib/crdt/map.js - About 1 hr to fix

              Function _fields has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      self._fields = v.map_value.map(function (entry) {
                          var value;
                          switch (mapFieldTypes[entry.field.type]) {
                              case 'COUNTER':
                                  value = new Counter();
              Severity: Minor
              Found in lib/crdt/map.js - About 1 hr to fix

                Function _receive has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                Connection.prototype._receive = function (data) {
                    var length;
                
                    if (!this.connected) {
                        return;
                Severity: Minor
                Found in lib/connection.js - About 1 hr to fix

                  Function _checkConnection has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  Client.prototype._checkConnection = function (err, c) {
                      var self = this, s, now = Date.now(), servers = c.isFailover() ? self.failoverServers : self.servers;
                  
                      if (err instanceof errors.RiakConnectionError) {
                          s = servers.get({ host: c.host(), port: c.port() });
                  Severity: Minor
                  Found in lib/client.js - About 1 hr to fix

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

                    Client.prototype._convertRpbGetResponse = function (result) {
                        var self = this;
                    
                        if (result) {
                            if (result.vclock) {
                    Severity: Minor
                    Found in lib/client.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 _checkConnection has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    Client.prototype._checkConnection = function (err, c) {
                        var self = this, s, now = Date.now(), servers = c.isFailover() ? self.failoverServers : self.servers;
                    
                        if (err instanceof errors.RiakConnectionError) {
                            s = servers.get({ host: c.host(), port: c.port() });
                    Severity: Minor
                    Found in lib/client.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 _process has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    Connection.prototype._process = function (data) {
                        var self = this, result, done;
                    
                        try {
                            result = self.protocol.read(data).Response().result;
                    Severity: Minor
                    Found in lib/connection.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