wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 691 of 718 total issues

Function loadConfigFromAPI has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    private function loadConfigFromAPI( $wikis, array $hashConfigFlags, $fallbackConfig ) {
        $endpoints = [];
        foreach ( $wikis as $prefix => $wiki ) {
            $iw = $this->interwikiLookup->fetch( $prefix );
            if ( !$iw || !$this->useConfigDumpApi || !$iw->isLocal() ) {
Severity: Minor
Found in includes/BaseInterwikiResolver.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 buildTagWeightsFromLegacyParameters has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    public static function buildTagWeightsFromLegacyParameters( $tagNames = null, $tagWeights = null ) {
        Assert::parameterType(
            [
                'string',
                'array',
Severity: Minor
Found in includes/Extra/MultiList/MultiListBuilder.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 getOverriddenFactor has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getOverriddenFactor( $value ) {
        if ( is_array( $value ) ) {
            $returnValue = (float)$value['value'];

            if ( isset( $value['config_override'] ) ) {
Severity: Minor
Found in includes/Search/Rescore/FunctionScoreBuilder.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 __construct has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct( SearchConfig $config, $weight, $profile ) {
        parent::__construct( $config, $weight );

        if ( isset( $profile['impact'] ) ) {
            $this->impact = $this->getOverriddenFactor( $profile['impact'] );
Severity: Minor
Found in includes/Search/Rescore/GeoMeanFunctionScoreBuilder.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 getSupportedProfile has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    private function getSupportedProfile( $profileName ) {
        $profile = $this->context->getConfig()
            ->getProfileService()
            ->loadProfileByName( SearchProfileService::RESCORE, $profileName );
        if ( !is_array( $profile ) ) {
Severity: Minor
Found in includes/Search/Rescore/RescoreBuilder.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 explain has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def explain(
        self,
        problem: Problem,
        es_state: Mapping[Tuple[str, str], ElasticsearchState],
    ) -> Optional[str]:
Severity: Minor
Found in scripts/check_indices.py - 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 17 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $this->disablePoolCountersAndLogging();

        $this->indexSuffix = $this->getBackCompatOption( 'indexSuffix', 'indexType' );
        $this->indexBaseName = $this->getOption( 'baseName',
Severity: Minor
Found in maintenance/DumpIndex.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 recycle has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function recycle() {
        $this->log( "Recycling index {$this->getIndex()->getName()}\n" );
        $this->recycle = true;
        $indexedDocs = $this->indexData();
        // This is fragile... hopefully most of the docs will be deleted from the old segments
Severity: Major
Found in maintenance/UpdateSuggesterIndex.php - About 2 hrs to fix

    Method __construct has 17 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            ParsedQuery $parsedQuery,
            array $initialNamespaces,
            CrossSearchStrategy $initialCrosswikiStrategy,
            array $contextualFilters,
            $searchEngineEntryPoint,
    Severity: Major
    Found in includes/Search/SearchQuery.php - About 2 hrs to fix

      Method sendOtherIndexUpdates has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function sendOtherIndexUpdates( $localSite, $indexName, array $otherActions, $batchSize = 30 ) {
              $client = $this->connection->getClient();
              $status = Status::newGood();
              foreach ( array_chunk( $otherActions, $batchSize ) as $updates ) {
                  '@phan-var array[] $updates';
      Severity: Major
      Found in includes/DataSender.php - About 2 hrs to fix

        File ElasticaErrorHandler.php has 255 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        namespace CirrusSearch;
        
        use Elastica\Exception\Bulk\ResponseException as BulkResponseException;
        Severity: Minor
        Found in includes/ElasticaErrorHandler.php - About 2 hrs to fix

          Function sendWeightedTagsUpdate has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              public function sendWeightedTagsUpdate(
                  string $indexSuffix,
                  string $tagPrefix,
                  array $tagWeights,
                  int $batchSize = 30
          Severity: Minor
          Found in includes/DataSender.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 searchTextReal has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function searchTextReal( SearchQuery $query ) {
                  $searcher = $this->makeSearcher( $query->getSearchConfig() );
                  $status = $searcher->search( $query );
                  $this->lastSearchMetrics = $searcher->getSearchMetrics();
                  if ( !$status->isOK() ) {
          Severity: Minor
          Found in includes/CirrusSearch.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 enableGlobalCustomFilters has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function enableGlobalCustomFilters( array $config, string $language,
                      array $customFilters, array $installedPlugins ) {
                  foreach ( $customFilters as $filterName => $gcfInfo ) {
                      if ( !$gcfInfo->languageCheck( $language ) ) {
                          continue;
          Severity: Minor
          Found in includes/Maintenance/GlobalCustomFilter.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 mergeConfig has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              private function mergeConfig( array &$config, array $langConfig, $name, $prefix ) {
                  $analyzer = $langConfig[ 'analyzer' ][ $name ];
                  $config[ 'analyzer' ][ $prefix . '_' . $name ] = $analyzer;
                  if ( !empty( $analyzer[ 'filter' ] ) ) {
                      // Add private filters for this analyzer
          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 monitorReindexTask has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              private function monitorReindexTask( ReindexTask $task, Index $target ) {
                  $consecutiveErrors = 0;
                  $sleepSeconds = self::monitorSleepSeconds( 1, 2, self::MONITOR_SLEEP_SECONDS );
                  $completionEstimateGen = self::estimateTimeRemaining();
                  while ( !$task->isComplete() ) {
          Severity: Minor
          Found in includes/Maintenance/Reindexer.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 transformElasticsearchResult has 52 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function transformElasticsearchResult( ElasticaResultSet $result ) {
                  // Should we make this a concrete class?
                  return new class(
                      $this->titleHelper,
                      $this->fetchPhaseBuilder,
          Severity: Major
          Found in includes/Search/FullTextResultsType.php - About 2 hrs to fix

            Method reindex has 52 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function reindex(
                    $slices = null,
                    $chunkSize = 100,
                    $acceptableCountDeviation = 0.05
                ) {
            Severity: Major
            Found in includes/Maintenance/Reindexer.php - About 2 hrs to fix

              Method canRecycle has 52 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function canRecycle() {
                      global $wgCirrusSearchRecycleCompletionSuggesterIndex;
                      if ( !$wgCirrusSearchRecycleCompletionSuggesterIndex ) {
                          return false;
                      }
              Severity: Major
              Found in maintenance/UpdateSuggesterIndex.php - About 2 hrs to fix

                Method buildTagWeightsFromLegacyParameters has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function buildTagWeightsFromLegacyParameters( $tagNames = null, $tagWeights = null ) {
                        Assert::parameterType(
                            [
                                'string',
                                'array',
                Severity: Major
                Found in includes/Extra/MultiList/MultiListBuilder.php - About 2 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language