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))) {
- 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 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) {
- 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 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))) {
- 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 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) {
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;
- 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
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';
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))) {
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))) {
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) {
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 {
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);
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);
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;
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;
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') {
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;
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);
- 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 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 {
- 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 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;
}
Avoid deeply nested control flow statements. Open
if (err) {
self.options.logger('ERROR CLOSING SERIALPORT: ' + err);
}