FezVrasta/popper.js

View on GitHub

Showing 208 of 322 total issues

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

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

  async fn(state) {
    const {
      placement,
      middlewareData,
      rects,
Severity: Major
Found in packages/core/src/middleware/flip.ts - About 4 hrs to fix

File safePolygon.ts has 354 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {contains, getTarget} from '@floating-ui/react/utils';
import {isElement} from '@floating-ui/utils/dom';
import type {Rect, Side} from './types';
import type {HandleCloseFn} from './hooks/useHover';
import {getChildren} from './utils/getChildren';
Severity: Minor
Found in packages/react/src/safePolygon.ts - About 4 hrs to fix

Function useClick has 112 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function useClick(
  context: FloatingRootContext,
  props: UseClickProps = {},
): ElementProps {
  const {
Severity: Major
Found in packages/react/src/hooks/useClick.ts - About 4 hrs to fix

Function FloatingArrow has 112 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const FloatingArrow = React.forwardRef(function FloatingArrow(
  props: FloatingArrowProps,
  ref: React.ForwardedRef<SVGSVGElement>,
): React.JSX.Element | null {
  const {
Severity: Major
Found in packages/react/src/components/FloatingArrow.tsx - About 4 hrs to fix

Function inline has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

export const inline = (
  options: InlineOptions | Derivable<InlineOptions> = {},
): Middleware => ({
  name: 'inline',
  options,
Severity: Minor
Found in packages/core/src/middleware/inline.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 110 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function useClientPoint(
  context: FloatingRootContext,
  props: UseClientPointProps = {},
): ElementProps {
  const {
Severity: Major
Found in packages/react/src/hooks/useClientPoint.ts - About 4 hrs to fix

Function useFloating has 109 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function useFloating<T extends ReferenceElement = ReferenceElement>(
  reference: Readonly<Ref<MaybeElement<T>>>,
  floating: Readonly<Ref<MaybeElement<FloatingElement>>>,
  options: UseFloatingOptions<T> = {},
): UseFloatingReturn {
Severity: Major
Found in packages/vue/src/useFloating.ts - About 4 hrs to fix

File Tutorial.js has 345 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
  arrow,
  flip,
  offset,
  shift,
Severity: Minor
Found in website/lib/components/Tutorial.js - About 4 hrs to fix

File useDismiss.ts has 340 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
  contains,
  getDocument,
  getTarget,
  isEventTargetWithin,
Severity: Minor
Found in packages/react/src/hooks/useDismiss.ts - About 4 hrs to fix

Function useFocus has 104 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function useFocus(
  context: FloatingRootContext,
  props: UseFocusProps = {},
): ElementProps {
  const {open, onOpenChange, events, dataRef, elements} = context;
Severity: Major
Found in packages/react/src/hooks/useFocus.ts - About 4 hrs to fix

Function useFloating has 104 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function useFloating<RT extends ReferenceType = ReferenceType>(
  options: UseFloatingOptions = {},
): UseFloatingReturn<RT> {
  const {nodeId} = options;

Severity: Major
Found in packages/react/src/hooks/useFloating.ts - About 4 hrs to fix

Function FloatingArrow has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

export const FloatingArrow = React.forwardRef(function FloatingArrow(
  props: FloatingArrowProps,
  ref: React.ForwardedRef<SVGSVGElement>,
): React.JSX.Element | null {
  const {
Severity: Minor
Found in packages/react/src/components/FloatingArrow.tsx - 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 Virtual has 101 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function Virtual() {
  const [open, setOpen] = useState(false);
  const boundaryRef = useRef();
  const pointerTypeRef = useRef();
  const {x, y, refs, update} = useFloating({
Severity: Major
Found in website/lib/components/Home/PositioningDemos.js - About 4 hrs to fix

Function onKeyDown has 98 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      onKeyDown(event) {
        isPointerModalityRef.current = false;

        const isArrowKey = event.key.indexOf('Arrow') === 0;
        const isCrossOpenKey = isCrossOrientationOpenKey(
Severity: Major
Found in packages/react/src/hooks/useListNavigation.ts - About 3 hrs to fix

Function FloatingPortal has 98 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function FloatingPortal(props: FloatingPortalProps): React.JSX.Element {
  const {children, id, root = null, preserveTabOrder = true} = props;

  const portalNode = useFloatingPortalNode({id, root});
  const [focusManagerState, setFocusManagerState] =
Severity: Major
Found in packages/react/src/components/FloatingPortal.tsx - About 3 hrs to fix

Function FloatingUIMiddleware has 92 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const FloatingUIMiddleware = React.memo(function FloatingUIMiddleware() {
  const devtools = useDevtools();
  const serializedData = useSerializedData('FloatingUIMiddleware');
  const [index, setIndex] = React.useState(serializedData.length - 1);
  const handleIndexChange = React.useCallback(
Severity: Major
Found in extension/src/views/floating-ui/FloatingUIMiddleware.tsx - About 3 hrs to fix

File Combobox.js has 318 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
  autoUpdate,
  flip,
  FloatingFocusManager,
  FloatingPortal,
Severity: Minor
Found in website/lib/components/Home/Combobox.js - About 3 hrs to fix

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

  async fn(state) {
    const {placement, elements, rects, platform, strategy} = state;
    // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
    // ClientRect's bounds, despite the event listener being triggered. A
    // padding of 2 seems to handle this issue.
Severity: Major
Found in packages/core/src/middleware/inline.ts - About 3 hrs to fix

Function FluentUIMiddleware has 90 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const FluentUIMiddleware = React.memo(() => {
  const serializedData = useSerializedData('FluentUIMiddleware');
  const devtools = useDevtools();
  const styles = useStyles();
  const [index, setIndex] = React.useState(serializedData.length - 1);
Severity: Major
Found in extension/src/views/fluentui/components/FluentUIMiddleware.tsx - About 3 hrs to fix
Severity
Category
Status
Source
Language