Apollon77/smartmeter-obis

View on GitHub

Showing 37 of 117 total issues

Function processData has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

StdInTransport.prototype.processData = function processData() {
    var self = this;
    if (!self.currentData || self.currentData.length === 0) return false;

    if (self.protocol.checkMessage(self.currentData.slice(0, self.currentDataOffset))) {
Severity: Minor
Found in lib/transports/StdInTransport.js - About 6 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 processData has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

SerialResponseTransport.prototype.processData = function processData() {
    var self = this;
    if (!self.currentData || self.currentData.length === 0) return false;
    if (self.protocol.checkMessage(self.currentData.slice(0, self.currentDataOffset))) {
        if (self.messageTimeoutTimer) {
Severity: Minor
Found in lib/transports/SerialResponseTransport.js - About 6 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 processData has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

TCPTransport.prototype.processData = function processData() {
    var self = this;
    if (!self.currentData || self.currentData.length === 0) return false;

    if (self.protocol.checkMessage(self.currentData.slice(0, self.currentDataOffset))) {
Severity: Minor
Found in lib/transports/TCPTransport.js - About 6 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 init has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

TCPTransport.prototype.init = function init() {
    this.protocol.initState(); // init State from protocol instance

    var self = this;
    if (!this.socket) {
Severity: Major
Found in lib/transports/TCPTransport.js - About 2 hrs to fix

    Function scheduleNextRun has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    TCPTransport.prototype.scheduleNextRun = function scheduleNextRun() {
        if (!this.stopRequests) {
            if (this.requestTimer) {
                clearTimeout(this.requestTimer);
                this.requestTimer = null;
    Severity: Minor
    Found in lib/transports/TCPTransport.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

    File SerialResponseTransport.js has 265 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* jshint -W097 */
    // jshint strict:true
    /*jslint node: true */
    /*jslint esversion: 6 */
    'use strict';
    Severity: Minor
    Found in lib/transports/SerialResponseTransport.js - About 2 hrs to fix

      Function processData has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      TCPTransport.prototype.processData = function processData() {
          var self = this;
          if (!self.currentData || self.currentData.length === 0) return false;
      
          if (self.protocol.checkMessage(self.currentData.slice(0, self.currentDataOffset))) {
      Severity: Major
      Found in lib/transports/TCPTransport.js - About 2 hrs to fix

        Function processData has 52 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        StdInTransport.prototype.processData = function processData() {
            var self = this;
            if (!self.currentData || self.currentData.length === 0) return false;
        
            if (self.protocol.checkMessage(self.currentData.slice(0, self.currentDataOffset))) {
        Severity: Major
        Found in lib/transports/StdInTransport.js - About 2 hrs to fix

          Function processData has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          SerialResponseTransport.prototype.processData = function processData() {
              var self = this;
              if (!self.currentData || self.currentData.length === 0) return false;
              if (self.protocol.checkMessage(self.currentData.slice(0, self.currentDataOffset))) {
                  if (self.messageTimeoutTimer) {
          Severity: Major
          Found in lib/transports/SerialResponseTransport.js - About 2 hrs to fix

            Function process has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            HttpRequestTransport.prototype.process = function process() {
                var self = this;
                request({'url': this.options.transportHttpRequestUrl, 'timeout': this.options.transportHttpRequestTimeout}, function (error, response, body) {
                    if (!error && response && response.statusCode === 200) {
                        try {
            Severity: Minor
            Found in lib/transports/HttpRequestTransport.js - About 1 hr to fix

              Function scheduleNextRun has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              SerialResponseTransport.prototype.scheduleNextRun = function scheduleNextRun() {
                  var self = this;
                  if (!this.stopRequests) {
                      if (this.requestTimer) {
                          clearTimeout(this.requestTimer);
              Severity: Minor
              Found in lib/transports/SerialResponseTransport.js - About 1 hr to fix

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

                                function finalizeMessageHandling() {
                                    if (self.options.debug === 2) self.options.logger('RESUME READING SERIALPORT IN FINALIZE');
                                    if (self.serialComm && !self.stopRequests) self.serialComm.resume(); // we want to read continously
                
                                    if (self.options.debug === 2) self.options.logger('SET MESSAGE TIMEOUT TIMER: ' + self.options.transportSerialMessageTimeout);
                Severity: Minor
                Found in lib/transports/SerialRequestResponseTransport.js - About 1 hr to fix

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

                  TCPTransport.prototype.scheduleNextRun = function scheduleNextRun() {
                      if (!this.stopRequests) {
                          if (this.requestTimer) {
                              clearTimeout(this.requestTimer);
                              this.requestTimer = null;
                  Severity: Minor
                  Found in lib/transports/TCPTransport.js - About 1 hr to fix

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

                    StdInTransport.prototype.scheduleNextRun = function scheduleNextRun() {
                        if (!this.stopRequests) {
                            if (this.requestTimer) {
                                clearTimeout(this.requestTimer);
                                this.requestTimer = null;
                    Severity: Minor
                    Found in lib/transports/StdInTransport.js - About 1 hr to fix

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

                                      function sendOutMessages(messagesToSend) {
                                          if (messagesToSend > 0) {
                                              self.protocol.getNextMessage(self.serialComm, function(nextData) {
                                                  if (self.options.debug === 2) self.options.logger('TO SEND ' + messagesToSend + ': ' + nextData);
                                                  if (typeof nextData === 'string' || typeof nextData === 'object') {
                      Severity: Minor
                      Found in lib/transports/SerialRequestResponseTransport.js - About 1 hr to fix

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

                        SerialRequestResponseTransport.prototype.scheduleNextRun = function scheduleNextRun() {
                            if (!this.stopRequests) {
                                if (this.requestTimer) {
                                    clearTimeout(this.requestTimer);
                                    this.requestTimer = null;
                        Severity: Minor
                        Found in lib/transports/SerialRequestResponseTransport.js - About 1 hr to fix

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

                          SerialRequestResponseTransport.prototype.stop = function stop(callback) {
                              if (this.options.debug === 2) this.options.logger('STOP');
                              this.stopRequests = true;
                              if (this.requestTimer) {
                                  clearTimeout(this.requestTimer);
                          Severity: Minor
                          Found in lib/transports/SerialRequestResponseTransport.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 prepareResult has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                          SmlProtocol.prototype.prepareResult = function prepareResult(list) {
                              var result = {};
                              for (var i = 0; i < list.getLength(); i++) {
                                  var entry = list.getListEntryAt(i);
                                  try {
                          Severity: Minor
                          Found in lib/protocols/SmlProtocol.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 (!commObj || typeof commObj.update !== 'function') {
                                          this.callUserCallback(new Error('Serialport instance needed for baudrate changeover'), null);
                                          callback('');
                                          return;
                                      }
                          Severity: Major
                          Found in lib/protocols/D0Protocol.js - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                            if (err) {
                                                                self.options.logger('ERROR CLOSING SERIALPORT: ' + err);
                                                            }
                            Severity: Major
                            Found in lib/transports/SerialRequestResponseTransport.js - About 45 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language