wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 718 of 718 total issues

Method searchTextInternal has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function searchTextInternal( $term ) {
        // Searcher needs to be cloned before any actual query building is done.
        $interleaveSearcher = $this->buildInterleaveSearcher();

        $qb = $this->buildFullTextSearch( $term );
Severity: Major
Found in includes/Searcher.php - About 2 hrs to fix

    Method execute has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function execute() {
            $this->disablePoolCountersAndLogging();
    
            $this->indexSuffix = $this->getBackCompatOption( 'indexSuffix', 'indexType' );
            $this->indexBaseName = $this->getOption( 'baseName',
    Severity: Major
    Found in maintenance/DumpIndex.php - About 2 hrs to fix

      Method mergeStatusWithChildren has 63 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function mergeStatusWithChildren( array $status, array $childResponse ) {
              foreach ( $childResponse['nodes'] as $nodeData ) {
                  foreach ( $nodeData['tasks'] as $taskId => $childData ) {
                      $sliceId = $childData['status']['slice_id'];
                      $status['slices'][$sliceId] = $childData['status'];
      Severity: Major
      Found in includes/Elastica/ReindexTask.php - About 2 hrs to fix

        Method extractFullError has 63 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function extractFullError( \Elastica\Exception\ExceptionInterface $exception ): array {
                if ( $exception instanceof BulkResponseException ) {
                    $actionReasons = [];
                    foreach ( $exception->getActionExceptions() as $actionException ) {
                        $actionReasons[] = $actionException->getMessage() . ': '
        Severity: Major
        Found in includes/ElasticaErrorHandler.php - About 2 hrs to fix

          Method extractMessageAndStatus has 63 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function extractMessageAndStatus( \Elastica\Exception\ExceptionInterface $exception = null ) {
                  if ( !$exception ) {
                      return [ Status::newFatal( 'cirrussearch-backend-error' ), '' ];
                  }
          
          
          Severity: Major
          Found in includes/ElasticaErrorHandler.php - About 2 hrs to fix

            File RequestLogger.php has 271 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            
            namespace CirrusSearch;
            
            use ISearchResultSet;
            Severity: Minor
            Found in includes/RequestLogger.php - About 2 hrs to fix

              SearchQueryBuilder has 23 functions (exceeds 20 allowed). Consider refactoring.
              Open

              final class SearchQueryBuilder {
              
                  /**
                   * @var ParsedQuery
                   */
              Severity: Minor
              Found in includes/Search/SearchQueryBuilder.php - About 2 hrs to fix

                BaseCirrusSearchResultSet has 23 functions (exceeds 20 allowed). Consider refactoring.
                Open

                abstract class BaseCirrusSearchResultSet extends BaseSearchResultSet implements CirrusSearchResultSet {
                    use SearchResultSetTrait;
                
                    /** @var bool */
                    private $hasMoreResults = false;
                Severity: Minor
                Found in includes/Search/BaseCirrusSearchResultSet.php - About 2 hrs to fix

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

                          try {
                              $this->requireCirrusReady();
                              $this->builder = SuggestBuilder::create( $this->getConnection(),
                                  $this->getOption( 'scoringMethod' ), $this->indexBaseName );
                              # check for broken indices and delete them
                  Severity: Major
                  Found in maintenance/UpdateSuggesterIndex.php and 1 other location - About 2 hrs to fix
                  maintenance/UpdateOneSearchIndexConfig.php on lines 237..300

                  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 131.

                  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

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

                          try {
                              $indexSuffixes = $this->getConnection()->getAllIndexSuffixes( null );
                              if ( !in_array( $this->indexSuffix, $indexSuffixes ) ) {
                                  $this->fatalError( 'indexSuffix option must be one of ' .
                                      implode( ', ', $indexSuffixes ) );
                  Severity: Major
                  Found in maintenance/UpdateOneSearchIndexConfig.php and 1 other location - About 2 hrs to fix
                  maintenance/UpdateSuggesterIndex.php on lines 209..235

                  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 131.

                  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

                  File SuggestBuilder.php has 270 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  <?php
                  
                  namespace CirrusSearch\BuildDocument\Completion;
                  
                  use CirrusSearch\Connection;
                  Severity: Minor
                  Found in includes/BuildDocument/Completion/SuggestBuilder.php - About 2 hrs to fix

                    Method sendWeightedTagsUpdate has 61 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function sendWeightedTagsUpdate(
                            string $indexSuffix,
                            string $tagPrefix,
                            array $tagWeights,
                            int $batchSize = 30
                    Severity: Major
                    Found in includes/DataSender.php - About 2 hrs to fix

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

                          public static function extractMessageAndStatus( \Elastica\Exception\ExceptionInterface $exception = null ) {
                              if ( !$exception ) {
                                  return [ Status::newFatal( 'cirrussearch-backend-error' ), '' ];
                              }
                      
                      
                      Severity: Minor
                      Found in includes/ElasticaErrorHandler.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 traceRedirects has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function traceRedirects( $title ) {
                              // Loop through redirects until we get to the ultimate target
                              $redirects = [];
                              $wikiPageFactory = MediaWikiServices::getInstance()->getWikiPageFactory();
                              while ( true ) {
                      Severity: Minor
                      Found in includes/Updater.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 doTitleSnippet has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private function doTitleSnippet( Title $title, \Elastica\Result $result, array $highlights ) {
                              $matched = false;
                              foreach ( $this->highligtedFields[ArrayCirrusSearchResult::TITLE_SNIPPET] as $hlField ) {
                                  if ( isset( $highlights[$hlField->getFieldName()] ) ) {
                                      $nstext = $title->getNamespace() === 0 ? '' : $this->titleHelper->getNamespaceText( $title ) . ':';
                      Severity: Minor
                      Found in includes/Search/FullTextCirrusSearchResultBuilder.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 getNamespaces has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function getNamespaces(): array {
                              $additionalRequired = null;
                              if ( $this->initialNamespaces != [] && $this->contextualFilters != [] ) {
                                  foreach ( $this->contextualFilters as $filter ) {
                                      $additional = $filter->requiredNamespaces();
                      Severity: Minor
                      Found in includes/Search/SearchQuery.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 enableICUFolding has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function enableICUFolding( array $config, $language ) {
                              $unicodeSetFilter = $this->getICUSetFilter( $language );
                              $filter = [
                                  'type' => 'icu_folding',
                              ];
                      Severity: Minor
                      Found in includes/Maintenance/AnalysisConfigBuilder.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 indexData has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private function indexData(): int {
                              // We build the suggestions by reading CONTENT and GENERAL indices.
                              // This does not support extra indices like FILES on commons.
                              $sourceIndexSuffixes = [ Connection::CONTENT_INDEX_SUFFIX, Connection::GENERAL_INDEX_SUFFIX ];
                      
                      
                      Severity: Minor
                      Found in maintenance/UpdateSuggesterIndex.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 execute has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function execute() {
                              $indexPattern = $this->getSearchConfig()->get( SearchConfig::INDEX_BASE_NAME ) . '_*';
                              $end = microtime( true ) + 60;
                              while ( true ) {
                                  try {
                      Severity: Minor
                      Found in maintenance/CirrusNeedsToBeBuilt.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 sendConfigDumpRequest has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function sendConfigDumpRequest( $endpoints ) {
                              $logger = LoggerFactory::getInstance( 'CirrusSearch' );
                              $reqs = [];
                              foreach ( $endpoints as $prefix => $info ) {
                                  $reqs[$prefix] = [
                      Severity: Major
                      Found in includes/BaseInterwikiResolver.php - About 2 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language