FezVrasta/popper.js

View on GitHub
packages/core/src/middleware/inline.ts

Summary

Maintainability
C
1 day
Test Coverage

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

    function getBoundingClientRect() {
      // There are two rects and they are disjoined.
      if (
        clientRects.length === 2 &&
        clientRects[0].left > clientRects[1].right &&
Severity: Major
Found in packages/core/src/middleware/inline.ts - About 2 hrs 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

There are no issues that match your filters.

Category
Status