FezVrasta/popper.js

View on GitHub

Showing 205 of 319 total issues

Function Size has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function Size() {
  return (
    <GridItem
      title="Size"
      titleClass="text-green-500 dark:text-green-300"
Severity: Minor
Found in website/lib/components/Home/PositioningDemos.js - About 1 hr to fix

Function getElementRects has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  getElementRects({
    reference,
    floating,
  }: {
    reference: View | VirtualElement;
Severity: Minor
Found in packages/react-native/src/createPlatform.ts - About 1 hr to fix

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

  async fn(state) {
    const {rects} = state;

    const {strategy = 'referenceHidden', ...detectOverflowOptions} = evaluate(
      options,
Severity: Minor
Found in packages/core/src/middleware/hide.ts - About 1 hr to fix

Function convertOffsetParentRelativeRectToViewportRelativeRect has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

export function convertOffsetParentRelativeRectToViewportRelativeRect({
  elements,
  rect,
  offsetParent,
  strategy,

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

export function buildCellMap(
  sizes: Dimensions[],
  cols: number,
  dense: boolean,
) {
Severity: Minor
Found in packages/react/src/utils/composite.ts - About 1 hr to fix

Function getRectRelativeToOffsetParent has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function getRectRelativeToOffsetParent(
  element: Element | VirtualElement,
  offsetParent: Element | Window,
  strategy: Strategy,
): Rect {
Severity: Minor
Found in packages/dom/src/utils/getRectRelativeToOffsetParent.ts - About 1 hr to fix

Consider simplifying this complex logical expression.
Open

      if (
        (side === 'top' && y >= refRect.bottom - 1) ||
        (side === 'bottom' && y <= refRect.top + 1) ||
        (side === 'left' && x >= refRect.right - 1) ||
        (side === 'right' && x <= refRect.left + 1)
Severity: Critical
Found in packages/react/src/safePolygon.ts - About 1 hr to fix

Consider simplifying this complex logical expression.
Open

      if (
        clientRects.length === 2 &&
        clientRects[0].left > clientRects[1].right &&
        x != null &&
        y != null
Severity: Critical
Found in packages/core/src/middleware/inline.ts - About 1 hr to fix

Function onMouseLeave has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function onMouseLeave(event: MouseEvent) {
      if (isClickLikeOpenEvent()) return;

      unbindMouseMoveRef.current();

Severity: Minor
Found in packages/react/src/hooks/useHover.ts - About 1 hr to fix

Function FloatingList has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function FloatingList(props: FloatingListProps): JSX.Element {
  const {children, elementsRef, labelsRef} = props;

  const [map, setMap] = React.useState(() => new Map<Node, number | null>());

Severity: Minor
Found in packages/react/src/components/FloatingList.tsx - About 1 hr to fix

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

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

Severity: Minor
Found in packages/react/src/hooks/useFloating.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

Function Layout has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export default function Layout({children, className}) {
    const {pathname, events, asPath} = useRouter();
    const index = nav.findIndex(({url}) => url === pathname) ?? 0;
    const [navOpen, setNavOpen] = useState(false);
    const [anchors, setAnchors] = useState([]);
Severity: Minor
Found in website/lib/components/Layout.js - 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

Function getOffsetParent has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export function getOffsetParent(
  element: Element,
  polyfill?: Polyfill,
): Element | Window {
  const win = getWindow(element);
Severity: Minor
Found in packages/dom/src/platform/getOffsetParent.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

Function contains has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export function contains(parent?: Element | null, child?: Element | null) {
  if (!parent || !child) {
    return false;
  }

Severity: Minor
Found in packages/react/src/utils.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

Function getOffsetParent has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function getOffsetParent(
  element: Element,
  polyfill?: Polyfill,
): Element | Window {
  const win = getWindow(element);
Severity: Minor
Found in packages/dom/src/platform/getOffsetParent.ts - About 1 hr to fix

Function Link has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const Link = forwardRef(function Link(props, ref) {
  const {setPageTransitionStatus, setArticleTransitionStatus} =
    useAppContext();
  const router = useRouter();

Severity: Minor
Found in website/lib/components/Link.js - About 1 hr to fix

Function position has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const position = useCallback(() => {
    if (width === null || height === null) return;

    computePosition(reference, floating, {
      platform: {
Severity: Minor
Found in website/lib/components/Canvas.js - About 1 hr to fix

Function App has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function App() {
  const arrowRef = React.useRef(null);
  useFloating();
  const {update, refs, elements} = useFloating({
    placement: 'right',
Severity: Minor
Found in packages/react-native/index.test-d.tsx - About 1 hr to fix

Function item has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const item = React.useMemo(() => {
    function syncCurrentTarget(currentTarget: HTMLElement | null) {
      if (!open) return;
      const index = listRef.current.indexOf(currentTarget);
      if (index !== -1) {
Severity: Minor
Found in packages/react/src/hooks/useListNavigation.ts - About 1 hr to fix

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

    function onKeyDown(event: KeyboardEvent) {
      if (event.key === 'Tab') {
        // The focus guards have nothing to focus, so we need to stop the event.
        if (
          contains(
Severity: Minor
Found in packages/react/src/components/FloatingFocusManager.tsx - About 1 hr to fix
Severity
Category
Status
Source
Language