protected/modules/zendsearch/vendors/Zend/Search/Lucene/Index/Writer.php

Summary

Maintainability
F
5 days
Test Coverage

Function _updateSegments has a Cognitive Complexity of 129 (exceeds 5 allowed). Consider refactoring.
Open

    private function _updateSegments()
    {
        // Get an exclusive index lock
        Zend_Search_Lucene_LockManager::obtainWriteLock($this->_directory);

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

    private function _updateSegments()
    {
        // Get an exclusive index lock
        Zend_Search_Lucene_LockManager::obtainWriteLock($this->_directory);

    File Writer.php has 473 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

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

      Function _maybeMergeSegments has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          private function _maybeMergeSegments()
          {
              if (Zend_Search_Lucene_LockManager::obtainOptimizationLock($this->_directory) === false) {
                  return;
              }

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

          private function _maybeMergeSegments()
          {
              if (Zend_Search_Lucene_LockManager::obtainOptimizationLock($this->_directory) === false) {
                  return;
              }

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

            private function _hasAnythingToMerge()
            {
                $segmentSizes = [];
                foreach ($this->_segmentInfos as $segName => $segmentInfo) {
                    $segmentSizes[$segName] = $segmentInfo->count();

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

            private function _hasAnythingToMerge()
            {
                $segmentSizes = [];
                foreach ($this->_segmentInfos as $segName => $segmentInfo) {
                    $segmentSizes[$segName] = $segmentInfo->count();

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

              public static function createIndex(Zend_Search_Lucene_Storage_Directory $directory, $generation, $nameCount)
              {
                  if ($generation == 0) {
                      // Create index in pre-2.1 mode
                      foreach ($directory->fileList() as $file) {

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

                public static function createIndex(Zend_Search_Lucene_Storage_Directory $directory, $generation, $nameCount)
                {
                    if ($generation == 0) {
                        // Create index in pre-2.1 mode
                        foreach ($directory->fileList() as $file) {
            Severity: Minor
            Found in protected/modules/zendsearch/vendors/Zend/Search/Lucene/Index/Writer.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

            There are no issues that match your filters.

            Category
            Status