hnhdigital-os/laravel-dynamic-filter

View on GitHub

Showing 64 of 70 total issues

Method getCurrentSearchQuery has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getCurrentSearchQuery($options, $class_name, $model_filter = false)
    {
        $class_name = 'App\\Models\\'.$class_name;
        extract($options);
        $route_name = (!isset($route_name)) ? $current_model : $route_name;
Severity: Major
Found in src/Traits/ControllerTrait.php - About 2 hrs to fix

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

        public function scopeModelJoin($query, $relationships, $operator = '=', $type = 'left', $where = false)
        {
            if (!is_array($relationships)) {
                $relationships = [$relationships];
            }
    Severity: Minor
    Found in src/Traits/ModelTrait.php - 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

    Method scopeModelJoin has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function scopeModelJoin($query, $relationships, $operator = '=', $type = 'left', $where = false)
        {
            if (!is_array($relationships)) {
                $relationships = [$relationships];
            }
    Severity: Minor
    Found in src/Traits/ModelTrait.php - About 1 hr to fix

      Function returnSearchResult has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          protected static function returnSearchResult($controller_name, $distinct_session, $search_request, $response, $extra_response = false)
          {
              unset($search_request['rows']);
      
              // Save filters to session
      Severity: Minor
      Found in src/Traits/ControllerTrait.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 getCurrentSearchDetails has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getCurrentSearchDetails($use_session, $settings, $options, $search_name)
          {
              extract($options);
      
              $options['route_paramater'] = (empty($options['route_paramater'])) ? $current_model : $options['route_paramater'];
      Severity: Minor
      Found in src/Traits/ControllerTrait.php - About 1 hr to fix

        Method runStandardSubSearch has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function runStandardSubSearch(&$view_data, $config, $model)
            {
                foreach ($config as $config_entry) {
                    list($page, $name, $variable, $method, $class, $view_settings, $search_settings) = array_pad($config_entry, 7, null);
        
        
        Severity: Minor
        Found in src/Traits/ControllerTrait.php - About 1 hr to fix

          Method checkSearchResults has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected static function checkSearchResults($table, $result, &$search_request, $name, $column_span = 1, $config = [])
              {
                  self::pagination($result, $search_request);
          
                  $thead = false;
          Severity: Minor
          Found in src/Traits/ControllerTrait.php - About 1 hr to fix

            Method showSearchAppliedFilters has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected static function showSearchAppliedFilters(&$tbody, &$search_request, $result, $model, $column_span = 1, $options = [])
                {
                    self::pagination($result, $search_request);
            
                    // Applied filters
            Severity: Minor
            Found in src/Traits/ControllerTrait.php - About 1 hr to fix

              Method scopeApplyAttributeFilters has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function scopeApplyAttributeFilters($query, $search_request)
                  {
                      if (isset($search_request['filters']) && is_array($search_request['filters']) && !empty($search_request['filters'])) {
              
                          // Get available filters
              Severity: Minor
              Found in src/Traits/ModelTrait.php - About 1 hr to fix

                Method getAppliedFiltersArray has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function getAppliedFiltersArray($search_request)
                    {
                        $model = (new static());
                        $result = [];
                        foreach ($model->getFilterAttributes() as $filter_name => $filter_settings) {
                Severity: Minor
                Found in src/Traits/ModelTrait.php - About 1 hr to fix

                  Method returnSearchResult has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected static function returnSearchResult($controller_name, $distinct_session, $search_request, $response, $extra_response = false)
                      {
                          unset($search_request['rows']);
                  
                          // Save filters to session
                  Severity: Minor
                  Found in src/Traits/ControllerTrait.php - About 1 hr to fix

                    Function getCurrentSearchDetails has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function getCurrentSearchDetails($use_session, $settings, $options, $search_name)
                        {
                            extract($options);
                    
                            $options['route_paramater'] = (empty($options['route_paramater'])) ? $current_model : $options['route_paramater'];
                    Severity: Minor
                    Found in src/Traits/ControllerTrait.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 getFilters has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        getFilters: function(search_table_id)
                        {
                            var current_filters = {
                              'filters': {}
                            };
                    Severity: Minor
                    Found in js/search.js - About 1 hr to fix

                      Method validateOperators has 8 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          private static function validateOperators($filter, &$method, &$arguments, $model, $filter_setting, $operator, $value1, $value2)
                      Severity: Major
                      Found in src/Traits/ModelTrait.php - About 1 hr to fix

                        Function runStandardSubSearch has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function runStandardSubSearch(&$view_data, $config, $model)
                            {
                                foreach ($config as $config_entry) {
                                    list($page, $name, $variable, $method, $class, $view_settings, $search_settings) = array_pad($config_entry, 7, null);
                        
                        
                        Severity: Minor
                        Found in src/Traits/ControllerTrait.php - About 55 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 deeply nested control flow statements.
                        Open

                                                    if (in_array($check_operator, $available_operators)) {
                                                        $operator = $check_operator;
                                                        $value1 = implode(' ', $value1_array);
                                                    }
                        Severity: Major
                        Found in src/Traits/ModelTrait.php - About 45 mins to fix

                          Method showSearchAppliedFilters has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              protected static function showSearchAppliedFilters(&$tbody, &$search_request, $result, $model, $column_span = 1, $options = [])
                          Severity: Minor
                          Found in src/Traits/ControllerTrait.php - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                            if (isset($settings['name'])) {
                                                                $filter_detail['name'] = $settings['name'].': '.$filter_detail['attribute_name'];
                                                            }
                            Severity: Major
                            Found in src/Traits/ModelTrait.php - About 45 mins to fix

                              Method checkSearchResults has 6 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  protected static function checkSearchResults($table, $result, &$search_request, $name, $column_span = 1, $config = [])
                              Severity: Minor
                              Found in src/Traits/ControllerTrait.php - About 45 mins to fix

                                Method scopeModelJoin has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                    public function scopeModelJoin($query, $relationships, $operator = '=', $type = 'left', $where = false)
                                Severity: Minor
                                Found in src/Traits/ModelTrait.php - About 35 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language