hnhdigital-os/laravel-model-filter

View on GitHub

Showing 194 of 194 total issues

Function processAttributeFilter has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring.
Open

    private static function processAttributeFilter($query, $filter_setting, $filter_requests)
    {
        $model = (new static());
        foreach ($filter_requests as $filter_request) {
            // Clean inputs
Severity: Minor
Found in src/Traits/ModelTrait.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

Function compose has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
Open

    public function compose(View $view)
    {
        // Get the data assigned to this view
        $view_data = $view->getData();
        $filter_types = [];
Severity: Minor
Found in src/Composers/SearchPage.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

Function getFilterAttributes has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getFilterAttributes($first_call = true)
    {
        $model = (new static());

        if (isset($model->filter_attributes) && is_array($model->filter_attributes)) {
Severity: Minor
Found in src/Traits/ModelTrait.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 ModelTrait.php has 518 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace HnhDigital\LaravelModelFilter\Traits;

use DB;
Severity: Major
Found in src/Traits/ModelTrait.php - About 1 day to fix

    File ControllerTrait.php has 433 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace HnhDigital\LaravelModelFilter\Traits;
    
    use HnhDigital\LaravelModelFilter\Objects\SearchViewOptions;
    Severity: Minor
    Found in src/Traits/ControllerTrait.php - About 6 hrs to fix

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

      Function getCurrentSearchQuery has a Cognitive Complexity of 36 (exceeds 5 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: Minor
      Found in src/Traits/ControllerTrait.php - About 5 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 validateOperators has 135 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private static function validateOperators($filter, &$method, &$arguments, $model, $filter_setting, $operator, $value1, $value2)
          {
              // No space search.
              if (array_has($filter_setting, 'phone_search')) {
                  $value1_numeric = str_replace(' ', '', $value1);
      Severity: Major
      Found in src/Traits/ModelTrait.php - About 5 hrs to fix

        File search.js has 358 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        
        $(document).ready(function() {
        
            /* User clicks the availablle filters */
            var track_filters = 0;
        Severity: Minor
        Found in js/search.js - About 4 hrs to fix

          Function showSearchAppliedFilters has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

              protected static function showSearchAppliedFilters(&$tbody, &$search_request, $result, $model, $column_span = 1)
              {
                  self::pagination($result, $search_request);
          
                  // Applied filters
          Severity: Minor
          Found in src/Traits/ControllerTrait.php - About 4 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

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

              private static function validateOperators($filter, &$method, &$arguments, $model, $filter_setting, $operator, $value1, $value2)
              {
                  // No space search.
                  if (array_has($filter_setting, 'phone_search')) {
                      $value1_numeric = str_replace(' ', '', $value1);
          Severity: Minor
          Found in src/Traits/ModelTrait.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

          Function scopeApplyAttributeFilters has a Cognitive Complexity of 26 (exceeds 5 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 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 compose has 91 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function compose(View $view)
              {
                  // Get the data assigned to this view
                  $view_data = $view->getData();
                  $filter_types = [];
          Severity: Major
          Found in src/Composers/SearchPage.php - About 3 hrs to fix

            Method processAttributeFilter has 77 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private static function processAttributeFilter($query, $filter_setting, $filter_requests)
                {
                    $model = (new static());
                    foreach ($filter_requests as $filter_request) {
                        // Clean inputs
            Severity: Major
            Found in src/Traits/ModelTrait.php - About 3 hrs to fix

              Function loadFilter has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function loadFilter(HttpRequest $request, ModelFilter $model_filter)
                  {
                      $model_name = 'App\\Models\\'.$request->get('model');
                      $method_name = $request->get('method');
              
              
              Severity: Minor
              Found in src/Traits/ControllerTrait.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 loadFilter has 62 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function loadFilter(HttpRequest $request, ModelFilter $model_filter)
                  {
                      $model_name = 'App\\Models\\'.$request->get('model');
                      $method_name = $request->get('method');
              
              
              Severity: Major
              Found in src/Traits/ControllerTrait.php - About 2 hrs to fix

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

                Function update has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    update: function(search_table_id, response)
                    {
                        var search_table = $('#'+search_table_id);
                
                        if (typeof response.rows != 'undefined') {
                Severity: Major
                Found in js/search.js - About 2 hrs to fix

                  Function update has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                  Open

                      update: function(search_table_id, response)
                      {
                          var search_table = $('#'+search_table_id);
                  
                          if (typeof response.rows != 'undefined') {
                  Severity: Minor
                  Found in js/search.js - 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 getFilterAttributes has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function getFilterAttributes($first_call = true)
                      {
                          $model = (new static());
                  
                          if (isset($model->filter_attributes) && is_array($model->filter_attributes)) {
                  Severity: Major
                  Found in src/Traits/ModelTrait.php - About 2 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language