FezVrasta/popper.js

View on GitHub

Showing 329 of 329 total issues

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

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

                <Tooltip>
                  <TooltipTrigger asChild>
                    <Button
                      aria-label="Share"
                      className="rounded-full p-3 hover:text-blue-500 dark:hover:text-blue-300"
Severity: Major
Found in website/pages/index.js and 3 other locations - About 2 hrs to fix
website/pages/index.js on lines 314..324
website/pages/index.js on lines 336..346
website/pages/index.js on lines 347..357

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

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

                <Tooltip>
                  <TooltipTrigger asChild>
                    <Button
                      aria-label="Edit"
                      className="rounded-full p-3 hover:text-green-500 dark:hover:text-green-300"
Severity: Major
Found in website/pages/index.js and 3 other locations - About 2 hrs to fix
website/pages/index.js on lines 314..324
website/pages/index.js on lines 325..335
website/pages/index.js on lines 336..346

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

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

                <Tooltip>
                  <TooltipTrigger asChild>
                    <Button
                      aria-label="Stats"
                      className="rounded-full p-3 hover:text-orange-500 dark:hover:text-orange-300"
Severity: Major
Found in website/pages/index.js and 3 other locations - About 2 hrs to fix
website/pages/index.js on lines 314..324
website/pages/index.js on lines 325..335
website/pages/index.js on lines 347..357

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

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

                <Tooltip>
                  <TooltipTrigger asChild>
                    <Button
                      aria-label="Like"
                      className="rounded-full p-3 hover:text-red-500 dark:hover:text-red-300"
Severity: Major
Found in website/pages/index.js and 3 other locations - About 2 hrs to fix
website/pages/index.js on lines 325..335
website/pages/index.js on lines 336..346
website/pages/index.js on lines 347..357

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

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

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

File Composite.tsx has 257 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import * as React from 'react';

import {useMergeRefs} from '../hooks/useMergeRefs';
import {useEffectEvent} from '../hooks/utils/useEffectEvent';
import type {Dimensions} from '../types';
Severity: Minor
Found in packages/react/src/components/Composite.tsx - 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 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 useDelayGroup has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function useDelayGroup(
  context: FloatingRootContext,
  options: UseGroupOptions = {},
): GroupContext {
  const {open, onOpenChange, floatingId} = context;
Severity: Major
Found in packages/react/src/components/FloatingDelayGroup.tsx - 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 mergeProps has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function mergeProps<Key extends keyof ElementProps>(
  userProps: (React.HTMLProps<Element> & ExtendedUserProps) | undefined,
  propsList: Array<ElementProps | void>,
  elementKey: Key,
): Record<string, unknown> {
Severity: Minor
Found in packages/react/src/hooks/useInteractions.ts - About 2 hrs to fix
Severity
Category
Status
Source
Language