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() {
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()));
}
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');
Avoid deeply nested control flow statements. Open
if (messageBody) {
Object.assign(result, this.prepareResult(messageBody.getValList()));
}
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);
- 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"
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');
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;
- 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"
Further reading
Avoid too many return
statements within this function. Open
return Buffer.from(message.substr(idx+regMessage[1].length), 'hex');
Avoid too many return
statements within this function. Open
return Buffer.from(message.substr(idx+regMessage[1].length+2));
Avoid too many return
statements within this function. Open
return;
Avoid too many return
statements within this function. Open
return;
Avoid too many return
statements within this function. Open
return null;
Avoid too many return
statements within this function. Open
return false;
Avoid too many return
statements within this function. Open
return Buffer.from(message.substr(idx+regMessage[1].length+2));
Avoid too many return
statements within this function. Open
return null; // ignore pot. other data in message ... we use the next message
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);
- 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"
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;
- 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"