mauritsl/node-castor-client

View on GitHub

Showing 35 of 35 total issues

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

DataStream.prototype.readShort = function() {
  var output = this.data.readUInt16BE(this.position);
  this.position += 2;
  return output;
};
Severity: Major
Found in classes/DataStream.js and 3 other locations - About 1 hr to fix
classes/DataStream.js on lines 38..42
classes/DataStream.js on lines 103..107
classes/DataStream.js on lines 109..113

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

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

DataStream.prototype.readDouble = function() {
  var output = this.data.readDoubleBE(this.position);
  this.position += 8;
  return output;
};
Severity: Major
Found in classes/DataStream.js and 3 other locations - About 1 hr to fix
classes/DataStream.js on lines 32..36
classes/DataStream.js on lines 38..42
classes/DataStream.js on lines 103..107

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

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

DataStream.prototype.readFloat = function() {
  var output = this.data.readFloatBE(this.position);
  this.position += 4;
  return output;
};
Severity: Major
Found in classes/DataStream.js and 3 other locations - About 1 hr to fix
classes/DataStream.js on lines 32..36
classes/DataStream.js on lines 38..42
classes/DataStream.js on lines 109..113

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

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 read has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

Schema.prototype.read = function() {
  var self = this;
  var cql = 'SELECT columnfamily_name, column_name, type, validator FROM system.schema_columns WHERE keyspace_name = \'' + this._keyspace + '\'';
  var query = new Query(this._transport, cql, this._consistency);
  this._schema = query.then(function(rows) {
Severity: Minor
Found in classes/Schema.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 _fetchFrames has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

Transport.prototype._fetchFrames = function() {
  // We need at least 8 bytes for the frame header.
  while (this._inputBuffer.length >= 8) {
    var length = 8 + this._inputBuffer.readUInt32BE(4);
    if (this._inputBuffer.length < length) {
Severity: Minor
Found in classes/Transport.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 Rows has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

var Rows = function(data) {
  this.columns = [];
  this.rowCount = 0;
  this.columnCount = 0;
  this._current = 0;
Severity: Minor
Found in classes/Rows.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 lt has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

Bignum.prototype.lt = function(num) {
  var a = this._num.toString();
  var b = num.toString();
  if (a == b) {
    return false;
Severity: Minor
Found in classes/Bignum.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

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

Castor.prototype.del = function(table) {
  var output = new Del(this._transport, this._schema, this._keyspace, table);
  return output;
};
Severity: Major
Found in castor-client.js and 2 other locations - About 45 mins to fix
castor-client.js on lines 93..96
castor-client.js on lines 98..101

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

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

Castor.prototype.set = function(table) {
  var output = new Set(this._transport, this._schema, this._keyspace, table);
  return output;
};
Severity: Major
Found in castor-client.js and 2 other locations - About 45 mins to fix
castor-client.js on lines 93..96
castor-client.js on lines 103..106

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

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

Castor.prototype.get = function(table) {
  var output = new Get(this._transport, this._schema, this._keyspace, table);
  return output;
};
Severity: Major
Found in castor-client.js and 2 other locations - About 45 mins to fix
castor-client.js on lines 98..101
castor-client.js on lines 103..106

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

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 current has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

Rows.prototype.current = function() {
  if (typeof this.rows[this._current] === 'undefined') {
    throw Error('Invalid position');
  }
  var row = this.rows[this._current];
Severity: Minor
Found in classes/Rows.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 getTimestamp has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

Field.prototype.getTimestamp = function() {
  if (typeof this.value === 'string') {
    var isDate = this.value.match(/^[0-9]{4}\-[012][0-9]\-[0-3][0-9]$/);
    var isDateTime = this.value.match(/^[0-9]{4}\-[012][0-9]\-[0-3][0-9]T[0-2][0-9]\:[0-5][0-9]\:[0-5][0-9](\.[0-9]+)?(Z|[\+\-][012][0-9]\:[0-5][0-9])?$/);
    if (!isDate && !isDateTime) {
Severity: Minor
Found in classes/Field.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 _executeJoin has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

Get.prototype._executeJoin = function(rows, join) {
  var self = this;
  var defer = Q.defer();
  var columns = {};
  var values = {};
Severity: Minor
Found in classes/Get.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

Avoid too many return statements within this function.
Open

  return (a.length === b.length) ? a < b : a.length < b.length;
Severity: Major
Found in classes/Bignum.js - About 30 mins to fix

    Function Transport has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    var Transport = function(host, readyCallback) {
      var self = this;
      
      // Used for validating the connection in the connection pool.
      this.ready = false;
    Severity: Minor
    Found in classes/Transport.js - About 25 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