Neovici/cosmoz-tabs

View on GitHub

Showing 7 of 9 total issues

Function useTabs has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    useTabs = (host) => {
        const { selected, hashParam } = host,
            [tabs, setTabs] = useState([]),
            [param] = useHashParam(hashParam),
            selection =
Severity: Major
Found in src/use-tabs.js - About 2 hrs to fix

    Function Tab has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const Tab = (host) => {
        const { active, badge, href } = host;
    
        useEffect(() => {
            if (!host.getAttribute('tabindex')) {
    Severity: Minor
    Found in src/next/cosmoz-tab.js - About 1 hr to fix

      Function CosmozTabCard has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const CosmozTabCard = (host) => {
          const { heading, collapsable, collapsed: isCollapsed } = host,
              [collapsed, setCollapsed] = useState(Boolean(isCollapsed)),
              toggleCollapsed = () => {
                  if (!collapsable) return;
      Severity: Minor
      Found in src/cosmoz-tab-card.js - About 1 hr to fix

        Function useTabs has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            useTabs = (host) => {
                const { selected, hashParam } = host,
                    [tabs, setTabs] = useState([]),
                    [param] = useHashParam(hashParam),
                    selection =
        Severity: Minor
        Found in src/use-tabs.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 useTab has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const useTab = (host) => {
            useEffect(() => {
                host.dispatchEvent(
                    new CustomEvent('cosmoz-tab-alter', {
                        bubbles: true,
        Severity: Minor
        Found in src/use-tab.js - About 1 hr to fix

          Function useTabSelectedEffect has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const useTabSelectedEffect = (host, selectedTab) => {
                  useEffect(() => {
                      notifyProperty(host, 'selectedItem', selectedTab);
                      if (selectedTab == null) {
                          return;
          Severity: Minor
          Found in src/use-tabs.js - About 1 hr to fix

            Function useTabSelectedEffect has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            const useTabSelectedEffect = (host, selectedTab) => {
                    useEffect(() => {
                        notifyProperty(host, 'selectedItem', selectedTab);
                        if (selectedTab == null) {
                            return;
            Severity: Minor
            Found in src/use-tabs.js - 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

            Severity
            Category
            Status
            Source
            Language