Showing 31 of 31 total issues

File index.js has 298 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var Stream = require('stream');
var Quorum = require('./lib/quorum');
var Connection = require('./lib/connection');
var Pool = require('generic-pool').Pool;
var Balancer = require('./lib/balancer');
Severity: Minor
Found in index.js - About 3 hrs to fix

    Function parse has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    exports.parse = function (response, parse) {
    
        response = Quorum.convert(response);
    
        for (var key in response) {
    Severity: Minor
    Found in lib/parser.js - About 2 hrs 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 _makeRequest has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    RiakPBC.prototype._makeRequest = function (options) {
    
        var self = this;
        var stream, callback;
    
    
    Severity: Minor
    Found in index.js - About 1 hr to fix

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

      RiakPBC.prototype.getIndex = function (params, callback) {
      
          params.stream = true;
      
          return this._makeRequest({
      Severity: Major
      Found in index.js and 1 other location - About 1 hr to fix
      index.js on lines 105..115

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

      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

      RiakPBC.prototype.getKeys = function (params, callback) {
      
          params.stream = true;
      
          return this._makeRequest({
      Severity: Major
      Found in index.js and 1 other location - About 1 hr to fix
      index.js on lines 204..214

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

      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 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      ConnectionManager.prototype._receive = function (data) {
      
          var length;
      
          // Make sure we can accomodate the incoming data
      Severity: Minor
      Found in lib/connection.js - About 1 hr to fix

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

        exports.parse = function (response, parse) {
        
            response = Quorum.convert(response);
        
            for (var key in response) {
        Severity: Minor
        Found in lib/parser.js - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

                          else if (response.key) {
                              response[key] = response[key].toString();
                          }
          Severity: Major
          Found in lib/parser.js - About 45 mins to fix

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

            ConnectionManager.prototype._receive = function (data) {
            
                var length;
            
                // Make sure we can accomodate the incoming data
            Severity: Minor
            Found in lib/connection.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 (contentType === 'application/json') {
                                    response[key] = JSON.parse(response[key]);
                                }
                                else if (textPattern.test(contentType)) {
                                    response[key] = response[key].toString();
            Severity: Major
            Found in lib/parser.js - About 45 mins to fix

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

              RiakPBC.prototype.getBuckets = function (params, callback) {
              
                  return this._makeRequest({
                      type: 'RpbListBucketsReq',
                      params: params,
              Severity: Major
              Found in index.js and 16 other locations - About 40 mins to fix
              index.js on lines 117..124
              index.js on lines 126..133
              index.js on lines 135..142
              index.js on lines 144..151
              index.js on lines 153..160
              index.js on lines 162..169
              index.js on lines 216..223
              index.js on lines 243..250
              index.js on lines 252..259
              index.js on lines 261..268
              index.js on lines 270..277
              index.js on lines 279..286
              index.js on lines 288..295
              index.js on lines 297..304
              index.js on lines 306..313
              index.js on lines 315..322

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

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

              RiakPBC.prototype.get = function (params, callback) {
              
                  return this._makeRequest({
                      type: 'RpbGetReq',
                      params: params,
              Severity: Major
              Found in index.js and 16 other locations - About 40 mins to fix
              index.js on lines 96..103
              index.js on lines 117..124
              index.js on lines 126..133
              index.js on lines 135..142
              index.js on lines 153..160
              index.js on lines 162..169
              index.js on lines 216..223
              index.js on lines 243..250
              index.js on lines 252..259
              index.js on lines 261..268
              index.js on lines 270..277
              index.js on lines 279..286
              index.js on lines 288..295
              index.js on lines 297..304
              index.js on lines 306..313
              index.js on lines 315..322

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

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

              RiakPBC.prototype.resetBucket = function (params, callback) {
              
                  return this._makeRequest({
                      type: 'RpbResetBucketReq',
                      params: params,
              Severity: Major
              Found in index.js and 16 other locations - About 40 mins to fix
              index.js on lines 96..103
              index.js on lines 117..124
              index.js on lines 126..133
              index.js on lines 144..151
              index.js on lines 153..160
              index.js on lines 162..169
              index.js on lines 216..223
              index.js on lines 243..250
              index.js on lines 252..259
              index.js on lines 261..268
              index.js on lines 270..277
              index.js on lines 279..286
              index.js on lines 288..295
              index.js on lines 297..304
              index.js on lines 306..313
              index.js on lines 315..322

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

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

              RiakPBC.prototype.getSearchSchema = function (params, callback) {
              
                  return this._makeRequest({
                      type: 'RpbYokozunaSchemaGetReq',
                      params: params,
              Severity: Major
              Found in index.js and 16 other locations - About 40 mins to fix
              index.js on lines 96..103
              index.js on lines 117..124
              index.js on lines 126..133
              index.js on lines 135..142
              index.js on lines 144..151
              index.js on lines 153..160
              index.js on lines 162..169
              index.js on lines 216..223
              index.js on lines 243..250
              index.js on lines 252..259
              index.js on lines 261..268
              index.js on lines 270..277
              index.js on lines 279..286
              index.js on lines 288..295
              index.js on lines 297..304
              index.js on lines 315..322

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

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

              RiakPBC.prototype.setBucket = function (params, callback) {
              
                  return this._makeRequest({
                      type: 'RpbSetBucketReq',
                      params: params,
              Severity: Major
              Found in index.js and 16 other locations - About 40 mins to fix
              index.js on lines 96..103
              index.js on lines 117..124
              index.js on lines 135..142
              index.js on lines 144..151
              index.js on lines 153..160
              index.js on lines 162..169
              index.js on lines 216..223
              index.js on lines 243..250
              index.js on lines 252..259
              index.js on lines 261..268
              index.js on lines 270..277
              index.js on lines 279..286
              index.js on lines 288..295
              index.js on lines 297..304
              index.js on lines 306..313
              index.js on lines 315..322

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

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

              RiakPBC.prototype.getSearchIndex = function (params, callback) {
              
                  return this._makeRequest({
                      type: 'RpbYokozunaIndexGetReq',
                      params: params,
              Severity: Major
              Found in index.js and 16 other locations - About 40 mins to fix
              index.js on lines 96..103
              index.js on lines 117..124
              index.js on lines 126..133
              index.js on lines 135..142
              index.js on lines 144..151
              index.js on lines 153..160
              index.js on lines 162..169
              index.js on lines 216..223
              index.js on lines 243..250
              index.js on lines 252..259
              index.js on lines 261..268
              index.js on lines 270..277
              index.js on lines 288..295
              index.js on lines 297..304
              index.js on lines 306..313
              index.js on lines 315..322

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

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

              RiakPBC.prototype.putSearchIndex = function (params, callback) {
              
                  return this._makeRequest({
                      type: 'RpbYokozunaIndexPutReq',
                      params: params,
              Severity: Major
              Found in index.js and 16 other locations - About 40 mins to fix
              index.js on lines 96..103
              index.js on lines 117..124
              index.js on lines 126..133
              index.js on lines 135..142
              index.js on lines 144..151
              index.js on lines 153..160
              index.js on lines 162..169
              index.js on lines 216..223
              index.js on lines 243..250
              index.js on lines 252..259
              index.js on lines 261..268
              index.js on lines 270..277
              index.js on lines 279..286
              index.js on lines 297..304
              index.js on lines 306..313
              index.js on lines 315..322

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

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

              RiakPBC.prototype.putCrdt = function (params, callback) {
              
                  return this._makeRequest({
                      type: 'DtUpdateReq',
                      params: params,
              Severity: Major
              Found in index.js and 16 other locations - About 40 mins to fix
              index.js on lines 96..103
              index.js on lines 117..124
              index.js on lines 126..133
              index.js on lines 135..142
              index.js on lines 144..151
              index.js on lines 153..160
              index.js on lines 162..169
              index.js on lines 216..223
              index.js on lines 243..250
              index.js on lines 252..259
              index.js on lines 261..268
              index.js on lines 279..286
              index.js on lines 288..295
              index.js on lines 297..304
              index.js on lines 306..313
              index.js on lines 315..322

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

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

              RiakPBC.prototype.putSearchSchema = function (params, callback) {
              
                  return this._makeRequest({
                      type: 'RpbYokozunaSchemaPutReq',
                      params: params,
              Severity: Major
              Found in index.js and 16 other locations - About 40 mins to fix
              index.js on lines 96..103
              index.js on lines 117..124
              index.js on lines 126..133
              index.js on lines 135..142
              index.js on lines 144..151
              index.js on lines 153..160
              index.js on lines 162..169
              index.js on lines 216..223
              index.js on lines 243..250
              index.js on lines 252..259
              index.js on lines 261..268
              index.js on lines 270..277
              index.js on lines 279..286
              index.js on lines 288..295
              index.js on lines 297..304
              index.js on lines 306..313

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

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

              RiakPBC.prototype.del = function (params, callback) {
              
                  return this._makeRequest({
                      type: 'RpbDelReq',
                      params: params,
              Severity: Major
              Found in index.js and 16 other locations - About 40 mins to fix
              index.js on lines 96..103
              index.js on lines 117..124
              index.js on lines 126..133
              index.js on lines 135..142
              index.js on lines 144..151
              index.js on lines 153..160
              index.js on lines 216..223
              index.js on lines 243..250
              index.js on lines 252..259
              index.js on lines 261..268
              index.js on lines 270..277
              index.js on lines 279..286
              index.js on lines 288..295
              index.js on lines 297..304
              index.js on lines 306..313
              index.js on lines 315..322

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

              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