hnhdigital-os/laravel-model-filter

View on GitHub

Showing 194 of 194 total issues

Avoid using undefined variables such as '$attached_model_filter' which will lead to PHP notices.
Open

            if (isset($attached_model_filter) && $attached_model_filter instanceof \Closure) {
Severity: Minor
Found in src/Traits/ControllerTrait.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Function getFilters has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    getFilters: function(search_table_id)
    {
        var search_table = $('#'+search_table_id);

        var current_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 getCurrentSearchDetails has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getCurrentSearchDetails($use_session, $settings, $options, $search_name)
          {
              if (request()->ajax()) {
                  $settings_data = request()->all();
              } else {
      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 variables with short names like $tr. Configured minimum length is 3.
      Open

                  $tr = $tbody->tr();
      Severity: Minor
      Found in src/Traits/ControllerTrait.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#shortvariable

      Avoid variables with short names like $tr. Configured minimum length is 3.
      Open

                          $tr = $tbody->tr();
      Severity: Minor
      Found in src/Traits/ControllerTrait.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#shortvariable

      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

        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

          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 applyFilterAttributeArray has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                private static function applyFilterAttributeArray($query, $attribute_list, $method, $arguments, $positive = true)
            Severity: Minor
            Found in src/Traits/ModelTrait.php - About 35 mins to fix

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

                  protected static function returnSearchResult($controller_name, $distinct_session, $search_request, $response, $extra_response = false)
              Severity: Minor
              Found in src/Traits/ControllerTrait.php - About 35 mins to fix

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

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

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

                        public function compose(View $view)
                        {
                            $view_data = $view->getData();
                    
                            if ($view_data['template']) {
                    Severity: Minor
                    Found in src/Composers/SearchFilterList.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 getSearchAppliedFilters has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected static function getSearchAppliedFilters($controller_name, $distinct_session = '', $use_session = false)
                        {
                    
                            // Filter provided.
                            if (is_array($use_session)) {
                    Severity: Minor
                    Found in src/Traits/ControllerTrait.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 true;
                    Severity: Major
                    Found in src/Traits/ModelTrait.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                              return true;
                      Severity: Major
                      Found in src/Traits/ModelTrait.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                                return true;
                        Severity: Major
                        Found in src/Traits/ModelTrait.php - About 30 mins to fix

                          The method scopeModelJoin has a boolean flag argument $where, which is a certain sign of a Single Responsibility Principle violation.
                          Open

                              public function scopeModelJoin($query, $relationships, $operator = '=', $type = 'left', $where = false)
                          Severity: Minor
                          Found in src/Traits/ModelTrait.php by phpmd

                          BooleanArgumentFlag

                          Since: 1.4.0

                          A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

                          Example

                          class Foo {
                              public function bar($flag = true) {
                              }
                          }

                          Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

                          Avoid too many return statements within this method.
                          Open

                                                  return true;
                          Severity: Major
                          Found in src/Traits/ModelTrait.php - About 30 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language