File asn1.js
has 1528 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict';
const iconv = require('iconv-lite');
const baEnum = require('./enum');
Function bacappDecodeContextApplicationData
has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring. Open
const bacappDecodeContextApplicationData = (buffer, offset, maxOffset, objectType, propertyId) => {
let len = 0;
let result;
if (isContextSpecific(buffer[offset])) {
if (propertyId === baEnum.PropertyIdentifier.LIST_OF_GROUP_MEMBERS) {
- 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 decodeReadAccessResult
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
const decodeReadAccessResult = module.exports.decodeReadAccessResult = (buffer, offset, apduLen) => {
let len = 0;
const value = {};
if (!decodeIsContextTag(buffer, offset + len, 0)) return;
len++;
- 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 bacappDecodeContextApplicationData
has 127 lines of code (exceeds 25 allowed). Consider refactoring. Open
const bacappDecodeContextApplicationData = (buffer, offset, maxOffset, objectType, propertyId) => {
let len = 0;
let result;
if (isContextSpecific(buffer[offset])) {
if (propertyId === baEnum.PropertyIdentifier.LIST_OF_GROUP_MEMBERS) {
Function bacappContextTagType
has 117 lines of code (exceeds 25 allowed). Consider refactoring. Open
const bacappContextTagType = (property, tagNumber) => {
let tag = 0;
switch (property) {
case baEnum.PropertyIdentifier.ACTUAL_SHED_LEVEL:
case baEnum.PropertyIdentifier.REQUESTED_SHED_LEVEL:
Function decodeReadAccessResult
has 87 lines of code (exceeds 25 allowed). Consider refactoring. Open
const decodeReadAccessResult = module.exports.decodeReadAccessResult = (buffer, offset, apduLen) => {
let len = 0;
const value = {};
if (!decodeIsContextTag(buffer, offset + len, 0)) return;
len++;
Function decodeCovSubscription
has 87 lines of code (exceeds 25 allowed). Consider refactoring. Open
const decodeCovSubscription = (buffer, offset, apduLen) => {
let len = 0;
const value = {};
let result;
let decodedValue;
Function decodeCovSubscription
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
const decodeCovSubscription = (buffer, offset, apduLen) => {
let len = 0;
const value = {};
let result;
let decodedValue;
- 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 bacappDecodeData
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
const bacappDecodeData = (buffer, offset, maxLength, tagDataType, lenValueType) => {
let result;
const value = {
len: 0,
type: tagDataType
Function decodeReadAccessSpecification
has a Cognitive Complexity of 19 (exceeds 5 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++;
- 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 bacappEncodeApplicationData
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
const bacappEncodeApplicationData = module.exports.bacappEncodeApplicationData = (buffer, value) => {
if (value.value === null) {
value.type = baEnum.ApplicationTags.NULL;
}
switch (value.type) {
Function bacappContextTagType
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
const bacappContextTagType = (property, tagNumber) => {
let tag = 0;
switch (property) {
case baEnum.PropertyIdentifier.ACTUAL_SHED_LEVEL:
case baEnum.PropertyIdentifier.REQUESTED_SHED_LEVEL:
- 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 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 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 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++;
Function decodeTagNumberAndValue
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
const decodeTagNumberAndValue = module.exports.decodeTagNumberAndValue = (buffer, offset) => {
let value;
let result = decodeTagNumber(buffer, offset);
let len = result.len;
if (isExtendedValue(buffer[offset])) {
Function decodeCalendar
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
const decodeCalendar = (buffer, offset, apduLen) => {
let len = 0;
const entries = [];
let decodedValue;
while (len < apduLen) {
Function bacappDecodeApplicationData
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
const bacappDecodeApplicationData = module.exports.bacappDecodeApplicationData = (buffer, offset, maxOffset, objectType, propertyId) => {
if (!isContextSpecific(buffer[offset])) {
let result = decodeTagNumberAndValue(buffer, offset);
if (result) {
const len = result.len;
- 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 byteReverseBits
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
const byteReverseBits = (inByte) => {
let outByte = 0;
if ((inByte & 1) > 0) {
outByte |= 0x80;
}
Function encodeTag
has a Cognitive Complexity of 9 (exceeds 5 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) {
- 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 decodeTagNumberAndValue
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
const decodeTagNumberAndValue = module.exports.decodeTagNumberAndValue = (buffer, offset) => {
let value;
let result = decodeTagNumber(buffer, offset);
let len = result.len;
if (isExtendedValue(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
Avoid deeply nested control flow statements. Open
} else if (propertyId === baEnum.PropertyIdentifier.LIST_OF_OBJECT_PROPERTY_REFERENCES || propertyId === baEnum.PropertyIdentifier.LOG_DEVICE_OBJECT_PROPERTY || propertyId === baEnum.PropertyIdentifier.OBJECT_PROPERTY_REFERENCE) {
result = decodeDeviceObjPropertyRef(buffer, offset, maxOffset);
if (!result) return;
return {
type: baEnum.ApplicationTags.OBJECT_PROPERTY_REFERENCE,
Function byteReverseBits
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
const byteReverseBits = (inByte) => {
let outByte = 0;
if ((inByte & 1) > 0) {
outByte |= 0x80;
}
- 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;
Avoid deeply nested control flow statements. Open
if (bacappResult.encoding !== undefined) resObj.encoding = bacappResult.encoding;
Avoid too many return
statements within this function. Open
return {
len: len,
value: value
};
Avoid too many return
statements within this function. Open
if (!result) return;
Avoid too many return
statements within this function. Open
if (!result) return;
Avoid too many return
statements within this function. Open
if (!subResult) return;
Avoid too many return
statements within this function. Open
if (!decodeIsClosingTagNumber(buffer, offset + len, 0)) return;
Avoid too many return
statements within this function. Open
return {
type: baEnum.ApplicationTags.CONTEXT_SPECIFIC_DECODED,
value: result.value,
len: result.len
};
Avoid too many return
statements within this function. Open
if (!bacappResult) return;
Avoid too many return
statements within this function. Open
if (!decodeIsClosingTagNumber(buffer, offset + len, 0)) return;
Avoid too many return
statements within this function. Open
if (result.tagNumber !== 1) return;
Avoid too many return
statements within this function. Open
return {
type: baEnum.ApplicationTags.TIMESTAMP,
value: subEvtResult.value,
len: subEvtResult.len + 1
};
Avoid too many return
statements within this function. Open
if ((len + offset) > maxOffset) return;
Avoid too many return
statements within this function. Open
return;
Avoid too many return
statements within this function. Open
if (result.tagNumber !== baEnum.ApplicationTags.OCTET_STRING) return;
Avoid too many return
statements within this function. Open
return {
len: len,
value: value
};
Avoid too many return
statements within this function. Open
if ((len + tmp.value) >= apduLen) return;
Avoid too many return
statements within this function. Open
if (!decodeIsClosingTagNumber(buffer, offset + len, 1)) return;
Avoid too many return
statements within this function. Open
if (result.tagNumber !== 0) return;
Avoid too many return
statements within this function. Open
return {
type: baEnum.ApplicationTags.UNSIGNED_INTEGER,
value: subEvtResult.value,
len: subEvtResult.len + 1
};
Avoid too many return
statements within this function. Open
if (!decodeIsClosingTagNumber(buffer, offset + len, 1)) return;
Avoid too many return
statements within this function. Open
if (result.tagNumber !== 1) return;
Avoid too many return
statements within this function. Open
if (result.tagNumber !== 4) return;
Avoid too many return
statements within this function. Open
return {
len: len,
value: list[0],
type: baEnum.ApplicationTags.CONTEXT_SPECIFIC_DECODED
};
Avoid too many return
statements within this function. Open
if (!decodeIsClosingTagNumber(buffer, offset + len, 4)) return;
Avoid too many return
statements within this function. Open
if (!result) return;
Avoid too many return
statements within this function. Open
if (!decodeIsClosingTagNumber(buffer, offset + len, 5)) return;
Avoid too many return
statements within this function. Open
if (!decodeIsOpeningTagNumber(buffer, offset + len, 1)) return;
Avoid too many return
statements within this function. Open
if ((len + result.value) >= apduLen) return;
Avoid too many return
statements within this function. Open
return {
type: baEnum.ApplicationTags.TIMESTAMP,
value: subEvtResult.value,
len: subEvtResult.len + 2
};
Avoid too many return
statements within this function. Open
if (result.tagNumber !== 2) return;
Avoid too many return
statements within this function. Open
return {
len: len,
value: value
};
Avoid too many return
statements within this function. Open
return {
type: baEnum.ApplicationTags.READ_ACCESS_RESULT,
value: result.value,
len: result.len
};
Avoid too many return
statements within this function. Open
if (!decodeIsClosingTagNumber(buffer, offset + len, 1)) return;
Avoid too many return
statements within this function. Open
return {
len: len,
value: list,
type: baEnum.ApplicationTags.CONTEXT_SPECIFIC_DECODED
};
Avoid too many return
statements within this function. Open
return;
Avoid too many return
statements within this function. Open
if (result.tagNumber !== 3) return;
Avoid too many return
statements within this function. Open
if (!result) return;
Avoid too many return
statements within this function. Open
return {
type: baEnum.ApplicationTags.OBJECT_PROPERTY_REFERENCE,
value: result.value,
len: result.len
};
Function decodeBitstring
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const decodeBitstring = module.exports.decodeBitstring = (buffer, offset, lenValue) => {
let len = 0;
const bitString = {};
bitString.value = [];
if (lenValue > 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 decodeDeviceObjPropertyRef
has a Cognitive Complexity of 6 (exceeds 5 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++;
- 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
HACK found Open
// HACK: Drop string specific handling ASAP
- Exclude checks
HACK found Open
return 'utf8'; // HACK: There is currently no support for UTF-32
- Exclude checks
HACK found Open
// HACK: Drop string specific handling ASAP
- Exclude checks
HACK found Open
// HACK: Drop string specific handling ASAP
- Exclude checks
Parsing error: Invalid ecmaVersion. Open
'use strict';
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/