danielwippermann/resol-vbus

View on GitHub
src/tcp-connection.js

Summary

Maintainability
D
2 days
Test Coverage

Function _connect has 235 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    _connect(force) {
        const _this = this;

        let socket;

Severity: Major
Found in src/tcp-connection.js - About 1 day to fix

    Function onLine has 96 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

                const onLine = function(line) {
                    let newPhase = -1;
                    if (line [0] === '+') {
                        if (phase === 0) {
                            if (_this.viaTag) {
    Severity: Major
    Found in src/tcp-connection.js - About 3 hrs to fix

      File tcp-connection.js has 300 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /*! resol-vbus | Copyright (c) 2013-present, Daniel Wippermann | MIT license */
      
      const net = require('net');
      const tls = require('tls');
      
      
      Severity: Minor
      Found in src/tcp-connection.js - About 3 hrs to fix

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

                    const onSocketData = function(chunk) {
                        // console.log('onData');
        
                        if (phase < 1000) {
                            // console.log(chunk.toString('utf8'));
        Severity: Minor
        Found in src/tcp-connection.js - About 1 hr to fix

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

                                  const channelListCallbackDone = (err, channel) => {
                                      if (err) {
                                          _this.socket.destroy();
                                          _this.socket = null;
          
          
          Severity: Minor
          Found in src/tcp-connection.js - About 1 hr to fix

            Avoid deeply nested control flow statements.
            Open

                                    if (md) {
                                        channelList.push({
                                            channel: md [1],
                                            name: md [2],
                                        });
            Severity: Major
            Found in src/tcp-connection.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                          if (err) {
                                              _this.socket.destroy();
                                              _this.socket = null;
              
                                              _this._setConnectionState(TcpConnection.STATE_DISCONNECTED);
              Severity: Major
              Found in src/tcp-connection.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    } else if (phase === 80) {
                                        newPhase = 900;
                                    } else if (phase === 900) {
                                        newPhase = 1000;
                                    }
                Severity: Major
                Found in src/tcp-connection.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if (isPromise(channelListCallbackResult)) {
                                              channelListCallbackResult.then(result => {
                                                  channelListCallbackDone(null, result);
                                              }, err => {
                                                  channelListCallbackDone(err);
                  Severity: Major
                  Found in src/tcp-connection.js - About 45 mins to fix

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

                        disconnect() {
                            if (this.connectionState === TcpConnection.STATE_DISCONNECTING) {
                                if (this.socket) {
                                    this.socket.destroy();
                    
                    
                    Severity: Minor
                    Found in src/tcp-connection.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

                    There are no issues that match your filters.

                    Category
                    Status