Function backQuote
has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring. Open
const backQuote: TCharScannerFunction = (src: string, ctx: TScannerContext): boolean | never => {
// store "next" postion character.
let ch: TBD<string>;
// cache start 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
Function slash
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
const slash: TCharScannerFunction = (src: string, ctx: TScannerContext): boolean => {
// cache start offset
const startOffset = ctx.offset;
// fetch next char.
- 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 apply
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
const apply = (src: string, opt: TRemoveCStyleCommentsOpt): string => {
//
// step 1. remove {line, block} comments
//
- 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
File js-scanner.ts
has 287 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*!
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Copyright (C) 2020 jeffy-g <hirotom1107@gmail.com>
Released under the MIT license
https://opensource.org/licenses/mit-license.php
Function slash
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
const slash: TCharScannerFunction = (src: string, ctx: TScannerContext): boolean => {
// cache start offset
const startOffset = ctx.offset;
// fetch next char.
Function apply
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
const apply = (src: string, opt: TRemoveCStyleCommentsOpt): string => {
//
// step 1. remove {line, block} comments
//
Function backQuote
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
const backQuote: TCharScannerFunction = (src: string, ctx: TScannerContext): boolean | never => {
// store "next" postion character.
let ch: TBD<string>;
// cache start offset
Function quote
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
const quote: TCharScannerFunction = (src: string, ctx: TScannerContext): boolean => {
const startOffset = ctx.offset;
const q = src[startOffset];
// limiter
- 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 (!ctx.isWalk) {
ctx.result += src.substring(prevOffset, next);
}
Avoid deeply nested control flow statements. Open
if (!inspectable) {
next++;
continue;
}
Avoid deeply nested control flow statements. Open
if (scanListener!(eventContext)) {
ctx.result += fragment;
}
Avoid deeply nested control flow statements. Open
if (code === EMetaChars.RIGHT_CURLY) {
startOffset = ++next;
/* https://coderwall
when(prevOffset);
/*/
Function walk
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
const walk = (src: string, opt: TRemoveCStyleCommentsOpt): void => {
//
// run as walk through mode
//
- 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 true;