phplib/Search/Elasticsearch.php

Summary

Maintainability
D
2 days
Test Coverage

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

    public function search($date, $settings, $query_list, $fields, $date_field, $date_type, $result_type, $filter_range) {
        // If we're looking for no results, set filter to (< 1)
        if($result_type == self::R_NO_RESULTS) {
            $filter_range = [0, 0];
        }
Severity: Minor
Found in phplib/Search/Elasticsearch.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

Method search has 107 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function search($date, $settings, $query_list, $fields, $date_field, $date_type, $result_type, $filter_range) {
        // If we're looking for no results, set filter to (< 1)
        if($result_type == self::R_NO_RESULTS) {
            $filter_range = [0, 0];
        }
Severity: Major
Found in phplib/Search/Elasticsearch.php - About 4 hrs to fix

    Method constructQuery has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function constructQuery() {
            $query = Util::get($this->obj['query_data'], 'query');
            $fields = Util::get($this->obj['query_data'], 'fields', []);
            $parser = new \ESQuery\Parser;
            list($settings, $query_list) = $parser->parse($query);
    Severity: Minor
    Found in phplib/Search/Elasticsearch.php - About 1 hr to fix

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

          public function search($date, $settings, $query_list, $fields, $date_field, $date_type, $result_type, $filter_range) {
      Severity: Major
      Found in phplib/Search/Elasticsearch.php - About 1 hr to fix

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

            public function isWorking($date) {
                $cfg = $this->getConfig();
                $client = ESClient::getClient($this->getClientConfigKey());
        
                $working = false;
        Severity: Minor
        Found in phplib/Search/Elasticsearch.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 constructQuery has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function constructQuery() {
                $query = Util::get($this->obj['query_data'], 'query');
                $fields = Util::get($this->obj['query_data'], 'fields', []);
                $parser = new \ESQuery\Parser;
                list($settings, $query_list) = $parser->parse($query);
        Severity: Minor
        Found in phplib/Search/Elasticsearch.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

        There are no issues that match your filters.

        Category
        Status