bokuweb/react-rnd

View on GitHub

Showing 21 of 86 total issues

File index.test.tsx has 745 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* tslint:disable */

import test from "ava";
import * as React from "react";
import { spy } from "sinon";
Severity: Major
Found in src/index.test.tsx - About 1 day to fix

    File index.tsx has 629 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import * as React from "react";
    import { DraggableEventHandler, default as DraggableRoot } from "react-draggable";
    import { Enable, Resizable, ResizeDirection } from "re-resizable";
    
    // FIXME: https://github.com/mzabriskie/react-draggable/issues/381
    Severity: Major
    Found in src/index.tsx - About 1 day to fix

      Function onResizeStart has a Cognitive Complexity of 69 (exceeds 5 allowed). Consider refactoring.
      Open

        onResizeStart(
          e: React.MouseEvent<HTMLElement> | React.TouchEvent<HTMLElement>,
          dir: ResizeDirection,
          elementRef: HTMLElement,
        ) {
      Severity: Minor
      Found in src/index.tsx - About 1 day to fix

      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 98 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        render() {
          const {
            disableDragging,
            style,
            dragHandleClassName,
      Severity: Major
      Found in src/index.tsx - About 3 hrs to fix

        Function onResizeStart has 89 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          onResizeStart(
            e: React.MouseEvent<HTMLElement> | React.TouchEvent<HTMLElement>,
            dir: ResizeDirection,
            elementRef: HTMLElement,
          ) {
        Severity: Major
        Found in src/index.tsx - About 3 hrs to fix

          Function onDragStart has 58 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            onDragStart(e: RndDragEvent, data: DraggableData) {
              if (this.props.onDragStart) {
                this.props.onDragStart(e, data);
              }
              const pos = this.getDraggablePosition();
          Severity: Major
          Found in src/index.tsx - About 2 hrs to fix

            Rnd has 21 functions (exceeds 20 allowed). Consider refactoring.
            Open

            export class Rnd extends React.PureComponent<Props, State> {
              public static defaultProps: DefaultProps = {
                maxWidth: Number.MAX_SAFE_INTEGER,
                maxHeight: Number.MAX_SAFE_INTEGER,
                scale: 1,
            Severity: Minor
            Found in src/index.tsx - About 2 hrs to fix

              Function render has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                render() {
                  return (
                    <div
                      style={{
                        width: "100%",
              Severity: Minor
              Found in stories/sandbox/issue-#622.tsx - About 1 hr to fix

                Function render has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  render() {
                    return (
                      <>
                        {[0, 1, 2].map((i) => (
                          <Rnd
                Severity: Minor
                Found in stories/basic/multi-controlled.tsx - About 1 hr to fix

                  Function onDragStart has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                    onDragStart(e: RndDragEvent, data: DraggableData) {
                      if (this.props.onDragStart) {
                        this.props.onDragStart(e, data);
                      }
                      const pos = this.getDraggablePosition();
                  Severity: Minor
                  Found in src/index.tsx - About 1 hr to fix

                  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 Example has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const Example: React.FC = () => {
                    const [state, setState] = React.useState<State>({
                      width: 200,
                      height: 200,
                      x: 0,
                  Severity: Minor
                  Found in stories/bounds/element-controlled.tsx - About 1 hr to fix

                    Function render has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      render() {
                        return (
                          <div>
                            <div style={{ marginLeft: "30px" }}>
                              <Rnd
                    Severity: Minor
                    Found in stories/bounds/window-controlled.tsx - About 1 hr to fix

                      Function render has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        render() {
                          return (
                            <div className="boundary" style={{ ...selectorBoundary, transform: "scale(0.6)" }}>
                              <div style={parentBoundary}>
                                <Rnd
                      Severity: Minor
                      Found in stories/scale/selector-controlled.tsx - About 1 hr to fix

                        Function render has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          render() {
                            return (
                              <div className="boundary" style={selectorBoundary}>
                                <div style={parentBoundary}>
                                  <Rnd
                        Severity: Minor
                        Found in stories/bounds/selector-controlled.tsx - About 1 hr to fix

                          Function render has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            render() {
                              return (
                                <div style={parentBoundary}>
                                  <Rnd
                                    style={style}
                          Severity: Minor
                          Found in stories/bounds/body-controlled.tsx - About 1 hr to fix

                            Function render has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              render() {
                                return (
                                  <div style={parentBoundary}>
                                    <Rnd
                                      style={style}
                            Severity: Minor
                            Found in stories/bounds/parent-controlled.tsx - About 1 hr to fix

                              Function render has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                                render() {
                                  const {
                                    disableDragging,
                                    style,
                                    dragHandleClassName,
                              Severity: Minor
                              Found in src/index.tsx - About 1 hr to fix

                              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 onResize has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                onResize(
                                  e: MouseEvent | TouchEvent,
                                  direction: ResizeDirection,
                                  elementRef: HTMLElement,
                                  delta: { height: number; width: number },
                              Severity: Minor
                              Found in src/index.tsx - About 1 hr to fix

                                Function onResize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  onResize(
                                    e: MouseEvent | TouchEvent,
                                    direction: ResizeDirection,
                                    elementRef: HTMLElement,
                                    delta: { height: number; width: number },
                                Severity: Minor
                                Found in src/index.tsx - About 45 mins to fix

                                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

                                    if (!this.resizable) return;
                                Severity: Major
                                Found in src/index.tsx - About 30 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language