Showing 19 of 26 total issues
Function findPath
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
export function findPath(grid: Grid): Move[] | null {
if (!grid || !grid.length) return null;
const hintTable: string[][] = [];
const path: Move[] = [];
- 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 findPathRecursively
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
export function findPathRecursively(grid: Grid, rowIndex?: number, columnIndex?: number): Move[] | null {
if (!grid || !grid.length) return null;
rowIndex = rowIndex != null ? rowIndex : grid.length - 1;
columnIndex = columnIndex != null ? columnIndex : grid[0].length - 1;
- 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 dijkstraShortestPath
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
export function dijkstraShortestPath(
graph: IUndirectedGraph,
sourceNode: string,
destinationNode: string,
): IPath {
- 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 findPath
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function findPath(grid: Grid): Move[] | null {
if (!grid || !grid.length) return null;
const hintTable: string[][] = [];
const path: Move[] = [];
Function trimLongMessage
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export function trimLongMessage(message: string, maxLength: number): string {
if (!message) return '';
const words = message.split(' ');
let result = '';
- 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 tripleStep
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export function tripleStep(stepsCount: number): number {
if (stepsCount <= 0) throw new Error(`${stepsCount} of steps is not a real stair!`);
else if (stepsCount === 1) return 1;
else if (stepsCount === 2) return 2;
else if (stepsCount === 3) return 4;
- 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 graphsEqual
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export function graphsEqual(graph1: IUndirectedGraph, graph2: IUndirectedGraph): boolean {
if (!graph1 || !graph2) throw new Error(`Compared graphs can not be null/undefined`);
if (graph1.nodes.length !== graph2.nodes.length) return false;
const someNodeMissing = graph1.nodes.some(node => graph2.nodes.indexOf(node) < 0);
- 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 magicIndex
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export function magicIndex(
array: number[],
lowIndex: number = 0,
highIndex = array.length - 1,
): number | null {
- 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 twoSum
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
var twoSum = function(nums: number[], target: number): number[] {
const valuesAndIndices = nums.reduce((subResult, value, index) => {
const indices = subResult[value];
indices ? indices.push(index) : subResult[value] = [index];
return subResult;
- 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 isTopSort
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export function isTopSort(
orderedNodes: string[],
graph: IDirectedGraph,
): boolean {
if (graph.nodes.length !== (orderedNodes || []).length) return false;
- 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 numberOfWaysToJumpToNthStep
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export const numberOfWaysToJumpToNthStep = (n) => {
if (n < 0) throw new Error(`Cmon, you cant jump onto a negative step; but I'd be able to provide a math to that problem if necessary!`);
if (memo.has(n)) return memo.get(n);
- 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 romanToInt
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
export const romanToInt = function(roman: string): number {
if (!roman || !roman.length) throw new Error(`${roman} is not a Roman number.`);
const queue = roman.toUpperCase().split('');
let result = 0;
- 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 null;
Avoid too many return
statements within this function. Open
else return magicIndex(array, lowIndex, index - 1);
Avoid too many return
statements within this function. Open
return true;
Function pathExists
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export function pathExists(graph: Graph, source: string, destination: string): boolean {
const visited = new Set<string>();
const toVisit = [ source ];
while (toVisit.length) {
const currentNode = toVisit.shift();
- 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 splitIntoGroups
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export function splitIntoGroups(bitSequence: string): { g: string, c: number }[] {
const groups: { g: string, c: number }[] = [];
let index = 0;
let group = bitSequence[index];
let groupLen = 1;
- 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 pathExists
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export function pathExists(source: string, destination: string, graph: IDirectedGraph): boolean {
const toVisit = [source];
const visited = new Set<string | undefined>([]);
while (toVisit.length) {
- 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 twoSumBruteForce
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
var twoSumBruteForce = function(nums: number[], target: number): number[] {
for (let left = 0; left < nums.length - 1; left++)
for (let right = left + 1; right < nums.length; right++)
if (nums[left] + nums[right] === target)
return [left, right];
- 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"