Showing 27 of 59 total issues
File index.tsx
has 868 lines of code (exceeds 250 allowed). Consider refactoring. Open
import * as React from 'react';
import { flushSync } from 'react-dom';
import { Resizer, Direction } from './resizer';
Function onMouseMove
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
onMouseMove(event: MouseEvent | TouchEvent) {
if (!this.state.isResizing || !this.resizable || !this.window) {
return;
}
if (this.window.TouchEvent && isTouchEvent(event)) {
- 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 calculateNewMaxFromBoundary
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
calculateNewMaxFromBoundary(maxWidth?: number, maxHeight?: number) {
const { boundsByDirection } = this.props;
const { direction } = this.state;
const widthByDirection = boundsByDirection && hasDirection('left', direction);
const heightByDirection = boundsByDirection && hasDirection('top', direction);
- 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 onMouseMove
has 104 lines of code (exceeds 25 allowed). Consider refactoring. Open
onMouseMove(event: MouseEvent | TouchEvent) {
if (!this.state.isResizing || !this.resizable || !this.window) {
return;
}
if (this.window.TouchEvent && isTouchEvent(event)) {
Function onResizeStart
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
onResizeStart(event: React.MouseEvent<HTMLElement> | React.TouchEvent<HTMLElement>, direction: Direction) {
if (!this.resizable || !this.window) {
return;
}
let clientX = 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
Resizable
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
export class Resizable extends React.PureComponent<ResizableProps, State> {
flexDir?: 'row' | 'column';
get parentNode(): HTMLElement | null {
if (!this.resizable) {
Function onResizeStart
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
onResizeStart(event: React.MouseEvent<HTMLElement> | React.TouchEvent<HTMLElement>, direction: Direction) {
if (!this.resizable || !this.window) {
return;
}
let clientX = 0;
Function calculateNewSizeFromDirection
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
calculateNewSizeFromDirection(clientX: number, clientY: number) {
const scale = this.props.scale || 1;
const [resizeRatioX, resizeRatioY] = normalizeToPair(this.props.resizeRatio || 1);
const { direction, original } = this.state;
const { lockAspectRatio, lockAspectRatioExtraHeight, lockAspectRatioExtraWidth } = this.props;
- 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 render
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const extendsProps = Object.keys(this.props).reduce((acc, key) => {
if (definedProps.indexOf(key) !== -1) {
return acc;
}
Function calculateNewMaxFromBoundary
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
calculateNewMaxFromBoundary(maxWidth?: number, maxHeight?: number) {
const { boundsByDirection } = this.props;
const { direction } = this.state;
const widthByDirection = boundsByDirection && hasDirection('left', direction);
const heightByDirection = boundsByDirection && hasDirection('top', direction);
Function calculateNewSizeFromDirection
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
calculateNewSizeFromDirection(clientX: number, clientY: number) {
const scale = this.props.scale || 1;
const [resizeRatioX, resizeRatioY] = normalizeToPair(this.props.resizeRatio || 1);
const { direction, original } = this.state;
const { lockAspectRatio, lockAspectRatioExtraHeight, lockAspectRatioExtraWidth } = this.props;
Function sizeStyle
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
get sizeStyle(): { width: string; height: string } {
const { size } = this.props;
const getSize = (key: 'width' | 'height'): string => {
if (typeof this.state[key] === 'undefined' || this.state[key] === 'auto') {
return 'auto';
- 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 constructor
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(props: ResizableProps) {
super(props);
this.state = {
isResizing: false,
width: this.propsSize?.width ?? 'auto',
Function getParentSize
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
getParentSize(): { width: number; height: number } {
if (!this.parentNode) {
if (!this.window) {
return { width: 0, height: 0 };
}
Function getPixelSize
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
const getPixelSize = (
size: undefined | string | number,
parentSize: number,
innerWidth: number,
innerHeight: 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 size
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
get size(): NumberSize {
let width = 0;
let height = 0;
if (this.resizable && this.window) {
const orgWidth = this.resizable.offsetWidth;
- 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 renderResizer
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
renderResizer() {
const { enable, handleStyles, handleClasses, handleWrapperStyle, handleWrapperClass, handleComponent } = this.props;
if (!enable) {
return 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 getStringSize
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
const getStringSize = (n: number | string): string => {
n = n.toString();
if (n === 'auto') {
return 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
Avoid too many return
statements within this function. Open
return n;
Avoid too many return
statements within this function. Open
return `${n}px`;