gdbots/query-parser-php

View on GitHub
src/Builder/ElasticaQueryBuilder.php

Summary

Maintainability
D
2 days
Test Coverage

File ElasticaQueryBuilder.php has 353 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
declare(strict_types=1);

namespace Gdbots\QueryParser\Builder;

Severity: Minor
Found in src/Builder/ElasticaQueryBuilder.php - About 4 hrs to fix

    Function handleRange has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function handleRange(Range $range, Field $field, bool $cacheable = false): void
        {
            $useBoost = $field->useBoost();
            $boost = $field->getBoost();
            $boolOp = $field->getBoolOperator();
    Severity: Minor
    Found in src/Builder/ElasticaQueryBuilder.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

    ElasticaQueryBuilder has 24 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class ElasticaQueryBuilder extends AbstractQueryBuilder
    {
        protected RuflinQueryBuilder $qb;
        protected BoolQuery $boolQuery;
    
    
    Severity: Minor
    Found in src/Builder/ElasticaQueryBuilder.php - About 2 hrs to fix

      Function addTextToQuery has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function addTextToQuery(string $method, Node $node, ?Field $field = null): void
          {
              if ($node instanceof Word && $node->isStopWord() && $this->ignoreStopWords) {
                  return;
              }
      Severity: Minor
      Found in src/Builder/ElasticaQueryBuilder.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 addTermToQuery has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function addTermToQuery(string $method, Node $node, ?Field $field = null, bool $cacheable = false): void
          {
              if ($node instanceof Emoji && $this->ignoreEmojis) {
                  return;
              }
      Severity: Minor
      Found in src/Builder/ElasticaQueryBuilder.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 addTextToQuery has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function addTextToQuery(string $method, Node $node, ?Field $field = null): void
          {
              if ($node instanceof Word && $node->isStopWord() && $this->ignoreStopWords) {
                  return;
              }
      Severity: Major
      Found in src/Builder/ElasticaQueryBuilder.php - About 2 hrs to fix

        Method handleRange has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function handleRange(Range $range, Field $field, bool $cacheable = false): void
            {
                $useBoost = $field->useBoost();
                $boost = $field->getBoost();
                $boolOp = $field->getBoolOperator();
        Severity: Minor
        Found in src/Builder/ElasticaQueryBuilder.php - About 2 hrs to fix

          Method addTermToQuery has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function addTermToQuery(string $method, Node $node, ?Field $field = null, bool $cacheable = false): void
              {
                  if ($node instanceof Emoji && $this->ignoreEmojis) {
                      return;
                  }
          Severity: Minor
          Found in src/Builder/ElasticaQueryBuilder.php - About 1 hr to fix

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

                protected function endSubquery(Subquery $subquery, ?Field $field = null): void
                {
                    $params = $this->boolQuery->getParams();
                    if (!empty($params)) {
                        $this->boolQuery->setMinimumShouldMatch(1);
            Severity: Minor
            Found in src/Builder/ElasticaQueryBuilder.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

            There are no issues that match your filters.

            Category
            Status