FezVrasta/popper.js

View on GitHub
packages/react/src/hooks/useClientPoint.ts

Summary

Maintainability
D
1 day
Test Coverage

Function createVirtualElement has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

function createVirtualElement(
  domRef: React.MutableRefObject<Element | null>,
  data: {
    axis: 'x' | 'y' | 'both';
    dataRef: React.MutableRefObject<ContextData>;
Severity: Minor
Found in packages/react/src/hooks/useClientPoint.ts - About 4 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

Function useClientPoint has 99 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function useClientPoint<RT extends ReferenceType = ReferenceType>(
  context: FloatingContext<RT>,
  props: UseClientPointProps = {},
): ElementProps {
  const {
Severity: Major
Found in packages/react/src/hooks/useClientPoint.ts - About 3 hrs to fix

Function useClientPoint has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

export function useClientPoint<RT extends ReferenceType = ReferenceType>(
  context: FloatingContext<RT>,
  props: UseClientPointProps = {},
): ElementProps {
  const {
Severity: Minor
Found in packages/react/src/hooks/useClientPoint.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

Function createVirtualElement has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function createVirtualElement(
  domRef: React.MutableRefObject<Element | null>,
  data: {
    axis: 'x' | 'y' | 'both';
    dataRef: React.MutableRefObject<ContextData>;
Severity: Major
Found in packages/react/src/hooks/useClientPoint.ts - About 2 hrs to fix

Function getBoundingClientRect has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    getBoundingClientRect() {
      const domRect = domRef.current?.getBoundingClientRect() || {
        width: 0,
        height: 0,
        x: 0,
Severity: Minor
Found in packages/react/src/hooks/useClientPoint.ts - About 1 hr to fix

There are no issues that match your filters.

Category
Status