src/tcp-connection.js
Function _connect
has 235 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
_connect(force) {
const _this = this;
let socket;
Function onLine
has 96 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const onLine = function(line) {
let newPhase = -1;
if (line [0] === '+') {
if (phase === 0) {
if (_this.viaTag) {
File tcp-connection.js
has 300 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
/*! resol-vbus | Copyright (c) 2013-present, Daniel Wippermann | MIT license */
const net = require('net');
const tls = require('tls');
Function onSocketData
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const onSocketData = function(chunk) {
// console.log('onData');
if (phase < 1000) {
// console.log(chunk.toString('utf8'));
Function channelListCallbackDone
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const channelListCallbackDone = (err, channel) => {
if (err) {
_this.socket.destroy();
_this.socket = null;
Avoid deeply nested control flow statements. Open
Open
if (isPromise(channelListCallbackResult)) {
channelListCallbackResult.then(result => {
channelListCallbackDone(null, result);
}, err => {
channelListCallbackDone(err);
Avoid deeply nested control flow statements. Open
Open
} else if (phase === 80) {
newPhase = 900;
} else if (phase === 900) {
newPhase = 1000;
}
Avoid deeply nested control flow statements. Open
Open
if (err) {
_this.socket.destroy();
_this.socket = null;
_this._setConnectionState(TcpConnection.STATE_DISCONNECTED);
Avoid deeply nested control flow statements. Open
Open
if (md) {
channelList.push({
channel: md [1],
name: md [2],
});
Function disconnect
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
disconnect() {
if (this.connectionState === TcpConnection.STATE_DISCONNECTING) {
if (this.socket) {
this.socket.destroy();
- Read upRead up
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"