SU-SWS/stanford_profile

View on GitHub
themes/stanford_basic/decoupled-menu/src/main-menu.island.tsx

Summary

Maintainability
A
25 mins
Test Coverage

File main-menu.island.tsx has 377 lines of code (exceeds 250 allowed). Consider refactoring.
Wontfix

import styled from "styled-components";
import {useWebComponentEvents} from "./hooks/useWebComponentEvents";
import {createIslandWebComponent} from 'preact-island'
import {useState, useEffect, useRef, useCallback, useMemo} from 'preact/hooks';
import {deserialize} from "./tools/deserialize";
Severity: Minor
Found in themes/stanford_basic/decoupled-menu/src/main-menu.island.tsx - About 5 hrs to fix

    Function MainMenu has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Wontfix

    export const MainMenu = ({}) => {
      useWebComponentEvents(islandName)
      const [menuItems, setMenuItems] = useState<MenuContentItem[]>(window.drupalSettings?.stanford_basic?.decoupledMenuItems || []);
      const [menuOpen, setMenuOpen] = useState<boolean>(false);
      const buttonRef = useRef<HTMLButtonElement | null>(null);
    Severity: Major
    Found in themes/stanford_basic/decoupled-menu/src/main-menu.island.tsx - About 2 hrs to fix

      Function MenuItem has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
      Open

      const MenuItem = ({id, title, url, items, expanded, level = 0}: {
        title: string,
        url: string,
        items?: MenuContentItem[],
        expanded: boolean,
      Severity: Minor
      Found in themes/stanford_basic/decoupled-menu/src/main-menu.island.tsx - 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