FezVrasta/popper.js

View on GitHub

Showing 329 of 329 total issues

Function detectOverflow has a Cognitive Complexity of 8 (exceeds 5 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: Minor
Found in packages/core/src/detectOverflow.ts - About 45 mins 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

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

    x:
      rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
packages/dom/src/platform/convertOffsetParentRelativeRectToViewportRelativeRect.ts on lines 66..66

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

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

    y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y,
packages/dom/src/platform/convertOffsetParentRelativeRectToViewportRelativeRect.ts on lines 64..65

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

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

Consider simplifying this complex logical expression.
Open

        if (
          (!previousOpenRef.current || !previousMountedRef.current) &&
          focusItemOnOpenRef.current &&
          (keyRef.current != null ||
            (focusItemOnOpenRef.current === true && keyRef.current == null))
Severity: Major
Found in packages/react/src/hooks/useListNavigation.ts - About 40 mins to fix

Consider simplifying this complex logical expression.
Open

  if (
    path.includes('react') ||
    path.includes('use') ||
    path.includes('floating') ||
    path.includes('composite') ||
Severity: Major
Found in website/lib/utils/getPackageContext.js - About 40 mins to fix

Consider simplifying this complex logical expression.
Open

    if (
      listContent == null ||
      ignoreKeysRef.current.includes(event.key) ||
      // Character key.
      event.key.length !== 1 ||
Severity: Major
Found in packages/react/src/hooks/useTypeahead.ts - About 40 mins to fix

Function getCellIndexOfCorner has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  index: number,
  sizes: Dimensions[],
  cellMap: (number | undefined)[],
  cols: number,
  corner: 'tl' | 'tr' | 'bl' | 'br',
Severity: Minor
Found in packages/react/src/utils/composite.ts - About 35 mins to fix

Function NavbarItem has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function NavbarItem({
    url,
    title,
    icon: Icon,
    hide,
Severity: Minor
Found in website/lib/components/Layout.js - About 35 mins 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 getScale has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export function getScale(element: Element | VirtualElement): Coords {
  const domElement = unwrapElement(element);

  if (!isHTMLElement(domElement)) {
    return createCoords(1);
Severity: Minor
Found in packages/dom/src/platform/getScale.ts - About 35 mins 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 useFloatingRootContext has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export function useFloatingRootContext(
  options: UseFloatingRootContextOptions,
): FloatingRootContext {
  const {
    open = false,
Severity: Minor
Found in packages/react/src/hooks/useFloatingRootContext.ts - About 35 mins 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 enableScrollLock has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function enableScrollLock() {
  const isIOS = /iP(hone|ad|od)|iOS/.test(getPlatform());
  const bodyStyle = document.body.style;
  // RTL <body> scrollbar
  const scrollbarX =
Severity: Minor
Found in packages/react/src/components/FloatingOverlay.tsx - About 35 mins 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

Avoid too many return statements within this function.
Open

      return true;
Severity: Major
Found in packages/react-native/src/utils/deepEqual.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

  return offsetParent || getContainingBlock(element) || win;
Severity: Major
Found in packages/dom/src/platform/getOffsetParent.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

        return;
Severity: Major
Found in packages/react/src/hooks/useDismiss.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

    return () => {
      tree.events.off('virtualfocus', handleVirtualFocus);
    };
Severity: Major
Found in packages/react/src/hooks/useListNavigation.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

        return;
Severity: Major
Found in packages/react/src/hooks/useListNavigation.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

    return true;
Severity: Major
Found in packages/react-native/src/utils/deepEqual.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

      return false;
Severity: Major
Found in packages/react-native/src/utils/deepEqual.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

        return false;
Severity: Major
Found in packages/react-native/src/utils/deepEqual.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

          return close();
Severity: Major
Found in packages/react/src/safePolygon.ts - About 30 mins to fix
Severity
Category
Status
Source
Language