src/list/list.ts
List
has 29 functions (exceeds 20 allowed). Consider refactoring. Wontfix
Wontfix
export class List<T> {
[k: string]: any;
constructor(generator: () => Generator<T, T[], T>, private readonly length: number) {
this[Symbol.iterator as any] = generator
Function all
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Wontfix
Wontfix
public all(fn: (val: T) => boolean): boolean {
const generator = this.generator()
const newList = new List<T>(<() => Generator<T, T, T>>function* () {
for (const value of generator as IterableIterator<T>) {
if (fn(value)) {
- 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"