freedomjs/freedom-for-node

View on GitHub

Showing 16 of 16 total issues

File core.tcpsocket.js has 286 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*globals require, console, Uint8Array */
/*jslint node:true,sloppy:true */

/**
 * A freedom.js tcp socket provider on Node Streams
Severity: Minor
Found in providers/core.tcpsocket.js - About 2 hrs to fix

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

    TcpSocket_node.prototype.resume = function (callback) {
      if (this.state === TcpSocket_node.state.CONNECTED) {
        this.connection.resume();
        callback();
      } else {
    Severity: Major
    Found in providers/core.tcpsocket.js and 1 other location - About 2 hrs to fix
    providers/core.tcpsocket.js on lines 69..79

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

    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

    TcpSocket_node.prototype.pause = function (callback) {
      if (this.state === TcpSocket_node.state.CONNECTED) {
        this.connection.pause();
        callback();
      } else {
    Severity: Major
    Found in providers/core.tcpsocket.js and 1 other location - About 2 hrs to fix
    providers/core.tcpsocket.js on lines 86..96

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

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

    module.exports = function (grunt) {
      'use strict';
      require('time-grunt')(grunt);
      require('jit-grunt')(grunt, {
        'npm-publish': 'grunt-npm'
    Severity: Major
    Found in Gruntfile.js - About 2 hrs to fix

      Function replaceBuffers has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      NodeLink.prototype.replaceBuffers = function(msg) {
        var retValue, i;
        if (typeof msg === 'object' && msg && msg.byteLength) {
          retValue = msg;
          try {
      Severity: Minor
      Found in lib/link.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

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

        for (var key in this.listeners) {
          if (this.listeners.hasOwnProperty(key)) {
            this.connection.on(key, this.listeners[key]);
          }
        }
      Severity: Major
      Found in providers/core.tcpsocket.js and 1 other location - About 1 hr to fix
      providers/core.tcpsocket.js on lines 211..215

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

      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

        for (var key in this.listeners) {
          if (this.listeners.hasOwnProperty(key)) {
            this.connection.removeListener(key, this.listeners[key]);
          }
        }
      Severity: Major
      Found in providers/core.tcpsocket.js and 1 other location - About 1 hr to fix
      providers/core.tcpsocket.js on lines 203..207

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

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

      TcpSocket_node.prototype.onError = function (error) {
        if (this.state === TcpSocket_node.state.CONNECTING) {
          this.callback(undefined, {
            "errcode": "CONNECTION_FAILED",
            "message": "Socket Error: " + error.message
      Severity: Minor
      Found in providers/core.tcpsocket.js - About 1 hr to fix

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

        TcpSocket_node.prototype.secure = function (callback) {
          if (this.state === TcpSocket_node.state.CONNECTED) {
            var cleartext = this.tlsconnect({
              socket: this.connection,
              rejectUnauthorized: true,
        Severity: Minor
        Found in providers/core.tcpsocket.js - About 1 hr to fix

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

          NodeLink.prototype.fix = function(message) {
            if (message && message.message && message.message.message) {
              message.message.message = this.replaceBuffers(message.message.message);
            }
            if (message && message.message && message.message.binary) {
          Severity: Minor
          Found in lib/link.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 deliverMessage has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          NodeLink.prototype.deliverMessage = function(flow, message) {
            if (this.obj) {
              /* //- For Debugging Purposes -
              if (!this.config.moduleContext) {
                console.warn('->[' + flow + '] ' + JSON.stringify(message));
          Severity: Minor
          Found in lib/link.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

          Function _checkDebug has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          Debug.prototype._checkDebug = function() {
            "use strict";
            var arg, equalsIndex, i; 
            for (i=0; i<process.execArgv.length; i++) {
              arg = process.execArgv[i];
          Severity: Minor
          Found in lib/debug.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 close has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          TcpSocket_node.prototype.close = function (continuation) {
            if (this.connection && this.state !== TcpSocket_node.state.CLOSED) {
              try {
                if (this.state === TcpSocket_node.state.LISTENING) {
                  // Close server socket
          Severity: Minor
          Found in providers/core.tcpsocket.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

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

            if (this.state === TcpSocket_node.state.CONNECTING) {
              this.state = TcpSocket_node.state.CONNECTED;
              TcpSocket_node.connectionState[this.id] = this.state;
            } else if (this.state === TcpSocket_node.state.BINDING) {
              this.state = TcpSocket_node.state.LISTENING;
          Severity: Minor
          Found in providers/core.tcpsocket.js and 1 other location - About 35 mins to fix
          providers/core.tcpsocket.js on lines 224..234

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

          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

            } else if (this.state === TcpSocket_node.state.BINDING) {
              this.state = TcpSocket_node.state.LISTENING;
              TcpSocket_node.connectionState[this.id] = this.state;
            } else if (this.state === TcpSocket_node.state.CONNECTED &&
                       this.connection.authorized === true) {
          Severity: Minor
          Found in providers/core.tcpsocket.js and 1 other location - About 35 mins to fix
          providers/core.tcpsocket.js on lines 221..234

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

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

          TcpSocket_node.prototype.onConnect = function (status) {
            if (this.state === TcpSocket_node.state.CONNECTING) {
              this.state = TcpSocket_node.state.CONNECTED;
              TcpSocket_node.connectionState[this.id] = this.state;
            } else if (this.state === TcpSocket_node.state.BINDING) {
          Severity: Minor
          Found in providers/core.tcpsocket.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