hnhdigital-os/laravel-navigation-builder

View on GitHub

Showing 61 of 61 total issues

Function __call has a Cognitive Complexity of 64 (exceeds 5 allowed). Consider refactoring.
Open

    public function __call(string $name, array $arguments)
    {
        $original_method_name = Str::snake($name);
        preg_match('/^([a-z]+)_([a-z_]+)_([a-z]+)$/', $original_method_name, $matches);

Severity: Minor
Found in src/Item.php - About 1 day 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

File Item.php has 463 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/*
 * This file is part of Laravel Navigation Builder.
 *
Severity: Minor
Found in src/Item.php - About 7 hrs to fix

    Menu has 35 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Menu
    {
        /**
         * Item collection.
         *
    Severity: Minor
    Found in src/Menu.php - About 4 hrs to fix

      Item has 31 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Item
      {
          /**
           * No link specified.
           *
      Severity: Minor
      Found in src/Item.php - About 3 hrs to fix

        Function render has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

            public function render($menu_level = 0)
            {
                static::activateIfItemIsActive($this);
        
                // Not authorized for this menu.
        Severity: Minor
        Found in src/Item.php - About 3 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

        Method __call has 85 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function __call(string $name, array $arguments)
            {
                $original_method_name = Str::snake($name);
                preg_match('/^([a-z]+)_([a-z_]+)_([a-z]+)$/', $original_method_name, $matches);
        
        
        Severity: Major
        Found in src/Item.php - About 3 hrs to fix

          The class Item has 22 public methods. Consider refactoring Item to keep number of public methods under 10.
          Open

          class Item
          {
              /**
               * No link specified.
               *
          Severity: Minor
          Found in src/Item.php by phpmd

          TooManyPublicMethods

          Since: 0.1

          A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

          By default it ignores methods starting with 'get' or 'set'.

          Example

          Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

          The class Menu has 26 non-getter- and setter-methods. Consider refactoring Menu to keep number of methods under 25.
          Open

          class Menu
          {
              /**
               * Item collection.
               *
          Severity: Minor
          Found in src/Menu.php by phpmd

          TooManyMethods

          Since: 0.1

          A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

          By default it ignores methods starting with 'get' or 'set'.

          The default was changed from 10 to 25 in PHPMD 2.3.

          Example

          Source https://phpmd.org/rules/codesize.html#toomanymethods

          The class Item has an overall complexity of 132 which is very high. The configured complexity threshold is 50.
          Open

          class Item
          {
              /**
               * No link specified.
               *
          Severity: Minor
          Found in src/Item.php by phpmd

          The class Menu has 24 public methods. Consider refactoring Menu to keep number of public methods under 10.
          Open

          class Menu
          {
              /**
               * Item collection.
               *
          Severity: Minor
          Found in src/Menu.php by phpmd

          TooManyPublicMethods

          Since: 0.1

          A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

          By default it ignores methods starting with 'get' or 'set'.

          Example

          Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

          The class Menu has an overall complexity of 70 which is very high. The configured complexity threshold is 50.
          Open

          class Menu
          {
              /**
               * Item collection.
               *
          Severity: Minor
          Found in src/Menu.php by phpmd

          Method render has 75 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function render($menu_level = 0)
              {
                  static::activateIfItemIsActive($this);
          
                  // Not authorized for this menu.
          Severity: Major
          Found in src/Item.php - About 3 hrs to fix

            File Menu.php has 261 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            
            /*
             * This file is part of Laravel Navigation Builder.
             *
            Severity: Minor
            Found in src/Menu.php - About 2 hrs to fix

              Function activateIfItemIsActive has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function activateIfItemIsActive($item)
                  {
                      // No menu items provided.
                      if (empty($list = $item->getActiveIfItemIsActiveOption())) {
                          return false;
              Severity: Minor
              Found in src/Item.php - 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 getMenu has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getMenu($key)
                  {
                      if (is_array($key)) {
                          $menu_items = $key;
                      } else {
              Severity: Minor
              Found in src/Navigation.php - 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

              Consider simplifying this complex logical expression.
              Open

                              if (($action == 'add' || $action == 'remove' || $action == 'append' || $action == 'prepend')
                                  && ($key == 'item' || $key == 'container' || $key == 'link') && $method_name == 'attribute') {
                                  $input_value = Arr::get($arguments, 1, '');
                                  $current_value = Arr::get($this->{$key.'_'.$method_name}, Arr::get($arguments, 0, null), '');
              
              
              Severity: Critical
              Found in src/Item.php - About 1 hr to fix

                Method renderDropdown has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function renderDropdown()
                    {
                        $menu_source = Arr::get($this->option, 'dropdown_source', null);
                        $config = Arr::get($this->option, 'dropdown_config', null);
                
                
                Severity: Minor
                Found in src/Item.php - About 1 hr to fix

                  Method __call has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function __call($name, $arguments)
                      {
                          // $this->whereTitle(...)
                          preg_match('/^[W|w]here([a-zA-Z0-9_]+)$/', $name, $matches);
                  
                  
                  Severity: Minor
                  Found in src/Menu.php - About 1 hr to fix

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

                        public function __call($name, $arguments)
                        {
                            // $this->whereTitle(...)
                            preg_match('/^[W|w]here([a-zA-Z0-9_]+)$/', $name, $matches);
                    
                    
                    Severity: Minor
                    Found in src/Menu.php - 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

                    Method activateIfItemIsActive has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public static function activateIfItemIsActive($item)
                        {
                            // No menu items provided.
                            if (empty($list = $item->getActiveIfItemIsActiveOption())) {
                                return false;
                    Severity: Minor
                    Found in src/Item.php - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language