FezVrasta/popper.js

View on GitHub

Showing 205 of 319 total issues

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

export function useClientPoint(
  context: FloatingRootContext,
  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 Floating has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

export function Floating({
  children,
  content,
  strategy: strategyOption,
  tooltipStyle = {},
Severity: Minor
Found in website/lib/components/Floating.js - 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 computePosition has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const computePosition: ComputePosition = async (
  reference,
  floating,
  config,
) => {
Severity: Major
Found in packages/core/src/computePosition.ts - About 2 hrs to fix

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

    function getBoundingClientRect() {
      // There are two rects and they are disjoined.
      if (
        clientRects.length === 2 &&
        clientRects[0].left > clientRects[1].right &&
Severity: Major
Found in packages/core/src/middleware/inline.ts - About 2 hrs to fix

Function detectOverflow has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export async function detectOverflow(
  state: MiddlewareState,
  options: DetectOverflowOptions | Derivable<DetectOverflowOptions> = {},
): Promise<SideObject> {
  const {x, y, platform, rects, elements, strategy} = state;
Severity: Major
Found in packages/core/src/detectOverflow.ts - About 2 hrs to fix

Function fn has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async fn(state) {
    const {x, y, placement, rects, platform, elements, middlewareData} = state;
    // Since `element` is required, we don't Partial<> the type.
    const {element, padding = 0} = evaluate(options, state) || {};

Severity: Major
Found in packages/core/src/middleware/arrow.ts - About 2 hrs to fix

Function observeMove has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function observeMove(element: Element, onMove: () => void) {
  let io: IntersectionObserver | null = null;
  let timeoutId: NodeJS.Timeout;

  const root = getDocumentElement(element);
Severity: Major
Found in packages/dom/src/autoUpdate.ts - About 2 hrs to fix

File Popover.js has 257 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
  arrow,
  autoUpdate,
  flip,
  FloatingArrow,
Severity: Minor
Found in website/lib/components/Popover.js - About 2 hrs to fix

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

function createVirtualElement(
  domElement: Element | null | undefined,
  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 useFloatingRootContext has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function useFloatingRootContext(
  options: UseFloatingRootContextOptions,
): FloatingRootContext {
  const {
    open = false,
Severity: Major
Found in packages/react/src/hooks/useFloatingRootContext.ts - About 2 hrs to fix

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

export const SomethingWentWrong = (props: SomethingWentWrongProps) => {
  const [currentSerializedData] = useSerializedData();
  const {inspectDocument: resetInspection} = useDevtools();

  const handleReload = React.useCallback(
Severity: Major
Found in extension/src/components/SomethingWentWrong.tsx - About 2 hrs to fix

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

export function getBoundingClientRect(
  element: Element | VirtualElement,
  includeScale = false,
  isFixedStrategy = false,
  offsetParent?: Element | Window,
Severity: Major
Found in packages/dom/src/utils/getBoundingClientRect.ts - About 2 hrs to fix

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

export function useFloating<RT extends ReferenceType = ReferenceType>(
  options: UseFloatingOptions = {},
): UseFloatingReturn<RT> {
  const {
    placement = 'bottom',
Severity: Minor
Found in packages/react-dom/src/useFloating.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 createController has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

export const createController = (defaultView: Window): Controller => {
  let selectedElement: HTMLElementWithMetadata | null = null;
  const observer = new MutationObserver((mutations) => {
    if (!selectedElement) {
      return;
Severity: Minor
Found in packages/devtools/src/controller.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 FloatingFocusManager has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

export function FloatingFocusManager(
  props: FloatingFocusManagerProps,
): JSX.Element {
  const {
    context,
Severity: Minor
Found in packages/react/src/components/FloatingFocusManager.tsx - 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 Shift has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function Shift() {
  const [boundary, setBoundary] = useState();

  useEffect(() => {
    if (boundary) {
Severity: Major
Found in website/lib/components/Home/PositioningDemos.js - About 2 hrs to fix

Function Result12 has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const Result12 = () => {
  const [arrowEl, setArrowEl] = useState(null);

  const {
    refs,
Severity: Major
Found in website/lib/components/Tutorial.js - About 2 hrs to fix

Function DialogContent has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function DialogContent(props, propRef) {
    const {context: floatingContext, ...context} =
      useDialogContext();
    const ref = useMergeRefs([
      context.refs.setFloating,
Severity: Minor
Found in website/lib/components/Dialog.js - About 2 hrs to fix

Function handleFocusOutside has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function handleFocusOutside(event: FocusEvent) {
      const relatedTarget = event.relatedTarget as Element | null;

      queueMicrotask(() => {
        const movedToUnrelatedNode = !(
Severity: Minor
Found in packages/react/src/components/FloatingFocusManager.tsx - About 2 hrs to fix

Function getBoundingClientRect has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

export function getBoundingClientRect(
  element: Element | VirtualElement,
  includeScale = false,
  isFixedStrategy = false,
  offsetParent?: Element | Window,
Severity: Minor
Found in packages/dom/src/utils/getBoundingClientRect.ts - 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

Severity
Category
Status
Source
Language