Showing 5 of 6 total issues
Function _onData
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
Open
async _onData(data) {
try {
this.emit('serial-msg', data)
if (this._reading) {
// read only 1 line
- 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 parseSms
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
Open
const parseSms = (() => {
let parts = {}
return function parseSms(data) {
try {
const matches = /\+(?:CMGR)|(?:CMT):.+\r((?:[\r\n]|.)+)\r(?:OK\r)?$/.exec(data)
- 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 _onData
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async _onData(data) {
try {
this.emit('serial-msg', data)
if (this._reading) {
// read only 1 line
Function parseSms
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const parseSms = (() => {
let parts = {}
return function parseSms(data) {
try {
const matches = /\+(?:CMGR)|(?:CMT):.+\r((?:[\r\n]|.)+)\r(?:OK\r)?$/.exec(data)
Function parseSms
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
return function parseSms(data) {
try {
const matches = /\+(?:CMGR)|(?:CMT):.+\r((?:[\r\n]|.)+)\r(?:OK\r)?$/.exec(data)
const pdu = parsePdu(matches[1])
pdu.text = pdu.text.replace(/\0/g, '')