Apollon77/smartmeter-obis

View on GitHub

Showing 37 of 117 total issues

Avoid deeply nested control flow statements.
Open

                                if (self.serialComm && nextData.length > 0) {
                                    self.serialComm.write(nextData, function () {
                                        self.serialComm.drain(function() {
                                            if (self.options.debug === 2) self.options.logger('DONE SEND ' + messagesToSend);
                                            setTimeout(function() {
Severity: Major
Found in lib/transports/SerialRequestResponseTransport.js - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                    if (smlFile.messages[msg].isValid() || this.options.protocolSmlIgnoreInvalidCRC) {
                        var messageBody = smlFile.messages[msg].getMessageBody();
                        if (messageBody) {
                            Object.assign(result, this.prepareResult(messageBody.getPeriodList()));
                        }
    Severity: Major
    Found in lib/protocols/SmlProtocol.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                      if (self.options.debug === 2) self.options.logger('DELETE all data (' + self.currentDataOffset + ') because of Buffer overrun missed data');
      Severity: Major
      Found in lib/transports/SerialRequestResponseTransport.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if (messageBody) {
                                Object.assign(result, this.prepareResult(messageBody.getValList()));
                            }
        Severity: Major
        Found in lib/protocols/SmlProtocol.js - About 45 mins to fix

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

          SerialResponseTransport.prototype.process = function process() {
              var self = this;
              function startIt() {
                  if (self.messageTimeoutTimer) {
                      clearTimeout(self.messageTimeoutTimer);
          Severity: Minor
          Found in lib/transports/SerialResponseTransport.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

          Consider simplifying this complex logical expression.
          Open

                  if (!error && response && response.statusCode === 200) {
                      try {
                          body = Buffer.from(body);
                      } catch (e) {
                          if (self.options.debug === 2) self.options.logger('CAN NOT ALLOCATE MEMORY! STOPPING');
          Severity: Major
          Found in lib/transports/HttpRequestTransport.js - About 40 mins to fix

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

            function TCPTransport(options, protocol) {
                this.options = options || {};
                this.protocol = protocol;
                this.socket = undefined;
            
            
            Severity: Minor
            Found in lib/transports/TCPTransport.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 Buffer.from(message.substr(idx+regMessage[1].length), 'hex');
            Severity: Major
            Found in lib/protocols/SmlProtocol.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                              return Buffer.from(message.substr(idx+regMessage[1].length+2));
              Severity: Major
              Found in lib/protocols/D0Protocol.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                return;
                Severity: Major
                Found in lib/transports/SerialRequestResponseTransport.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                      return;
                  Severity: Major
                  Found in lib/transports/SerialRequestResponseTransport.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return null;
                    Severity: Major
                    Found in lib/protocols/SmlProtocol.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                          return false;
                      Severity: Major
                      Found in lib/transports/SerialResponseTransport.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                        return Buffer.from(message.substr(idx+regMessage[1].length+2));
                        Severity: Major
                        Found in lib/protocols/D0Protocol.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                              return null; // ignore pot. other data in message ... we use the next message
                          Severity: Major
                          Found in lib/protocols/SmlProtocol.js - About 30 mins to fix

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

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

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

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