mauritsl/node-castor-client

View on GitHub

Showing 35 of 35 total issues

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

    if (self._filter.length) {
      for (var i = 0; i < self._filter.length; ++i) {
        var type = schema.columns[self._filter[i].name];
        if (typeof type === 'undefined') {
          throw Error('Unknown field ' + self._filter[i].name + ' in filter');
Severity: Major
Found in classes/Del.js and 1 other location - About 1 day to fix
classes/Get.js on lines 142..152

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

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

    if (self._filter.length) {
      for (var i = 0; i < self._filter.length; ++i) {
        var type = schema.columns[self._filter[i].name];
        if (typeof type === 'undefined') {
          throw Error('Unknown field ' + self._filter[i].name + ' in filter');
Severity: Major
Found in classes/Get.js and 1 other location - About 1 day to fix
classes/Del.js on lines 63..73

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

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

Field.prototype.getList = function() {
  var self = this;
  if (typeof this.value !== 'object' || !(this.value instanceof Array)) {
    throw Error('Invalid value for field ' + this.name);
  }
Severity: Major
Found in classes/Field.js and 1 other location - About 6 hrs to fix
classes/Field.js on lines 165..176

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

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

Field.prototype.getSet = function() {
  var self = this;
  if (typeof this.value !== 'object' || !(this.value instanceof Array)) {
    throw Error('Invalid value for field ' + this.name);
  }
Severity: Major
Found in classes/Field.js and 1 other location - About 6 hrs to fix
classes/Field.js on lines 135..146

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

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

Del.prototype.filter = function(name, value, operator) {
  if (typeof operator === 'undefined') {
    operator = '=';
  }
  if (operator != '=' && operator != '<' && operator != '>' && operator != '<=' && operator != '>=') {
Severity: Major
Found in classes/Del.js and 1 other location - About 4 hrs to fix
classes/Get.js on lines 69..78

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

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

Get.prototype.filter = function(name, value, operator) {
  if (typeof operator === 'undefined') {
    operator = '=';
  }
  if (operator != '=' && operator != '<' && operator != '>' && operator != '<=' && operator != '>=') {
Severity: Major
Found in classes/Get.js and 1 other location - About 4 hrs to fix
classes/Del.js on lines 36..45

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

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

DataStream.prototype.readInet = function() {
  var i;
  if (this.data.length === 4) {
    // IPv4
    var inet = [];
Severity: Minor
Found in classes/DataStream.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 _executeJoin has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Get.prototype._executeJoin = function(rows, join) {
  var self = this;
  var defer = Q.defer();
  var columns = {};
  var values = {};
Severity: Major
Found in classes/Get.js - About 2 hrs to fix

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

      var next = function() {
        if (!rows.valid()) {
          rows.rewind();
          defer.resolve({columns: columns, values: values});
          return;
    Severity: Major
    Found in classes/Get.js - About 2 hrs to fix

      Function translateType has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Schema.prototype.translateType = function(validator) {
        validator = validator.split('org.apache.cassandra.db.marshal.').join('');
        var baseType = validator.split('(')[0];
        var types = {
          'AsciiType': TypeSpec.ASCII,
      Severity: Minor
      Found in classes/Schema.js - About 1 hr to fix

        Function execute has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        Get.prototype.execute = function() {
          var self = this;
          return Q.when(this._schema).then(function(schema) {
            if (typeof schema === 'undefined') {
              throw Error('Unknown table ' + self._table);
        Severity: Minor
        Found in classes/Get.js - About 1 hr to fix

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

          Transport.prototype.connect = function() {
            var self = this;
            
            if (new Date() - this._lastConnectAttempt < 5000) {
              return;
          Severity: Minor
          Found in classes/Transport.js - About 1 hr to fix

            Function Rows has 36 lines of code (exceeds 25 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 1 hr to fix

              Function execute has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              Query.prototype.execute = function() {
                var self = this;
                var defer = Q.defer();
                
                var length = Buffer.byteLength(this._cql, 'utf8');
              Severity: Minor
              Found in classes/Query.js - About 1 hr to fix

                Function readByType has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                DataStream.prototype.readByType = function(type) {
                  switch (type.getType()) {
                    case TypeSpec.ASCII:
                    case TypeSpec.VARCHAR:
                    case TypeSpec.TEXT:
                Severity: Minor
                Found in classes/DataStream.js - About 1 hr to fix

                  Function getValueString has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  Field.prototype.getValueString = function() {
                    if (this.value === null) {
                      // All field types can be null.
                      return 'NULL';
                    }
                  Severity: Minor
                  Found in classes/Field.js - About 1 hr to fix

                    Function execute has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    Set.prototype.execute = function() {
                      var self = this;
                      return Q.when(this._schema).then(function(schema) {
                        self._update.forEach(function(update) {
                          if (typeof schema.columns[update.field] === 'undefined') {
                    Severity: Minor
                    Found in classes/Set.js - About 1 hr to fix

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

                      DataStream.prototype.readInet = function() {
                        var i;
                        if (this.data.length === 4) {
                          // IPv4
                          var inet = [];
                      Severity: Minor
                      Found in classes/DataStream.js - About 1 hr to fix

                        Function _fetchFrames has 28 lines of code (exceeds 25 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

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

                          DataStream.prototype.readInt = function() {
                            var output = this.data.readUInt32BE(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 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

                          Severity
                          Category
                          Status
                          Source
                          Language