hnhdigital-os/laravel-model-filter

View on GitHub

Showing 194 of 194 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 runStandardSubSearch has 43 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

        Avoid excessively long variable names like $attached_button_color. Keep variable name length under 20.
        Open

                $options['attached_button_color'] = (isset($attached_button_color)) ? $attached_button_color : 'danger';
        Severity: Minor
        Found in src/Traits/ControllerTrait.php by phpmd

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

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

        Avoid excessively long variable names like $unattached_button_name. Keep variable name length under 20.
        Open

                $options['unattached_button_name'] = (isset($unattached_button_name)) ? $unattached_button_name : 'Add '.str_plural($search_name, 1);
        Severity: Minor
        Found in src/Traits/ControllerTrait.php by phpmd

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

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

        Avoid excessively long variable names like $override_attached_method_source. Keep variable name length under 20.
        Open

                        if (isset($override_attached_method_source)) {
        Severity: Minor
        Found in src/Traits/ControllerTrait.php by phpmd

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

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

        Avoid excessively long variable names like $unattached_method_source. Keep variable name length under 20.
        Open

                        if (isset($unattached_method_source)) {
        Severity: Minor
        Found in src/Traits/ControllerTrait.php by phpmd

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

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

        Avoid excessively long variable names like $override_unattached_method_source. Keep variable name length under 20.
        Open

                        if (isset($override_unattached_method_source)) {
        Severity: Minor
        Found in src/Traits/ControllerTrait.php by phpmd

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

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

        Avoid excessively long variable names like $unattached_model_filter. Keep variable name length under 20.
        Open

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

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

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

        Avoid excessively long variable names like $original_model_filter_options. Keep variable name length under 20.
        Open

                $original_model_filter_options = ModelFilter::active()->get();
        Severity: Minor
        Found in src/Traits/ControllerTrait.php by phpmd

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

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

        Avoid excessively long variable names like $attached_model_filter. Keep variable name length under 20.
        Open

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

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

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

        Avoid excessively long variable names like $unattached_allocations. Keep variable name length under 20.
        Open

                    if (isset($unattached_allocations)) {
        Severity: Minor
        Found in src/Traits/ControllerTrait.php by phpmd

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

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

        Avoid excessively long variable names like $related_qualified_key_name. Keep variable name length under 20.
        Open

                        $related_qualified_key_name = $related_relation->getQualifiedKeyName();
        Severity: Minor
        Found in src/Traits/ModelTrait.php by phpmd

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

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

        Avoid excessively long variable names like $unattached_button_color. Keep variable name length under 20.
        Open

                $options['unattached_button_color'] = (isset($unattached_button_color)) ? $unattached_button_color : 'primary';
        Severity: Minor
        Found in src/Traits/ControllerTrait.php by phpmd

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

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

        Avoid excessively long variable names like $total_relationship_models. Keep variable name length under 20.
        Open

                    $total_relationship_models = 0;
        Severity: Minor
        Found in src/Traits/ModelTrait.php by phpmd

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

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

        Avoid excessively long variable names like $original_model_filter_options. Keep variable name length under 20.
        Open

                            $original_model_filter_options = ModelFilter::where($model_attribute, $app_model->id)->get();
        Severity: Minor
        Found in src/Composers/SearchPage.php by phpmd

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

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

        Avoid excessively long variable names like $unattached_button_icon. Keep variable name length under 20.
        Open

                $options['unattached_button_icon'] = (isset($unattached_button_icon)) ? $unattached_button_icon : 'plus';
        Severity: Minor
        Found in src/Traits/ControllerTrait.php by phpmd

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

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

        Avoid excessively long variable names like $attached_method_source. Keep variable name length under 20.
        Open

                        if (isset($attached_method_source)) {
        Severity: Minor
        Found in src/Traits/ControllerTrait.php by phpmd

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

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

        Severity
        Category
        Status
        Source
        Language