File Modification.ts
has 337 lines of code (exceeds 250 allowed). Consider refactoring. Open
import type { EventPhase } from '@interactjs/core/InteractEvent'
import type { Interaction, DoAnyPhaseArg } from '@interactjs/core/Interaction'
import type { EdgeOptions, FullRect, Point, Rect } from '@interactjs/core/types'
import clone from '@interactjs/utils/clone'
import extend from '@interactjs/utils/extend'
Function setAll
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
setAll(arg: MethodArg & Partial<ModifierArg>): ModificationResult {
const { phase, preEnd, skipModifiers, rect: unmodifiedRect, edges: unmodifiedEdges } = arg
arg.coords = extend({}, arg.pageCoords)
arg.rect = extend({}, unmodifiedRect)
Consider simplifying this complex logical expression. Open
if (
// ignore disabled modifiers
!options ||
options.enabled === false ||
// check if we require endOnly option to fire move before end
Function setAndApply
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
setAndApply(
arg: Partial<DoAnyPhaseArg> & {
phase: EventPhase
preEnd?: boolean
skipModifiers?: number
Function applyToInteraction
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
applyToInteraction(arg: { phase: EventPhase; rect?: Rect }) {
const { interaction } = this
const { phase } = arg
const curCoords = interaction.coords.cur
const startCoords = interaction.coords.start
Consider simplifying this complex logical expression. Open
if (prevCoords && prevRect) {
const rectChanged =
newResult.rect.left !== prevRect.left ||
newResult.rect.right !== prevRect.right ||
newResult.rect.top !== prevRect.top ||
Function beforeEnd
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
beforeEnd(arg: Omit<DoAnyPhaseArg, 'iEvent'> & { state?: ModifierState }): void | false {
const { interaction, event } = arg
const states = this.states
if (!states || !states.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 setAll
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
setAll(arg: MethodArg & Partial<ModifierArg>): ModificationResult {
const { phase, preEnd, skipModifiers, rect: unmodifiedRect, edges: unmodifiedEdges } = arg
arg.coords = extend({}, arg.pageCoords)
arg.rect = extend({}, unmodifiedRect)
- 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 shouldDo
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
shouldDo(options, preEnd?: boolean, phase?: string, requireEndOnly?: boolean) {
if (
// ignore disabled modifiers
!options ||
options.enabled === 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"