File client.js
has 798 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict';
// Util Modules
const EventEmitter = require('events').EventEmitter;
const debug = require('debug')('bacstack');
Function _processConfirmedServiceRequest
has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring. Open
_processConfirmedServiceRequest(address, type, service, maxSegments, maxApdu, invokeId, buffer, offset, length) {
let result;
debug('Handle this._processConfirmedServiceRequest');
if (service === baEnum.ConfirmedServiceChoice.READ_PROPERTY) {
result = baServices.readProperty.decode(buffer, offset, length);
- 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
Client
has 49 functions (exceeds 20 allowed). Consider refactoring. Open
class Client extends EventEmitter {
constructor(options) {
super();
options = options || {};
Function _processUnconfirmedServiceRequest
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
_processUnconfirmedServiceRequest(address, type, service, buffer, offset, length) {
let result;
debug('Handle this._processUnconfirmedServiceRequest');
if (service === baEnum.UnconfirmedServiceChoice.I_AM) {
result = baServices.iAmBroadcast.decode(buffer, offset);
- 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 _processConfirmedServiceRequest
has 95 lines of code (exceeds 25 allowed). Consider refactoring. Open
_processConfirmedServiceRequest(address, type, service, maxSegments, maxApdu, invokeId, buffer, offset, length) {
let result;
debug('Handle this._processConfirmedServiceRequest');
if (service === baEnum.ConfirmedServiceChoice.READ_PROPERTY) {
result = baServices.readProperty.decode(buffer, offset, length);
Function _handlePdu
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
_handlePdu(address, type, buffer, offset, length) {
let result;
// Handle different PDU types
switch (type & baEnum.PDU_TYPE_MASK) {
case baEnum.PduTypes.UNCONFIRMED_REQUEST:
Function _processUnconfirmedServiceRequest
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
_processUnconfirmedServiceRequest(address, type, service, buffer, offset, length) {
let result;
debug('Handle this._processUnconfirmedServiceRequest');
if (service === baEnum.UnconfirmedServiceChoice.I_AM) {
result = baServices.iAmBroadcast.decode(buffer, offset);
Avoid deeply nested control flow statements. Open
if (!result) return debug('Received invalid writePropertyMultiple message');
Avoid deeply nested control flow statements. Open
} else if (service === baEnum.ConfirmedServiceChoice.CONFIRMED_COV_NOTIFICATION) {
result = baServices.covNotify.decode(buffer, offset, length);
if (!result) return debug('Received invalid covNotify message');
this.emit('covNotify', {address: address, invokeId: invokeId, request: result});
} else if (service === baEnum.ConfirmedServiceChoice.ATOMIC_WRITE_FILE) {
Function _performDefaultSegmentHandling
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
_performDefaultSegmentHandling(sender, adr, type, service, invokeId, maxSegments, maxApdu, sequencenumber, first, moreFollows, buffer, offset, length) {
if (first) {
this._segmentStore = [];
type &= ~baEnum.PduConReqBits.SEGMENTED_MESSAGE;
let apduHeaderLen = 3;
- 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
} else if (service === baEnum.UnconfirmedServiceChoice.TIME_SYNCHRONIZATION) {
result = baServices.timeSync.decode(buffer, offset, length);
if (!result) return debug('Received invalid TimeSync message');
/**
Function _processSegment
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
_processSegment(receiver, type, service, invokeId, maxSegments, maxApdu, server, sequencenumber, proposedWindowNumber, buffer, offset, length) {
let first = false;
if (sequencenumber === 0 && this._lastSequenceNumber === 0) {
first = true;
} else {
- 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 (!result) return debug('Received invalid covNotifyUnconfirmed message');
Function _handlePdu
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
_handlePdu(address, type, buffer, offset, length) {
let result;
// Handle different PDU types
switch (type & baEnum.PDU_TYPE_MASK) {
case baEnum.PduTypes.UNCONFIRMED_REQUEST:
- 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
if (!result) return debug('Received invalid subscribeProperty message');
Avoid too many return
statements within this function. Open
if (!result) return debug('Received invalid eventNotifyData message');
Avoid too many return
statements within this function. Open
if (!result) return debug('Received invalid removeListElement message');
Avoid too many return
statements within this function. Open
if (!result) return debug('Received invalid TimeSync message');
Avoid too many return
statements within this function. Open
if (!result) return debug('Received invalid ihaveBroadcast message');
Avoid too many return
statements within this function. Open
if (!result) return debug('Received invalid deleteObject message');
Avoid too many return
statements within this function. Open
if (!result) return debug('Received invalid covNotify message');
Avoid too many return
statements within this function. Open
if (!result) return debug('Received invalid createObject message');
Avoid too many return
statements within this function. Open
if (!result) return debug('Received invalid alarmAcknowledge message');
Avoid too many return
statements within this function. Open
if (!result) return debug('Received invalid TimeSyncUTC message');
Avoid too many return
statements within this function. Open
if (!result) return debug('Received invalid privateTransfer message');
Avoid too many return
statements within this function. Open
if (!result) return debug('Received invalid reinitializeDevice message');
Avoid too many return
statements within this function. Open
if (!result) return debug('Received invalid EventNotify message');
Avoid too many return
statements within this function. Open
if (!result) return debug('Received invalid lifeSafetyOperation message');
Avoid too many return
statements within this function. Open
if (!result) return debug('Received invalid subscribeCOV message');
Avoid too many return
statements within this function. Open
if (!result) return debug('Received invalid deviceCommunicationControl message');
Avoid too many return
statements within this function. Open
if (!result) return debug('Received invalid getEventInformation message');
Avoid too many return
statements within this function. Open
if (!result) return debug('Received invalid readRange message');
Avoid too many return
statements within this function. Open
if (!result) return debug('Received invalid atomicWriteFile message');
Avoid too many return
statements within this function. Open
if (!result) return debug('Received invalid atomicReadFile message');
Avoid too many return
statements within this function. Open
if (!result) return debug('Received invalid getEntrollmentSummary message');
Avoid too many return
statements within this function. Open
if (!result) return debug('Received invalid privateTransfer message');
Avoid too many return
statements within this function. Open
if (!result) return debug('Received invalid addListElement message');
Parsing error: Invalid ecmaVersion. Open
'use strict';
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/