hnhdigital-os/laravel-search-components

View on GitHub

Showing 20 of 70 total issues

File Search.php has 537 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace HnhDigital\SearchComponents;

use HnhDigital\LaravelHtmlBuilder\Tag;
Severity: Major
Found in src/Search.php - About 1 day to fix

    Search has 42 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Search
    {
        /**
         * Config.
         *
    Severity: Minor
    Found in src/Search.php - About 5 hrs to fix

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

          private function parseRequest()
          {
              $result = [
                  'count'      => 0,
                  'attributes' => [],
      Severity: Minor
      Found in src/Search.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

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

          private function parseRequest()
          {
              $result = [
                  'count'      => 0,
                  'attributes' => [],
      Severity: Minor
      Found in src/Search.php - About 1 hr to fix

        Function autoInit has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          autoInit: function() {
            $('.hnhdigital-search-form').on('submit', function() {
              var form = $(this);
              var results = $('.'+$(this).attr('id').replace(new RegExp('-form$'), '-results'));
              var page = $(form).find('[name=page]').val();
        Severity: Minor
        Found in resources/js/search.js - About 1 hr to fix

          Method render has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function render($html, $response = [])
              {
                  $this->result = $html;
                  $this->result_response = $response;
          
          
          Severity: Minor
          Found in src/Search.php - About 1 hr to fix

            Function updateResults has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              updateResults: function(results, response) {
                if (!results.hasClass('hnhdigital-search-results')) {
                  var form_id = results.attr('id').replace(new RegExp('-form$'), '-results');
                  results = $('.'+form_id);
                }
            Severity: Minor
            Found in resources/js/search.js - About 1 hr to fix

              Function serialize has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                serialize: function(form, results) {
                  var search = {};
              
                  results.find('.search-field').each(function() {
              
              
              Severity: Minor
              Found in resources/js/search.js - About 1 hr to fix

                Method getSearchInput has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function getSearchInput()
                    {
                        $total_columns = $this->checkColumns();
                        $search_input = Arr::get($this->config, 'search_input', []);
                        $force_search_input = Arr::get($this->config, 'force_search_input', false);
                Severity: Minor
                Found in src/Search.php - About 1 hr to fix

                  Function render has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function render($html, $response = [])
                      {
                          $this->result = $html;
                          $this->result_response = $response;
                  
                  
                  Severity: Minor
                  Found in src/Search.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 updateResults has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                    updateResults: function(results, response) {
                      if (!results.hasClass('hnhdigital-search-results')) {
                        var form_id = results.attr('id').replace(new RegExp('-form$'), '-results');
                        results = $('.'+form_id);
                      }
                  Severity: Minor
                  Found in resources/js/search.js - About 45 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 __call has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function __call($method, $arguments)
                      {
                          preg_match('/^(get|set)(.*)$/', $method, $matches);
                  
                          if (count($matches)) {
                  Severity: Minor
                  Found in src/Search.php - About 45 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 autoInit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                    autoInit: function() {
                      $('.hnhdigital-search-form').on('submit', function() {
                        var form = $(this);
                        var results = $('.'+$(this).attr('id').replace(new RegExp('-form$'), '-results'));
                        var page = $(form).find('[name=page]').val();
                  Severity: Minor
                  Found in resources/js/search.js - About 45 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 setRequest has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function setRequest($name)
                      {
                          // Get the data from the request or provided array.
                          $request = is_array($name) ? $name : request($name, []);
                  
                  
                  Severity: Minor
                  Found in src/Search.php - About 45 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 addRequest has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function addRequest(...$names)
                      {
                          $request = $this->config['request'];
                  
                          // If names provided as an array.
                  Severity: Minor
                  Found in src/Search.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 generateSessionName has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function generateSessionName($name, $class = '', $route_text = '', $route_parameters = [])
                      {
                          // Use the unique route as the session name.
                          if (! empty($route_text)) {
                              $name = str_replace(['[', ']', '::', ' '], ['', '-', '-', ''], $route_text);
                  Severity: Minor
                  Found in src/Search.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/Search.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

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

                      Function getSearchInfo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private function getSearchInfo()
                          {
                              $total_columns = $this->checkColumns();
                              $search_info = Arr::get($this->config, 'search_info', []);
                              $tbody = Tag::tbody();
                      Severity: Minor
                      Found in src/Search.php - About 25 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 run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function run($query)
                          {
                              $this->query = clone $query;
                      
                              // Run query.
                      Severity: Minor
                      Found in src/Search.php - About 25 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

                      Severity
                      Category
                      Status
                      Source
                      Language