dekk-app/react-mops

View on GitHub

Showing 3,908 of 3,908 total issues

Function Guides has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

> = React.forwardRef(({...props}, ref: React.Ref<HTMLDivElement>) => {
    const sizeRef = React.useRef<HTMLDivElement>();

    const [height, setHeight] = React.useState(0);
    const [width, setWidth] = React.useState(0);
Severity: Major
Found in packages/react-mops/src/guides/guides.tsx - About 2 hrs to fix

    Function useHandlesDown has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    export const useHandlesDown = ({
        currentRotation,
        initialPosition,
        initialSize,
        // limitLeft,
    Severity: Minor
    Found in packages/react-mops/src/hooks/with-handle-hooks.ts - About 2 hrs 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 4 locations. Consider refactoring.
    Open

        React.useEffect(() => {
            document.addEventListener("mouseleave", handleMouseUp);
            document.addEventListener("mouseup", handleMouseUp);
            return () => {
                document.removeEventListener("mouseleave", handleMouseUp);
    Severity: Major
    Found in packages/react-mops/src/hooks/mouse-event-hooks.ts and 3 other locations - About 2 hrs to fix
    packages/react-mops/src/hooks/mouse-event-hooks.ts on lines 122..129
    packages/react-mops/src/hooks/mouse-event-hooks.ts on lines 131..138
    packages/react-mops/src/hooks/use-hooks.ts on lines 58..65

    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 75.

    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

        React.useEffect(() => {
            window.addEventListener("focus", handleFocus);
            window.addEventListener("blur", handleFocus);
            return () => {
                document.removeEventListener("focus", handleFocus);
    Severity: Major
    Found in packages/react-mops/src/hooks/mouse-event-hooks.ts and 3 other locations - About 2 hrs to fix
    packages/react-mops/src/hooks/mouse-event-hooks.ts on lines 58..65
    packages/react-mops/src/hooks/mouse-event-hooks.ts on lines 131..138
    packages/react-mops/src/hooks/use-hooks.ts on lines 58..65

    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 75.

    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

        React.useEffect(() => {
            window.addEventListener("focus", handleFocus);
            window.addEventListener("blur", handleFocus);
            return () => {
                window.removeEventListener("focus", handleFocus);
    Severity: Major
    Found in packages/react-mops/src/hooks/use-hooks.ts and 3 other locations - About 2 hrs to fix
    packages/react-mops/src/hooks/mouse-event-hooks.ts on lines 58..65
    packages/react-mops/src/hooks/mouse-event-hooks.ts on lines 122..129
    packages/react-mops/src/hooks/mouse-event-hooks.ts on lines 131..138

    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 75.

    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

        React.useEffect(() => {
            document.addEventListener("mouseleave", handleMouseUp);
            document.addEventListener("mouseup", handleMouseUp);
            return () => {
                document.removeEventListener("mouseleave", handleMouseUp);
    Severity: Major
    Found in packages/react-mops/src/hooks/mouse-event-hooks.ts and 3 other locations - About 2 hrs to fix
    packages/react-mops/src/hooks/mouse-event-hooks.ts on lines 58..65
    packages/react-mops/src/hooks/mouse-event-hooks.ts on lines 122..129
    packages/react-mops/src/hooks/use-hooks.ts on lines 58..65

    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 75.

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

    export const useMeta = () => {
        const [metaKey, setMetaKey] = React.useState(false);
        const key = isOSX() ? "Meta" : "Control";
        const handleKeyDown = React.useCallback(
            (e: KeyboardEvent) => {
    Severity: Minor
    Found in packages/react-mops/src/hooks/use-hooks.ts - About 1 hr to fix

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

          {
              setInitialPosition,
              setInitialSize,
              setPosition,
              setSize,
      Severity: Major
      Found in packages/react-mops/src/hooks/with-handle-hooks.ts and 1 other location - About 1 hr to fix
      packages/react-mops/src/box.tsx on lines 103..117

      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 66.

      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 withHandle = useWithHandle({
                  contentRef,
                  currentPosition,
                  currentRotation,
                  initialPosition,
      Severity: Major
      Found in packages/react-mops/src/box.tsx and 1 other location - About 1 hr to fix
      packages/react-mops/src/hooks/with-handle-hooks.ts on lines 6..20

      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 66.

      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

      export const useHandlers = ({
          currentPosition,
          currentRotation,
          currentSize,
          onDrag,
      Severity: Major
      Found in packages/react-mops/src/hooks/use-hooks.ts and 1 other location - About 1 hr to fix
      packages/react-mops/src/box.tsx on lines 89..102

      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 61.

      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

              } = useHandlers({
                  currentPosition,
                  currentRotation,
                  currentSize,
                  onDrag,
      Severity: Major
      Found in packages/react-mops/src/box.tsx and 1 other location - About 1 hr to fix
      packages/react-mops/src/hooks/use-hooks.ts on lines 115..128

      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 61.

      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 GuidesProvider has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      }> = ({children, guideRequests, containerSize}) => {
          const [guides, setGuides] = React.useState<Mops.Guide[]>([]);
          const addGuides = guideModels => {
              setGuides(state => {
                  const newGuides = guideModels.filter(
      Severity: Minor
      Found in packages/react-mops/src/guides/guides.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 handleMouse = useHandleMouse({
                  addGuides,
                  currentRotation,
                  currentSize,
                  guideRequests,
      Severity: Major
      Found in packages/react-mops/src/box.tsx and 1 other location - About 1 hr to fix
      packages/react-mops/src/hooks/mouse-event-hooks.ts on lines 194..206

      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 56.

      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

      export const useHandleMouse = ({
          addGuides,
          currentRotation,
          currentSize,
          initialPosition,
      Severity: Major
      Found in packages/react-mops/src/hooks/mouse-event-hooks.ts and 1 other location - About 1 hr to fix
      packages/react-mops/src/box.tsx on lines 182..194

      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 56.

      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 useMouseMove has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      export const useMouseMove = (
          onMouseUp: Mops.MouseHandler,
          onMouseMove: Mops.MouseHandler,
          scale: number,
          rotation?: Mops.RotationModel
      Severity: Minor
      Found in packages/react-mops/src/hooks/mouse-event-hooks.ts - About 55 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

      Function getOS has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      const getOS = () => {
          if ("navigator" in global) {
              if (navigator.appVersion.indexOf("Win") !== -1) {
                  return WINDOWS;
              }
      Severity: Minor
      Found in packages/react-mops/src/hooks/use-hooks.ts - About 55 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

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

                  x: inRange(model.x, item.position.x - 10, item.position.x + 10)
                      ? item.position.x
                      : undefined,
      Severity: Minor
      Found in packages/react-mops/src/guides/snapping.ts and 1 other location - About 55 mins to fix
      packages/react-mops/src/guides/snapping.ts on lines 114..116

      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

                  y: inRange(model.y, item.position.y - 10, item.position.y + 10)
                      ? item.position.y
                      : undefined
      Severity: Minor
      Found in packages/react-mops/src/guides/snapping.ts and 1 other location - About 55 mins to fix
      packages/react-mops/src/guides/snapping.ts on lines 111..113

      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

                          y: {
                              uuid: hasY && smallerY ? uuid : previousValue.y.uuid,
                              value: hasY && smallerY ? y : previousValue.y.value
                          }
      Severity: Minor
      Found in packages/react-mops/src/guides/snapping.ts and 1 other location - About 50 mins to fix
      packages/react-mops/src/guides/snapping.ts on lines 153..156

      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 52.

      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 handleKeyUp = React.useCallback(
              (e: KeyboardEvent) => {
                  if (e.key === key) {
                      setMetaKey(false);
                  }
      Severity: Minor
      Found in packages/react-mops/src/hooks/use-hooks.ts and 1 other location - About 50 mins to fix
      packages/react-mops/src/hooks/use-hooks.ts on lines 36..43

      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 52.

      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