Showing 52 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 has too many statements (57). Maximum allowed is 30. Open
this.serialComm.on('data', function (data) {
- Read upRead up
- Exclude checks
enforce a maximum number of statements allowed in function blocks (max-statements)
The max-statements
rule allows you to specify the maximum number of statements allowed in a function.
function foo() {
var bar = 1; // one statement
var baz = 2; // two statements
var qux = 3; // three statements
}
Rule Details
This rule enforces a maximum number of statements allowed in function blocks.
Options
This rule has a number or object option:
-
"max"
(default10
) enforces a maximum number of statements allows in function blocks
Deprecated: The object property maximum
is deprecated; please use the object property max
instead.
This rule has an object option:
-
"ignoreTopLevelFunctions": true
ignores top-level functions
max
Examples of incorrect code for this rule with the default { "max": 10 }
option:
/*eslint max-statements: ["error", 10]*/
/*eslint-env es6*/
function foo() {
var foo1 = 1;
var foo2 = 2;
var foo3 = 3;
var foo4 = 4;
var foo5 = 5;
var foo6 = 6;
var foo7 = 7;
var foo8 = 8;
var foo9 = 9;
var foo10 = 10;
var foo11 = 11; // Too many.
}
let foo = () => {
var foo1 = 1;
var foo2 = 2;
var foo3 = 3;
var foo4 = 4;
var foo5 = 5;
var foo6 = 6;
var foo7 = 7;
var foo8 = 8;
var foo9 = 9;
var foo10 = 10;
var foo11 = 11; // Too many.
};
Examples of correct code for this rule with the default { "max": 10 }
option:
/*eslint max-statements: ["error", 10]*/
/*eslint-env es6*/
function foo() {
var foo1 = 1;
var foo2 = 2;
var foo3 = 3;
var foo4 = 4;
var foo5 = 5;
var foo6 = 6;
var foo7 = 7;
var foo8 = 8;
var foo9 = 9;
var foo10 = 10;
return function () {
// The number of statements in the inner function does not count toward the
// statement maximum.
return 42;
};
}
let foo = () => {
var foo1 = 1;
var foo2 = 2;
var foo3 = 3;
var foo4 = 4;
var foo5 = 5;
var foo6 = 6;
var foo7 = 7;
var foo8 = 8;
var foo9 = 9;
var foo10 = 10;
return function () {
// The number of statements in the inner function does not count toward the
// statement maximum.
return 42;
};
}
ignoreTopLevelFunctions
Examples of additional correct code for this rule with the { "max": 10 }, { "ignoreTopLevelFunctions": true }
options:
/*eslint max-statements: ["error", 10, { "ignoreTopLevelFunctions": true }]*/
function foo() {
var foo1 = 1;
var foo2 = 2;
var foo3 = 3;
var foo4 = 4;
var foo5 = 5;
var foo6 = 6;
var foo7 = 7;
var foo8 = 8;
var foo9 = 9;
var foo10 = 10;
var foo11 = 11;
}
Related Rules
- [complexity](complexity.md)
- [max-depth](max-depth.md)
- [max-len](max-len.md)
- [max-nested-callbacks](max-nested-callbacks.md)
- [max-params](max-params.md) Source: http://eslint.org/docs/rules/
Function 'processData' has too many statements (38). Maximum allowed is 30. Open
TCPTransport.prototype.processData = function processData() {
- Read upRead up
- Exclude checks
enforce a maximum number of statements allowed in function blocks (max-statements)
The max-statements
rule allows you to specify the maximum number of statements allowed in a function.
function foo() {
var bar = 1; // one statement
var baz = 2; // two statements
var qux = 3; // three statements
}
Rule Details
This rule enforces a maximum number of statements allowed in function blocks.
Options
This rule has a number or object option:
-
"max"
(default10
) enforces a maximum number of statements allows in function blocks
Deprecated: The object property maximum
is deprecated; please use the object property max
instead.
This rule has an object option:
-
"ignoreTopLevelFunctions": true
ignores top-level functions
max
Examples of incorrect code for this rule with the default { "max": 10 }
option:
/*eslint max-statements: ["error", 10]*/
/*eslint-env es6*/
function foo() {
var foo1 = 1;
var foo2 = 2;
var foo3 = 3;
var foo4 = 4;
var foo5 = 5;
var foo6 = 6;
var foo7 = 7;
var foo8 = 8;
var foo9 = 9;
var foo10 = 10;
var foo11 = 11; // Too many.
}
let foo = () => {
var foo1 = 1;
var foo2 = 2;
var foo3 = 3;
var foo4 = 4;
var foo5 = 5;
var foo6 = 6;
var foo7 = 7;
var foo8 = 8;
var foo9 = 9;
var foo10 = 10;
var foo11 = 11; // Too many.
};
Examples of correct code for this rule with the default { "max": 10 }
option:
/*eslint max-statements: ["error", 10]*/
/*eslint-env es6*/
function foo() {
var foo1 = 1;
var foo2 = 2;
var foo3 = 3;
var foo4 = 4;
var foo5 = 5;
var foo6 = 6;
var foo7 = 7;
var foo8 = 8;
var foo9 = 9;
var foo10 = 10;
return function () {
// The number of statements in the inner function does not count toward the
// statement maximum.
return 42;
};
}
let foo = () => {
var foo1 = 1;
var foo2 = 2;
var foo3 = 3;
var foo4 = 4;
var foo5 = 5;
var foo6 = 6;
var foo7 = 7;
var foo8 = 8;
var foo9 = 9;
var foo10 = 10;
return function () {
// The number of statements in the inner function does not count toward the
// statement maximum.
return 42;
};
}
ignoreTopLevelFunctions
Examples of additional correct code for this rule with the { "max": 10 }, { "ignoreTopLevelFunctions": true }
options:
/*eslint max-statements: ["error", 10, { "ignoreTopLevelFunctions": true }]*/
function foo() {
var foo1 = 1;
var foo2 = 2;
var foo3 = 3;
var foo4 = 4;
var foo5 = 5;
var foo6 = 6;
var foo7 = 7;
var foo8 = 8;
var foo9 = 9;
var foo10 = 10;
var foo11 = 11;
}
Related Rules
- [complexity](complexity.md)
- [max-depth](max-depth.md)
- [max-len](max-len.md)
- [max-nested-callbacks](max-nested-callbacks.md)
- [max-params](max-params.md) Source: http://eslint.org/docs/rules/
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 has too many statements (31). Maximum allowed is 30. Open
this.socket.on('data', function (data) {
- Read upRead up
- Exclude checks
enforce a maximum number of statements allowed in function blocks (max-statements)
The max-statements
rule allows you to specify the maximum number of statements allowed in a function.
function foo() {
var bar = 1; // one statement
var baz = 2; // two statements
var qux = 3; // three statements
}
Rule Details
This rule enforces a maximum number of statements allowed in function blocks.
Options
This rule has a number or object option:
-
"max"
(default10
) enforces a maximum number of statements allows in function blocks
Deprecated: The object property maximum
is deprecated; please use the object property max
instead.
This rule has an object option:
-
"ignoreTopLevelFunctions": true
ignores top-level functions
max
Examples of incorrect code for this rule with the default { "max": 10 }
option:
/*eslint max-statements: ["error", 10]*/
/*eslint-env es6*/
function foo() {
var foo1 = 1;
var foo2 = 2;
var foo3 = 3;
var foo4 = 4;
var foo5 = 5;
var foo6 = 6;
var foo7 = 7;
var foo8 = 8;
var foo9 = 9;
var foo10 = 10;
var foo11 = 11; // Too many.
}
let foo = () => {
var foo1 = 1;
var foo2 = 2;
var foo3 = 3;
var foo4 = 4;
var foo5 = 5;
var foo6 = 6;
var foo7 = 7;
var foo8 = 8;
var foo9 = 9;
var foo10 = 10;
var foo11 = 11; // Too many.
};
Examples of correct code for this rule with the default { "max": 10 }
option:
/*eslint max-statements: ["error", 10]*/
/*eslint-env es6*/
function foo() {
var foo1 = 1;
var foo2 = 2;
var foo3 = 3;
var foo4 = 4;
var foo5 = 5;
var foo6 = 6;
var foo7 = 7;
var foo8 = 8;
var foo9 = 9;
var foo10 = 10;
return function () {
// The number of statements in the inner function does not count toward the
// statement maximum.
return 42;
};
}
let foo = () => {
var foo1 = 1;
var foo2 = 2;
var foo3 = 3;
var foo4 = 4;
var foo5 = 5;
var foo6 = 6;
var foo7 = 7;
var foo8 = 8;
var foo9 = 9;
var foo10 = 10;
return function () {
// The number of statements in the inner function does not count toward the
// statement maximum.
return 42;
};
}
ignoreTopLevelFunctions
Examples of additional correct code for this rule with the { "max": 10 }, { "ignoreTopLevelFunctions": true }
options:
/*eslint max-statements: ["error", 10, { "ignoreTopLevelFunctions": true }]*/
function foo() {
var foo1 = 1;
var foo2 = 2;
var foo3 = 3;
var foo4 = 4;
var foo5 = 5;
var foo6 = 6;
var foo7 = 7;
var foo8 = 8;
var foo9 = 9;
var foo10 = 10;
var foo11 = 11;
}
Related Rules
- [complexity](complexity.md)
- [max-depth](max-depth.md)
- [max-len](max-len.md)
- [max-nested-callbacks](max-nested-callbacks.md)
- [max-params](max-params.md) Source: http://eslint.org/docs/rules/
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"