Function decode
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Wontfix
export const decode = (buf: Iterable<number>, utf8 = true) => {
const iter = buf[Symbol.iterator]();
const stack = [];
let i: IteratorResult<number>;
let x: any;
- Read upRead up
- Create a ticketCreate a ticket
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 collect
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Wontfix
const collect = (stack: any[], x: any, utf8 = false) => {
const parent = peek(stack);
if (!parent) return x;
if (parent.type === Type.LIST) {
parent.val.push(utf8 && isArray(x) ? utf8Decode(x) : x);
- Read upRead up
- Create a ticketCreate a ticket
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 readInt
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
const readInt = (iter: Iterator<number>, acc: number, end = Lit.END) => {
let i: IteratorResult<number>;
let x: number;
let isSigned = false;
while (!(i = iter.next()).done) {
- Read upRead up
- Create a ticketCreate a ticket
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. Wontfix
if (parent.type === Type.LIST) {
(<any[]>parent.val).push(x.val);
} else if (parent.type === Type.DICT) {
(<any>parent.val)[(<any>parent).key] = x.val;
(<any>parent).key = null;
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Wontfix
return peek(stack).val;
- Create a ticketCreate a ticket
Function readFloat
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Wontfix
const readFloat = (iter: Iterator<number>) => {
let i: IteratorResult<number>;
let x: number;
let acc = "";
while (!(i = iter.next()).done) {
- Read upRead up
- Create a ticketCreate a ticket
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"