Showing 163 of 163 total issues
Function set
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function set(arg) {
const { interaction, state, coords } = arg
const { options, offsets } = state
const relative = {
x: coords.x - offsets[0].x,
Function set
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function set(arg: ModifierArg<RestrictSizeState>) {
const { interaction, state, rect, edges } = arg
const { options } = state
if (!edges) {
Function setPerAction
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
setPerAction(actionName: ActionName, options: OrBoolean<Options>) {
const defaults = this._defaults
// for all the default per-action options
for (const optionName_ in options) {
Function set
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
set(arg) {
const { state, rect, coords } = arg
const { linkedEdges } = state
const initialCoords = extend({}, coords)
const aspectMethod = state.equalDelta ? setEqualDelta : setRatio
Function transformImportsToAbsolute
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function transformImportsToAbsolute() {
const fixImportSource = ({ node: { source } }, { opts, filename }) => {
if (!source || (opts.ignore && opts.ignore(filename, source.value))) return
const { moduleDirectory = getModuleDirectories() } = opts
Function setAndApply
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
setAndApply(
arg: Partial<DoAnyPhaseArg> & {
phase: EventPhase
preEnd?: boolean
skipModifiers?: number
Function pointerExtend
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export default function pointerExtend<T>(dest: Partial<T & { __set?: Partial<T> }>, source: T) {
dest.__set ||= {} as any
for (const prop in source) {
// skip deprecated prefixed properties
- 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 transformImportsToAbsolute
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function transformImportsToAbsolute() {
const fixImportSource = ({ node: { source } }, { opts, filename }) => {
if (!source || (opts.ignore && opts.ignore(filename, source.value))) return
const { moduleDirectory = getModuleDirectories() } = opts
- 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 new
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
new(target: Target, options?: any): Interactable {
options = extend(options || {}, {
actions: this.scope.actions,
})
const interactable = new this.scope.Interactable(target, options, this.scope.document, this.scope.events)
Function initCursors
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function initCursors(browser: typeof import('@interactjs/utils/browser').default) {
return browser.isIe9
? {
x: 'e-resize',
y: 's-resize',
Function removeDelegate
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function removeDelegate(
selector: string,
context: Document | Element,
type: string,
listener?: ListenerEntry['func'],
Function getActionInfo
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getActionInfo(
interaction: Interaction,
pointer: PointerType,
event: PointerEventType,
eventTarget: Node,
Function mouseOrPen
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
mouseOrPen({ pointerId, pointerType, eventType, scope }: SearchDetails) {
if (pointerType !== 'mouse' && pointerType !== 'pen') {
return null
}
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
Function reject
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
reject() {
const { dropState } = this._interaction
if (
this.type !== 'dropactivate' &&
Function start
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function start(arg: ModifierArg<SnapState>) {
const { state, edges } = arg
const { options } = state
if (!edges) {
Function on
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
interact.on = warnOnce(function on(type: string | EventTypes, listener: ListenersArg, options?: object) {
if (is.string(type) && type.search(' ') !== -1) {
type = type.trim().split(/ +/)
}
Consider simplifying this complex logical expression. Open
if (rect && !('left' in rect && 'top' in rect)) {
rect = extend({}, rect)
rect.left = rect.x || 0
rect.top = rect.y || 0
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 idle
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
idle({ pointerType, scope }: SearchDetails) {
for (const interaction of scope.interactions.list) {
// if there's already a pointer held down
if (interaction.pointers.length === 1) {
const target = interaction.interactable
- 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"