protected/modules/zendsearch/vendors/Zend/Search/Lucene/Search/Query/Boolean.php

Summary

Maintainability
F
6 days
Test Coverage

Function optimize has a Cognitive Complexity of 101 (exceeds 5 allowed). Consider refactoring.
Open

    public function optimize(Zend_Search_Lucene_Interface $index)
    {
        $subqueries = [];
        $signs = [];

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 optimize has 179 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function optimize(Zend_Search_Lucene_Interface $index)
    {
        $subqueries = [];
        $signs = [];

    File Boolean.php has 455 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * Zend Framework
     *
     * LICENSE

      Function _calculateNonConjunctionResult has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          private function _calculateNonConjunctionResult()
          {
              $requiredVectors = [];
              $requiredVectorsSizes = [];
              $requiredVectorsIds = []; // is used to prevent arrays comparison

      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 _calculateConjunctionResult has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          private function _calculateConjunctionResult()
          {
              $this->_resVector = null;
      
              if (count($this->_subqueries) == 0) {

      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 _nonConjunctionScore has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public function _nonConjunctionScore($docId, Zend_Search_Lucene_Interface $reader)
          {
              if ($this->_coord === null) {
                  $this->_coord = [];
      
      

      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 _calculateNonConjunctionResult has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function _calculateNonConjunctionResult()
          {
              $requiredVectors = [];
              $requiredVectorsSizes = [];
              $requiredVectorsIds = []; // is used to prevent arrays comparison

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

            private function _calculateConjunctionResult()
            {
                $this->_resVector = null;
        
                if (count($this->_subqueries) == 0) {

          Function __construct has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public function __construct($subqueries = null, $signs = null)
              {
                  if (is_array($subqueries)) {
                      $this->_subqueries = $subqueries;
          
          

          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 _nonConjunctionScore has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function _nonConjunctionScore($docId, Zend_Search_Lucene_Interface $reader)
              {
                  if ($this->_coord === null) {
                      $this->_coord = [];
          
          

            Function execute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public function execute(Zend_Search_Lucene_Interface $reader, $docsFilter = null)
                {
                    // Initialize weight if it's not done yet
                    $this->_initWeight($reader);
            
            

            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 __toString has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public function __toString()
                {
                    // It's used only for query visualisation, so we don't care about characters escaping
            
                    $query = '';

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

                public function addSubquery(Zend_Search_Lucene_Search_Query $subquery, $sign = null)
                {
                    if ($sign !== true || $this->_signs !== null) { // Skip, if all subqueries are required
                        if ($this->_signs === null) { // Check, If all previous subqueries are required
                            $this->_signs = [];

            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 reset($subqueries);

              Avoid too many return statements within this method.
              Open

                      return $optimizedQuery;

                Avoid too many return statements within this method.
                Open

                            return $optimizedQuery;

                  Avoid too many return statements within this method.
                  Open

                              return $optimizedQuery;

                    Avoid too many return statements within this method.
                    Open

                                return new Zend_Search_Lucene_Search_Query_Empty();

                      Avoid too many return statements within this method.
                      Open

                                  return $optimizedQuery;

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                            public function addSubquery(Zend_Search_Lucene_Search_Query $subquery, $sign = null)
                            {
                                if ($sign !== true || $this->_signs !== null) { // Skip, if all subqueries are required
                                    if ($this->_signs === null) { // Check, If all previous subqueries are required
                                        $this->_signs = [];
                        protected/modules/zendsearch/vendors/Zend/Search/Lucene/Search/Query/MultiTerm.php on lines 136..149

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 113.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Identical blocks of code found in 2 locations. Consider refactoring.
                        Open

                                foreach ($resVectors as $nextResVector) {
                                    if ($this->_resVector === null) {
                                        $this->_resVector = $nextResVector;
                                    } else {
                                        //$this->_resVector = array_intersect_key($this->_resVector, $nextResVector);
                        protected/modules/zendsearch/vendors/Zend/Search/Lucene/Search/Query/Phrase.php on lines 446..468

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 100.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Identical blocks of code found in 2 locations. Consider refactoring.
                        Open

                                if ($this->_coord === null) {
                                    $this->_coord = [];
                        
                                    $maxCoord = 0;
                                    foreach ($this->_signs as $sign) {
                        protected/modules/zendsearch/vendors/Zend/Search/Lucene/Search/Query/MultiTerm.php on lines 506..519

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 99.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Identical blocks of code found in 2 locations. Consider refactoring.
                        Open

                                foreach ($requiredVectors as $nextResVector) {
                                    if ($required === null) {
                                        $required = $nextResVector;
                                    } else {
                                        //$required = array_intersect_key($required, $nextResVector);
                        protected/modules/zendsearch/vendors/Zend/Search/Lucene/Search/Query/MultiTerm.php on lines 410..432

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 90.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        There are no issues that match your filters.

                        Category
                        Status