grommet/grommet

View on GitHub
src/js/utils/DOM.js

Summary

Maintainability
B
5 hrs
Test Coverage

Function findScrollParent has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

export const findScrollParent = (element, horizontal) => {
  let result;
  if (element) {
    let parent = element.parentNode;
    while (!result && parent && parent.getBoundingClientRect) {
Severity: Minor
Found in src/js/utils/DOM.js - About 2 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 findScrollParents has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

export const findScrollParents = (element, horizontal) => {
  const result = [];
  if (element) {
    let parent = element.parentNode;
    while (parent && parent.getBoundingClientRect) {
Severity: Minor
Found in src/js/utils/DOM.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 makeNodeUnfocusable has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const makeNodeUnfocusable = (node) => {
  // do not touch aria live containers so that announcements work
  if (!node.hasAttribute('aria-live')) {
    node.setAttribute('aria-hidden', true);
    // prevent children to receive focus
Severity: Minor
Found in src/js/utils/DOM.js - About 1 hr to fix

    Function withinDropPortal has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    export const withinDropPortal = (node, portalContext) => {
      const root = node?.getRootNode();
      let element = node;
      let portalId;
      while (element && element !== root) {
    Severity: Minor
    Found in src/js/utils/DOM.js - About 25 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

    There are no issues that match your filters.

    Category
    Status