Function parseJsonString
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
export function parseJsonString(s: string, pos: number): string | undefined {
let str = ""
let c: string | undefined
parseJsonString.message = undefined
// eslint-disable-next-line no-constant-condition, @typescript-eslint/no-unnecessary-condition
- 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 parseJsonNumber
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
export function parseJsonNumber(s: string, pos: number, maxDigits?: number): number | undefined {
let numStr = ""
let c: string
parseJsonNumber.message = undefined
if (s[pos] === "-") {
- 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 parseJsonString
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function parseJsonString(s: string, pos: number): string | undefined {
let str = ""
let c: string | undefined
parseJsonString.message = undefined
// eslint-disable-next-line no-constant-condition, @typescript-eslint/no-unnecessary-condition
Function parseJsonNumber
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function parseJsonNumber(s: string, pos: number, maxDigits?: number): number | undefined {
let numStr = ""
let c: string
parseJsonNumber.message = undefined
if (s[pos] === "-") {
Avoid deeply nested control flow statements. Open
if (c === undefined) {
errorMessage("unexpected end")
return undefined
}
Avoid deeply nested control flow statements. Open
if (c >= "a" && c <= "f") {
code += c.charCodeAt(0) - CODE_A + 10
} else if (c >= "0" && c <= "9") {
code += c.charCodeAt(0) - CODE_0
} else {
Avoid too many return
statements within this function. Open
return str
Avoid too many return
statements within this function. Open
return +numStr
Avoid too many return
statements within this function. Open
return undefined
Function parseJson
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export function parseJson(s: string, pos: number): unknown {
let endPos: number | undefined
parseJson.message = undefined
let matches: RegExpExecArray | null
if (pos) s = s.slice(pos)
- 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"