FezVrasta/popper.js

View on GitHub

Showing 305 of 305 total issues

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 fn has 101 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

Function useFloating has 100 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

Function useClientPoint has 99 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function useClientPoint<RT extends ReferenceType = ReferenceType>(
  context: FloatingContext<RT>,
  props: UseClientPointProps = {},
): ElementProps {
  const {
Severity: Major
Found in packages/react/src/hooks/useClientPoint.ts - About 3 hrs to fix

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

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

Function onKeyDown has 95 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 FloatingArrow has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

export const FloatingArrow = React.forwardRef(function FloatingArrow(
  props: FloatingArrowProps,
  ref: React.ForwardedRef<SVGSVGElement>,
): JSX.Element | null {
  const {
Severity: Minor
Found in packages/react/src/components/FloatingArrow.tsx - About 3 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 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 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

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

export function useInnerOffset(
  context: FloatingContext,
  props: UseInnerOffsetProps,
): ElementProps {
  const {open, elements} = context;
Severity: Major
Found in packages/react/src/inner.ts - About 3 hrs to fix

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

  async fn(state) {
    const {rects, middlewareData, placement, platform, elements} = state;

    const {
      crossAxis = false,
Severity: Major
Found in packages/core/src/middleware/autoPlacement.ts - About 3 hrs to fix

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

export function FloatingPortal(props: FloatingPortalProps): 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 closeOnPressOutside has 80 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const closeOnPressOutside = useEffectEvent((event: MouseEvent) => {
    // Given developers can stop the propagation of the synthetic event,
    // we can only be confident with a positive value.
    const insideReactTree = insideReactTreeRef.current;
    insideReactTreeRef.current = false;
Severity: Major
Found in packages/react/src/hooks/useDismiss.ts - About 3 hrs to fix

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

            const commonPoints: [Point, Point] = [
              [
                cursorLeaveFromBottom
                  ? rect.right - buffer
                  : isFloatingTaller
Severity: Major
Found in packages/react/src/safePolygon.ts and 1 other location - About 3 hrs to fix
packages/react/src/safePolygon.ts on lines 357..374

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

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 commonPoints: [Point, Point] = [
              [
                rect.left,
                cursorLeaveFromRight
                  ? rect.top + buffer
Severity: Major
Found in packages/react/src/safePolygon.ts and 1 other location - About 3 hrs to fix
packages/react/src/safePolygon.ts on lines 243..260

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

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 commonPoints: [Point, Point] = [
              [
                cursorLeaveFromBottom
                  ? rect.left + buffer
                  : isFloatingTaller
Severity: Major
Found in packages/react/src/safePolygon.ts and 1 other location - About 3 hrs to fix
packages/react/src/safePolygon.ts on lines 319..336

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

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 commonPoints: [Point, Point] = [
              [
                rect.left,
                cursorLeaveFromRight
                  ? rect.bottom - buffer
Severity: Major
Found in packages/react/src/safePolygon.ts and 1 other location - About 3 hrs to fix
packages/react/src/safePolygon.ts on lines 281..298

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

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

  async fn(state) {
    const {
      listRef,
      overflowRef,
      onFallbackChange,
Severity: Major
Found in packages/react/src/inner.ts - About 3 hrs to fix
Severity
Category
Status
Source
Language