bokuweb/react-resizable-box

View on GitHub

Showing 59 of 59 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      if (typeof this.props.size.width !== 'undefined' && this.props.size.width !== this.state.width) {
        this.setState({ width: this.props.size.width });
      }
Severity: Major
Found in src/index.tsx and 1 other location - About 2 hrs to fix
src/index.tsx on lines 704..706

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 82.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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;
Severity: Major
Found in src/index.tsx - About 2 hrs to fix

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

        if (hasDirection('bottom', direction)) {
          newHeight = original.height + ((clientY - original.y) * resizeRatioY) / scale;
          if (lockAspectRatio) {
            newWidth = (newHeight - extraHeight) * this.ratio + extraWidth;
          }
    Severity: Major
    Found in src/index.tsx and 3 other locations - About 1 hr to fix
    src/index.tsx on lines 594..599
    src/index.tsx on lines 600..605
    src/index.tsx on lines 612..617

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 73.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

        if (hasDirection('right', direction)) {
          newWidth = original.width + ((clientX - original.x) * resizeRatioX) / scale;
          if (lockAspectRatio) {
            newHeight = (newWidth - extraWidth) / this.ratio + extraHeight;
          }
    Severity: Major
    Found in src/index.tsx and 3 other locations - About 1 hr to fix
    src/index.tsx on lines 600..605
    src/index.tsx on lines 606..611
    src/index.tsx on lines 612..617

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 73.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

        if (hasDirection('top', direction)) {
          newHeight = original.height - ((clientY - original.y) * resizeRatioY) / scale;
          if (lockAspectRatio) {
            newWidth = (newHeight - extraHeight) * this.ratio + extraWidth;
          }
    Severity: Major
    Found in src/index.tsx and 3 other locations - About 1 hr to fix
    src/index.tsx on lines 594..599
    src/index.tsx on lines 600..605
    src/index.tsx on lines 606..611

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 73.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

        if (hasDirection('left', direction)) {
          newWidth = original.width - ((clientX - original.x) * resizeRatioX) / scale;
          if (lockAspectRatio) {
            newHeight = (newWidth - extraWidth) / this.ratio + extraHeight;
          }
    Severity: Major
    Found in src/index.tsx and 3 other locations - About 1 hr to fix
    src/index.tsx on lines 594..599
    src/index.tsx on lines 606..611
    src/index.tsx on lines 612..617

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 73.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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;
    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 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;
          }
    Severity: Minor
    Found in src/index.tsx - About 1 hr to fix

      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);
      Severity: Minor
      Found in src/index.tsx - About 1 hr to fix

        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;
        Severity: Minor
        Found in src/index.tsx - About 1 hr to fix

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

              <div style={{ display: 'flex' }}>
                <Resizable style={{ ...style, flexBasis: '100px' }}>001</Resizable>
                <Resizable style={{ ...style, flexBasis: '100px' }}>002</Resizable>
              </div>
          Severity: Major
          Found in stories/flex.stories.tsx and 1 other location - About 1 hr to fix
          stories/flex.stories.tsx on lines 20..23

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 60.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          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';
          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

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

              <div style={{ display: 'flex', flexDirection: 'column' }}>
                <Resizable style={{ ...style, flexBasis: '100px' }}>001</Resizable>
                <Resizable style={{ ...style, flexBasis: '100px' }}>002</Resizable>
              </div>
          Severity: Major
          Found in stories/flex.stories.tsx and 1 other location - About 1 hr to fix
          stories/flex.stories.tsx on lines 14..17

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 60.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          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',
          Severity: Minor
          Found in src/index.tsx - About 1 hr to fix

            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 };
                  }
            Severity: Minor
            Found in src/index.tsx - About 1 hr to fix

              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,
              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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  const height =
                    size && typeof size.height !== 'undefined' && !this.state.isResizing
                      ? getStringSize(size.height)
                      : getSize('height');
              Severity: Minor
              Found in src/index.tsx and 1 other location - About 55 mins to fix
              src/index.tsx on lines 348..351

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 53.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                    boundHeight = heightByDirection
                      ? this.resizableBottom - this.targetTop
                      : this.props.bounds.offsetHeight + (this.targetTop - this.resizableTop);
              Severity: Minor
              Found in src/index.tsx and 1 other location - About 55 mins to fix
              src/index.tsx on lines 569..571

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 53.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  const width =
                    size && typeof size.width !== 'undefined' && !this.state.isResizing
                      ? getStringSize(size.width)
                      : getSize('width');
              Severity: Minor
              Found in src/index.tsx and 1 other location - About 55 mins to fix
              src/index.tsx on lines 352..355

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 53.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                    boundWidth = widthByDirection
                      ? this.resizableRight - this.targetLeft
                      : this.props.bounds.offsetWidth + (this.targetLeft - this.resizableLeft);
              Severity: Minor
              Found in src/index.tsx and 1 other location - About 55 mins to fix
              src/index.tsx on lines 572..574

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 53.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Severity
              Category
              Status
              Source
              Language