Showing 28 of 422 total issues
Interval
has 70 functions (exceeds 20 allowed). Consider refactoring. Open
Open
export class Interval implements IntervalLike, IntervalQualifier {
low: number;
high: number;
/**
* @default 'open'
File letter-matrix.const.ts
has 596 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { NEWLINE } from '../../regex/index.js';
export type SmallLetterMatrixAlphabet = (typeof UPPERCASE_ALPHABET)[number];
type RowRenderedLetter = string[];
export type RowRenderedAlphaBet = Record<SmallLetterMatrixAlphabet, RowRenderedLetter>;
BoundingBox
has 61 functions (exceeds 20 allowed). Consider refactoring. Open
Open
export class BoundingBox {
/**
* from left to right
*/
horizontal: Interval = Interval.EMPTY;
File interval.class.ts
has 517 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { Vec2 } from '../../model/vector/vec2.class.js';
import type { Vec2Like, Vec2String } from '../../model/vector/vec2.class.types.js';
export interface IntervalLike extends Partial<IntervalQualifier> {
low: number;
File bounding-box.class.ts
has 424 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { Direction, Interval, max } from '../../index.js';
import { Vec2 } from './vec2.class.js';
import type { Vec2Like } from './vec2.class.types.js';
export type BoundingBoxCorner = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight';
IntCodeComputer
has 33 functions (exceeds 20 allowed). Consider refactoring. Open
Open
export class IntCodeComputer implements Iterable<number | undefined> {
public tape: Map<number, number>;
public cursor = 0;
public relBase = 0;
private halt = false;
Function addCameraFollowSystem
has a Cognitive Complexity of 53 (exceeds 30 allowed). Consider refactoring. Open
Open
export const addCameraFollowSystem = (gridWorld: GridWorld): void => {
gridWorld.addSystem((world) => {
const camera = world.query(CameraComponent)[0]?.[1];
// IO-less worlds have no camera
if (!camera) {
- 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 calculateVariations
has 82 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const calculateVariations = (
state: State,
cache: Map<string, number> = new Map(),
): number => {
const key = `${state.remainingCriteria.join(',')};${state.remainingDamagedLog};${state.remainingDamagedLog};${state.currentOriginalCriteria};${state.currentCriteria}`;
Function parse
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const parse = (input: string): Card => {
let parsing: ParseableData = ParseableData.SEEDS;
let seeds: number[] = [];
const seedToSoilMap: Range[] = [];
const soilToFertilizerMap: Range[] = [];
PairTree
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
Open
export class PairTree<T = number> {
public parent?: PairTree<T> | undefined;
public parentSide?: PairSide | undefined;
public leftTree?: PairTree<T> | undefined;
public leftValue?: T | undefined;
Function addCameraFollowSystem
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const addCameraFollowSystem = (gridWorld: GridWorld): void => {
gridWorld.addSystem((world) => {
const camera = world.query(CameraComponent)[0]?.[1];
// IO-less worlds have no camera
if (!camera) {
LeafonlyBinaryTree
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
Open
export class LeafonlyBinaryTree<T = number> {
public parent?: LeafonlyBinaryTree<T> | undefined;
public parentSide?: BinarySide | undefined;
public leftTree?: LeafonlyBinaryTree<T> | undefined;
public leftValue?: T | undefined;
Function dijkstra
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const dijkstra = <
T extends ToString,
Dir extends ToString,
N extends BasicGraphNode<T, Dir>,
>(
Function parse
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const parse = (input: string): { monkeyMap: Record<number, Monkey>; monkeys: Monkey[] } => {
const lines = split(input, true);
const monkeyMap: Record<number, Monkey> = {};
const monkeyIdMatcher = /^Monkey (\d+):$/;
Function Symbol.iterator
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public *[Symbol.iterator](): IterableIterator<number | undefined> {
do {
const v = this.tape.get(this.cursor) ?? 0;
const i = toInstruction(v);
switch (i) {
Function mergeQualifiedNumbers
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static mergeQualifiedNumbers(
this: void,
qualifiedNumbers: QualifiedNumber[],
useSort = true,
): Interval[] {
Function energizeMap
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const energizeMap = (gg: GridGraph, startingBeam: Beam): number => {
let beams: Beam[] = [startingBeam];
const beamPathHistory = new Map<string, Set<string>>();
while (beams.length > 0) {
const spawnedBeams: Beam[] = [];
Function compress
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public compress(rounds = 1, maxDistinctKeys = Number.POSITIVE_INFINITY): number[] {
let p: string | undefined = this.tape[0];
let result: number[] = [];
let i = 0;
let r = rounds;
Function parse
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const parse = (input: string): TicketObservation => {
const lines = split(input);
const fieldRanges = new Map<string, Interval[]>();
let myTicket: Ticket = [];
const nearbyTickets: Ticket[] = [];
Function init
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
init(): void {
this.backend.onKeyPress((event, _modifier) => {
this.keyBuffer[event] = 1;
switch (event) {