wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 718 of 718 total issues

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

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

                  public function buildFromParsedQuery( ParsedQuery $query ): AbstractQuery {
                      $visitor = new class( $query ) extends LeafVisitor {
                          public string $nearMatch;
              
                          public function __construct( ParsedQuery $query ) {
              Severity: Major
              Found in includes/Query/Builder/NearMatchFieldQueryBuilder.php - About 2 hrs to fix

                File SuggesterAnalysisConfigBuilder.php has 251 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                
                namespace CirrusSearch\Maintenance;
                
                /**
                Severity: Minor
                Found in includes/Maintenance/SuggesterAnalysisConfigBuilder.php - About 2 hrs to fix

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

                      public function detect( $text ) {
                          $dirs = $this->config->getElement( 'CirrusSearchTextcatModel' );
                          if ( !$dirs ) {
                              return null;
                          }
                  Severity: Minor
                  Found in includes/LanguageDetector/TextCat.php - About 2 hrs to fix

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

                        public function updateOtherIndex( $titles ) {
                            if ( !$this->connection->getConfig()->getElement( 'CirrusSearchWikimediaExtraPlugin', 'super_detect_noop' ) ) {
                                $this->logFailure( $titles, 'super_detect_noop plugin not enabled' );
                                return;
                            }
                    Severity: Minor
                    Found in includes/OtherIndexesUpdater.php - About 1 hr to fix

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

                          public function explain( array $doc ) {
                              $qualityExplain = $this->intermediateExplain( $doc );
                              $pop = $doc['popularity_score'] ?? 0;
                              if ( $pop > self::POPULARITY_MAX ) {
                                  $popExplain = [
                      Severity: Minor
                      Found in includes/BuildDocument/Completion/PQScore.php - About 1 hr to fix

                        Method customize has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private function customize( array $config, $language ) {
                                $defaultStopSet = $this->getDefaultStopSet( $language );
                                $config['filter']['stop_filter']['stopwords'] = $defaultStopSet;
                        
                                switch ( $this->getDefaultTextAnalyzerType( $language ) ) {
                        Severity: Minor
                        Found in includes/Maintenance/SuggesterAnalysisConfigBuilder.php - About 1 hr to fix

                          Function isProfileSyntaxSupported has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                          Open

                              private function isProfileSyntaxSupported( array $profile ) {
                                  if ( ( $profile['supported_syntax'] ?? [] ) !== [] ) {
                                      $supportedSyntax = false;
                                      foreach ( $profile['supported_syntax'] as $supported ) {
                                          if ( $this->context->isSyntaxUsed( $supported ) ) {
                          Severity: Minor
                          Found in includes/Search/Rescore/RescoreBuilder.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

                          Function parseValue has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function parseValue( $key, $value, $quotedValue, $valueDelimiter, $suffix, WarningCollector $warningCollector ) {
                                  $parsedValue = [];
                          
                                  $field = self::KEY_TABLE[$key];
                                  $parsedValue['field'] = $field;
                          Severity: Minor
                          Found in includes/Query/IndexedNumericFieldFeature.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

                          Function customize has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                          Open

                              private function customize( array $config, $language ) {
                                  $defaultStopSet = $this->getDefaultStopSet( $language );
                                  $config['filter']['stop_filter']['stopwords'] = $defaultStopSet;
                          
                                  switch ( $this->getDefaultTextAnalyzerType( $language ) ) {
                          Severity: Minor
                          Found in includes/Maintenance/SuggesterAnalysisConfigBuilder.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

                          Severity
                          Category
                          Status
                          Source
                          Language