Showing 9 of 15 total issues
File parser.js
has 370 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict'
const Buffer = require('buffer').Buffer
const StringDecoder = require('string_decoder').StringDecoder
const decoder = new StringDecoder()
Function execute
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
execute (buffer) {
if (this.buffer === null) {
this.buffer = buffer
this.offset = 0
} else if (this.bigStrSize === 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 execute
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
execute (buffer) {
if (this.buffer === null) {
this.buffer = buffer
this.offset = 0
} else if (this.bigStrSize === 0) {
Function parseStringNumbers
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function parseStringNumbers (parser) {
const length = parser.buffer.length - 1
var offset = parser.offset
var number = 0
var res = ''
- 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 parseArrayElements
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function parseArrayElements (parser, responses, i) {
const bufferLength = parser.buffer.length
while (i < responses.length) {
const offset = parser.offset
if (parser.offset >= bufferLength) {
- 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 decreaseBufferPool
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function decreaseBufferPool () {
if (bufferPool.length > 50 * 1024) {
if (counter === 1 || notDecreased > counter * 2) {
const minSliceLen = Math.floor(bufferPool.length / 10)
const sliceLength = minSliceLen < bufferOffset
- 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 resizeBuffer
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function resizeBuffer (length) {
if (bufferPool.length < length + bufferOffset) {
const multiplier = length > 1024 * 1024 * 75 ? 2 : 3
if (bufferOffset > 1024 * 1024 * 111) {
bufferOffset = 1024 * 1024 * 50
- 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
return parser.buffer.toString('utf8', start, offset)
Function parseSimpleString
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function parseSimpleString (parser) {
const start = parser.offset
const buffer = parser.buffer
const length = buffer.length - 1
var offset = start
- 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"