hnhdigital-os/laravel-navigation-builder

View on GitHub

Showing 25 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

          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

                      Avoid deeply nested control flow statements.
                      Open

                                                  if (($index = array_search($input_value, $current_value_array)) !== false) {
                                                      unset($current_value_array[$index]);
                                                  }
                      Severity: Major
                      Found in src/Item.php - About 45 mins to fix

                        Function checkItemIsActive has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function checkItemIsActive($item)
                            {
                                if ($this->getActive()) {
                                    return true;
                                }
                        Severity: Minor
                        Found in src/Item.php - About 35 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

                        Function renderDropdown has a Cognitive Complexity of 7 (exceeds 5 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 35 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

                        Avoid too many return statements within this method.
                        Open

                                return $this;
                        Severity: Major
                        Found in src/Item.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                      return $this;
                          Severity: Major
                          Found in src/Item.php - About 30 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language