FezVrasta/popper.js

View on GitHub

Showing 329 of 329 total issues

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 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 useHover has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

export function useHover(
  context: FloatingRootContext,
  props: UseHoverProps = {},
): ElementProps {
  const {open, onOpenChange, dataRef, events, elements} = context;
Severity: Minor
Found in packages/react/src/hooks/useHover.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 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

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

  const {
    refs,
    floatingStyles,
    placement,
    update,
Severity: Major
Found in website/lib/components/Tutorial.js and 1 other location - About 4 hrs to fix
website/lib/components/Tutorial.js on lines 309..323

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

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 2 locations. Consider refactoring.
Open

  const {
    refs,
    floatingStyles,
    placement,
    update,
Severity: Major
Found in website/lib/components/Tutorial.js and 1 other location - About 4 hrs to fix
website/lib/components/Tutorial.js on lines 251..265

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

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

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

      onKeyDown(event) {
        isPointerModalityRef.current = false;

        const isArrowKey = event.key.startsWith('Arrow');
        const isHomeOrEndKey = ['Home', 'End'].includes(event.key);
Severity: Major
Found in packages/react/src/hooks/useListNavigation.ts - About 4 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, 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

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

export type {
  AlignedPlacement,
  Alignment,
  Axis,
  ClientRectObject,
Severity: Major
Found in packages/dom/src/index.ts and 1 other location - About 3 hrs to fix
packages/dom/src/index.ts on lines 45..67

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

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

Severity
Category
Status
Source
Language