File reorder-delta-builder.ts
has 259 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { debugLog } from 'core-app/shared/helpers/debug_output';
import { QueryOrder } from 'core-app/core/apiv3/endpoints/queries/apiv3-query-order';
// min allowed position
export const MIN_ORDER = -2147483647;
Function buildInsertPosition
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
function buildInsertPosition(
order:string[],
positions:QueryOrder,
wpId:string,
index:number,
Function isAscendingOrder
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function isAscendingOrder(
order:string[],
positions:QueryOrder,
index:number,
):boolean {
- 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 positionSwap
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
delta:QueryOrder,
order:string[],
positions:QueryOrder,
index:number,
fromIndex:number|null,
Function buildInsertPosition
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function buildInsertPosition(
order:string[],
positions:QueryOrder,
wpId:string,
index:number,
- 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 buildDelta
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
order:string[],
positions:QueryOrder,
wpId:string,
index:number,
fromIndex:number|null,
Function insertAsFirst
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
delta:QueryOrder,
order:string[],
positions:QueryOrder,
index:number,
wpId:string,
Function buildInsertPosition
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
order:string[],
positions:QueryOrder,
wpId:string,
index:number,
fromIndex:number|null,
Avoid too many return
statements within this function. Open
return {
...rebuiltDelta,
[wpId]: predecessorPosition + distance,
};
Avoid too many return
statements within this function. Open
return {
...rebuiltDelta,
[wpId]: predecessorPosition + (ORDER_DISTANCE / 2),
};
Avoid too many return
statements within this function. Open
return reorderedInsert(rebuiltDelta, order, positions);
Avoid too many return
statements within this function. Open
return reorderedInsert(rebuiltDelta, order, positions);
Function redistribute
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function redistribute(
delta:QueryOrder,
order:string[],
minIndex:number,
maxIndex:number,
- 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"