Showing 365 of 365 total issues
Function decode
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
module.exports.decode = (buffer, offset) => {
let len = 0;
let result;
let decodedValue;
let isStream = true;
- 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 bacappEncodePropertyState
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports.bacappEncodePropertyState = (buffer, value) => {
switch (value.type) {
case baEnum.PropertyStates.BOOLEAN_VALUE:
encodeContextBoolean(buffer, 0, value.state === 1 ? true : false);
break;
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 decode
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
module.exports.decode = (buffer, offset) => {
let len = 0;
let result;
let decodedValue;
const eventData = {};
- 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 decodeAcknowledge
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports.decodeAcknowledge = (buffer, offset, apduLen) => {
let result;
let decodedValue;
const objectId = {};
const property = {};
Function decodeAcknowledge
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports.decodeAcknowledge = (buffer, offset, apduLen) => {
let len = 0;
let result;
let decodedValue;
if (!baAsn1.decodeIsContextTag(buffer, offset + len, 0)) return;
Function decodeReadAccessSpecification
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
const decodeReadAccessSpecification = module.exports.decodeReadAccessSpecification = (buffer, offset, apduLen) => {
let len = 0;
const value = {};
if (!decodeIsContextTag(buffer, offset + len, 0)) return;
len++;
Function decodeAcknowledge
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports.decodeAcknowledge = (buffer, offset, apduLen) => {
let len = 0;
let result;
const enrollmentSummaries = [];
while ((apduLen - len) > 0) {
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);
Function decodeAcknowledge
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports.decodeAcknowledge = (buffer, offset) => {
let len = 0;
let result;
let decodedValue;
let isStream;
Function decode
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports.decode = (buffer, offset) => {
const orgOffset = offset;
offset++;
const funct = buffer[offset++];
let destination;
Function decode
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports.decode = (buffer, offset, apduLen) => {
let len = 0;
let result;
let decodedValue;
const value = {};
Function decode
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports.decode = (buffer, offset, apduLen) => {
let len = 0;
const value = {};
let result;
let decodedValue;
Function decode
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports.decode = (buffer, offset) => {
let result;
let apduLen = 0;
const orgOffset = offset;
result = baAsn1.decodeTagNumberAndValue(buffer, offset + apduLen);
Function decode
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports.decode = (buffer, offset, apduLen) => {
let len = 0;
const value = {};
let decodedValue;
let result = baAsn1.decodeTagNumberAndValue(buffer, offset + len);
Function encodeTag
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
const encodeTag = module.exports.encodeTag = (buffer, tagNumber, contextSpecific, lenValueType) => {
let len = 1;
const tmp = new Array(3);
tmp[0] = 0;
if (contextSpecific) {
Function decode
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports.decode = (buffer, offset, apduLen) => {
let len = 0;
let result;
let decodedValue;
if (apduLen < 7) return;
Function decodeAcknowledge
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
module.exports.decodeAcknowledge = (buffer, offset, apduLen) => {
let len = 0;
let result;
const enrollmentSummaries = [];
while ((apduLen - len) > 0) {
- 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 decode
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports.decode = (buffer, offset) => {
let len;
const func = buffer[1];
const msgLength = (buffer[2] << 8) | (buffer[3] << 0);
if (buffer[0] !== baEnum.BVLL_TYPE_BACNET_IP || buffer.length !== msgLength) return;
Function decodeDeviceObjPropertyRef
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
const decodeDeviceObjPropertyRef = (buffer, offset) => {
let len = 0;
let arrayIndex = baEnum.ASN1_ARRAY_ALL;
if (!decodeIsContextTag(buffer, offset + len, 0)) return;
len++;