wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 718 of 718 total issues

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

    public function onView() {
        // Disable regular results
        $this->getOutput()->disable();

        $response = $this->getRequest()->response();
Severity: Minor
Found in includes/Dump.php - About 1 hr to fix

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

        public function bestRoute( SearchQuery $query ): SearchQueryRoute {
            Assert::parameter( isset( $this->routes[$query->getSearchEngineEntryPoint()] ), 'query',
                "Unsupported search engine entry point {$query->getSearchEngineEntryPoint()}" );
    
            $routes = $this->routes[$query->getSearchEngineEntryPoint()];
    Severity: Minor
    Found in includes/Dispatch/DefaultSearchQueryDispatchService.php - About 1 hr to fix

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

          private function getPrefixSearchRequest( $term, $variants ) {
              $namespaces = $this->searchContext->getNamespaces();
              if ( $namespaces === null ) {
                  return null;
              }
      Severity: Minor
      Found in includes/CompletionSuggester.php - About 1 hr to fix

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

            private function collectPrefixSearchResults( CompletionResultsCollector $collector, array $results, CompletionRequestLog $log ) {
                if ( !isset( $results[self::MSEARCH_KEY_PREFIX] ) ) {
                    return 0;
                }
                $indexName = $this->prefixSearchRequestBuilder->getIndex()->getName();
        Severity: Minor
        Found in includes/CompletionSuggester.php - About 1 hr to fix

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

              private function pickTextSnippet( $highlights ) {
                  // This can get skipped if there the page was sent to Elasticsearch without text.
                  // This could be a bug or it could be that the page simply doesn't have any text.
                  $mainSnippet = '';
                  // Prefer source_text.plain it's likely a regex
          Severity: Minor
          Found in includes/Search/Result.php - About 1 hr to fix

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

                public function collect( SearchSuggestion $suggestion, $profileName, $index ) {
                    if ( !$this->canCollect( $suggestion->getSuggestedTitleID(), $suggestion->getScore() ) ) {
                        return false;
                    }
            
            
            Severity: Minor
            Found in includes/Search/CompletionResultsCollector.php - About 1 hr to fix

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

                  private function finishRequest( Connection $connection ) {
                      if ( !$this->currentRequestLog ) {
                          LoggerFactory::getInstance( 'CirrusSearch' )->warning(
                              'finishRequest called without staring a request'
                          );
              Severity: Minor
              Found in includes/ElasticsearchIntermediary.php - About 1 hr to fix

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

                    public function parseValue( $key, $value, $quotedValue, $valueDelimiter, $suffix, WarningCollector $warningCollector ) {
                        $values = explode( '|', $value, self::MAX_CONDITIONS + 1 );
                        if ( count( $values ) > self::MAX_CONDITIONS ) {
                            $warningCollector->addWarning(
                                'cirrussearch-feature-too-many-conditions',
                Severity: Minor
                Found in includes/Query/HasTemplateFeature.php - About 1 hr to fix

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

                      private function internalParseValue( $value ) {
                          $trimQuote = '/^"([^"]*)"\s*$/';
                          $value = preg_replace( $trimQuote, "$1", $value );
                          // NS_MAIN by default
                          $namespaces = [ NS_MAIN ];
                  Severity: Minor
                  Found in includes/Query/PrefixFeature.php - About 1 hr to fix

                    Method __construct has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function __construct( SearchConfig $config = null,
                            CirrusDebugOptions $debugOptions = null,
                            NamespacePrefixParser $namespacePrefixParser = null,
                            InterwikiResolver $interwikiResolver = null, TitleHelper $titleHelper = null
                        ) {
                    Severity: Minor
                    Found in includes/CirrusSearch.php - About 1 hr to fix

                      Method score has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function score( \CirrusSearch\Search\SearchQuery $query ) {
                              Assert::parameter( $query->getSearchEngineEntryPoint() === $this->searchEngineEntryPoint,
                                  'query',
                                  "must be {$this->searchEngineEntryPoint} but {$query->getSearchEngineEntryPoint()} given." );
                      
                      
                      Severity: Minor
                      Found in includes/Dispatch/BasicSearchQueryRoute.php - About 1 hr to fix

                        Method getCompiledReplacements has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private function getCompiledReplacements() {
                                if ( $this->compiledReplacements === null ) {
                                    $this->compiledReplacements = [];
                                    foreach ( $this->replacements as $repl => $value ) {
                                        if ( !is_string( $repl ) ) {
                        Severity: Minor
                        Found in includes/Profile/ArrayPathSetter.php - About 1 hr to fix

                          Method checkConfig has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              protected function checkConfig( $actual, array $required, $indent = null ) {
                                  foreach ( $required as $key => $value ) {
                                      $this->debugCheckConfig( "\n$indent$key: " );
                                      if ( !array_key_exists( $key, $actual ) ) {
                                          $this->debugCheckConfig( "not found..." );
                          Severity: Minor
                          Found in includes/Maintenance/Validators/Validator.php - About 1 hr to fix

                            Method getOnWikiBoostTemplates has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                private static function getOnWikiBoostTemplates( SearchConfig $config ) {
                                    $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
                                    $cacheKey = $cache->makeGlobalKey( 'cirrussearch-boost-templates', $config->getWikiId() );
                                    if ( $config->getWikiId() == WikiMap::getCurrentWikiId() ) {
                                        // Local wiki we can fetch boost templates from system
                            Severity: Minor
                            Found in includes/Util.php - About 1 hr to fix

                              Method parseValue has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function parseValue( $key, $value, $quotedValue, $valueDelimiter, $suffix, WarningCollector $warningCollector ) {
                                      // en:Programming|id:3041512\
                                      $categories = explode( '|', $value );// en:programming
                                      if ( count( $categories ) > $this->maxConditions ) {
                                          $warningCollector->addWarning(
                              Severity: Minor
                              Found in includes/Query/InCategoryFeature.php - About 1 hr to fix

                                Method resize has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public function resize( Document $document ): array {
                                        $this->stats = [];
                                        $this->document = $document;
                                        $originalDocLength = self::estimateDataSize( $document );
                                        $this->docLength = $originalDocLength;
                                Severity: Minor
                                Found in includes/BuildDocument/DocumentSizeLimiter.php - About 1 hr to fix

                                  Consider simplifying this complex logical expression.
                                  Open

                                                  if ( $optVal === null || $optVal === false || $optName === 'fromId' ||
                                                      $optName === 'toId' || $optName === 'buildChunks' ||
                                                      ( $optName === 'memory-limit' && $optVal === 'max' )
                                                  ) {
                                                      continue;
                                  Severity: Major
                                  Found in includes/Maintenance/ChunkBuilder.php - About 1 hr to fix

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

                                            ParsedNode $root,
                                            $query,
                                            $rawQuery,
                                            $queryCleanups,
                                            ?NamespaceHeaderNode $namespaceHeader,
                                    Severity: Major
                                    Found in includes/Parser/AST/ParsedQuery.php - About 1 hr to fix

                                      Consider simplifying this complex logical expression.
                                      Open

                                              if ( $this->hasComplex ) {
                                                  $classes[] = self::COMPLEX_QUERY;
                                                  // @phan-suppress-next-line PhanSuspiciousValueComparison
                                              } elseif ( $this->maxDepth === 0 && $this->hasWords && !$this->hasSimplePhrase ) {
                                                  $classes[] = self::SIMPLE_BAG_OF_WORDS;
                                      Severity: Major
                                      Found in includes/Parser/BasicQueryClassifier.php - About 1 hr to fix

                                        Method onPageUndeleteComplete has 8 arguments (exceeds 4 allowed). Consider refactoring.
                                        Open

                                                ProperPageIdentity $page,
                                                Authority $restorer,
                                                string $reason,
                                                RevisionRecord $restoredRev,
                                                ManualLogEntry $logEntry,
                                        Severity: Major
                                        Found in includes/ArchiveChangeListener.php - About 1 hr to fix
                                          Severity
                                          Category
                                          Status
                                          Source
                                          Language