oleksiyk/no-riak

View on GitHub

Showing 27 of 27 total issues

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

    self.options.connectionString.trim().split(',').forEach(function (hostStr) {
        var h = hostStr.trim().split(':');

        if (h.length < 2) { return null; }

Severity: Major
Found in lib/client.js and 1 other location - About 6 hrs to fix
lib/client.js on lines 69..82

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

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

    self.options.failoverConnectionString.trim().split(',').forEach(function (hostStr) {
        var h = hostStr.trim().split(':');

        if (h.length < 2) { return null; }

Severity: Major
Found in lib/client.js and 1 other location - About 6 hrs to fix
lib/client.js on lines 50..63

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

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

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

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

    Client.prototype.setBucket = function (params) {
        ['pr', 'r', 'w', 'pw', 'dw', 'rw'].forEach(function (p) {
            if (params && params.props && (typeof params.props[p] === 'string')) {
                params.props[p] = riakQuorumValues[params.props[p]] || params.props[p];
            }
    Severity: Major
    Found in lib/client.js and 1 other location - About 4 hrs to fix
    lib/client.js on lines 514..522

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

    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.prototype.setBucketType = function (params) {
        ['pr', 'r', 'w', 'pw', 'dw', 'rw'].forEach(function (p) {
            if (params && params.props && (typeof params.props[p] === 'string')) {
                params.props[p] = riakQuorumValues[params.props[p]] || params.props[p];
            }
    Severity: Major
    Found in lib/client.js and 1 other location - About 4 hrs to fix
    lib/client.js on lines 491..499

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

    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.prototype.getBucket = function (params) {
        return this._request('RpbGetBucketReq', params).then(function (result) {
            ['pr', 'r', 'w', 'pw', 'dw', 'rw'].forEach(function (p) {
                result.props[p] = riakQuorumValues[result.props[p]] || result.props[p];
            });
    Severity: Major
    Found in lib/client.js and 1 other location - About 3 hrs to fix
    lib/client.js on lines 505..512

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

    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.prototype.getBucketType = function (params) {
        return this._request('RpbGetBucketTypeReq', params).then(function (result) {
            ['pr', 'r', 'w', 'pw', 'dw', 'rw'].forEach(function (p) {
                result.props[p] = riakQuorumValues[result.props[p]] || result.props[p];
            });
    Severity: Major
    Found in lib/client.js and 1 other location - About 3 hrs to fix
    lib/client.js on lines 482..489

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

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

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

              if (self.options.autoJSON && _.isPlainObject(params.content.value)) {
                  params.content.value = JSON.stringify(params.content.value);
                  params.content.content_type = 'application/json';
              }
      Severity: Major
      Found in lib/client.js and 1 other location - About 2 hrs to fix
      lib/client.js on lines 456..459

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

      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 (self.options.autoJSON && _.isPlainObject(params.content.value)) {
                  params.content.value = JSON.stringify(params.content.value);
                  params.content.content_type = 'application/json';
              }
      Severity: Major
      Found in lib/client.js and 1 other location - About 2 hrs to fix
      lib/client.js on lines 332..335

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

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

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

          Client.prototype.updateCounter = function (params) {
              return this._request('RpbCounterUpdateReq', params).then(function (result) {
                  if (result !== null) {
                      return result.value;
                  }
          Severity: Major
          Found in lib/client.js and 1 other location - About 1 hr to fix
          lib/client.js on lines 473..480

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

          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.prototype.getCounter = function (params) {
              return this._request('RpbCounterGetReq', params).then(function (result) {
                  if (result !== null) {
                      return result.value;
                  }
          Severity: Major
          Found in lib/client.js and 1 other location - About 1 hr to fix
          lib/client.js on lines 464..471

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

          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 _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
                    Severity
                    Category
                    Status
                    Source
                    Language