wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 718 of 718 total issues

Method loadDocuments has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function loadDocuments( PageIdentity $title, $sourceFiltering = true ) {
        [ $docId, $hasRedirects ] = $this->determineCirrusDocId( $title );
        if ( $docId === null ) {
            return [];
        }
Severity: Minor
Found in includes/Api/ApiTrait.php - About 1 hr to fix

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

        private function __construct( $repoType, $repoName, SearchConfig $config, callable $arrayLoader ) {
            $this->wrapped = ArrayProfileRepository::lazyLoaded( $repoType, $repoName, static function () use ( $arrayLoader, $config ) {
                $profiles = [];
    
                $allowedFields = [ 'suggest' => true, 'suggest-stop' => true ];
    Severity: Minor
    Found in includes/Profile/CompletionSearchProfileRepository.php - About 1 hr to fix

      Method bulkResponseExceptionIsJustDocumentMissing has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function bulkResponseExceptionIsJustDocumentMissing(
              ResponseException $exception, $logCallback = null
          ) {
              $justDocumentMissing = true;
              foreach ( $exception->getResponseSet()->getBulkResponses() as $bulkResponse ) {
      Severity: Minor
      Found in includes/DataSender.php - About 1 hr to fix

        Method upgradeIndexVersion has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function upgradeIndexVersion() {
                $pluginsStatus = $this->configUtils->scanAvailableModules();
                if ( !$pluginsStatus->isGood() ) {
                    throw new \RuntimeException( (string)$pluginsStatus );
                }
        Severity: Minor
        Found in includes/MetaStore/MetaStoreIndex.php - About 1 hr to fix

          Method buildDocument has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function buildDocument( Connection $connection, $baseName, $typeName ) {
                  global $IP;
                  if ( $typeName == Connection::TITLE_SUGGEST_INDEX_SUFFIX ) {
                      [ $aMaj, $aMin ] = explode( '.', SuggesterAnalysisConfigBuilder::VERSION, 3 );
                      [ $mMaj, $mMin ] = explode( '.', SuggesterMappingConfigBuilder::VERSION, 3 );
          Severity: Minor
          Found in includes/MetaStore/MetaVersionStore.php - About 1 hr to fix

            Method searchArchive has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function searchArchive( $term ) {
                    $this->searchContext->setOriginalSearchTerm( $term );
                    $term = $this->searchContext->escaper()->fixupWholeQueryString( $term );
                    $this->setResultsType( new TitleResultsType() );
            
            
            Severity: Minor
            Found in includes/Searcher.php - About 1 hr to fix

              Method getMapping has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getMapping( SearchEngine $engine ) {
                      if ( !( $engine instanceof CirrusSearch ) ) {
                          throw new \LogicException( "Cannot map CirrusSearch fields for another engine." );
                      }
                      $this->initFlags();
              Severity: Minor
              Found in includes/Search/SourceTextIndexField.php - About 1 hr to fix

                Method getSearchRequest has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function getSearchRequest( Client $client ) {
                        $fixablePart = $this->queryFixer->getFixablePart();
                        if ( $fixablePart === null ) {
                            return null;
                        }
                Severity: Minor
                Found in includes/Fallbacks/IndexLookupFallbackMethod.php - About 1 hr to fix

                  Method toArray has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function toArray() {
                          $output = [
                              'type' => $this->highlighterType
                          ];
                  
                  
                  Severity: Minor
                  Found in includes/Search/Fetch/BaseHighlightedField.php - About 1 hr to fix

                    Method extractResponseVariables has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function extractResponseVariables( $responseData ) {
                            if ( !is_array( $responseData ) ) {
                                // No known offenders, but just in case...
                                return [];
                            }
                    Severity: Minor
                    Found in includes/SearchRequestLog.php - About 1 hr to fix

                      Method format has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function format( array $queryResult ) {
                              $result = [];
                              if ( isset( $queryResult['result']['hits']['hits'] ) ) {
                                  $queryResult = [ $queryResult ];
                              }
                      Severity: Minor
                      Found in includes/ExplainPrinter.php - About 1 hr to fix

                        Method getValueRegex has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private function getValueRegex() {
                                Assert::invariant( $this->hasValue(), __METHOD__ . ' called but hasValue() is false' );
                                if ( $this->greedy() ) {
                                    Assert::precondition( !$this->allowEmptyValue(), "greedy keywords must not accept empty value" );
                                    // XXX: we ignore value delimiter for greedy keywords
                        Severity: Minor
                        Found in includes/Query/SimpleKeywordFeature.php - About 1 hr to fix

                          Method toArray has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function toArray() {
                                  $ar = [
                                      'query' => $this->query,
                                      'rawQuery' => $this->rawQuery
                                  ];
                          Severity: Minor
                          Found in includes/Parser/AST/ParsedQuery.php - About 1 hr to fix

                            Method initProfile has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                private function initProfile() {
                                    $res = $this->getDB( DB_REPLICA )
                                        ->newSelectQueryBuilder()
                                        ->select( [ 'min_id' => 'MIN(page_id)', 'max_id' => 'MAX(page_id)' ] )
                                        ->table( 'page' )
                            Severity: Minor
                            Found in maintenance/SaneitizeJobs.php - About 1 hr to fix

                              Method validateSpecificAlias has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  private function validateSpecificAlias() {
                                      $connection = $this->getConnection();
                              
                                      $fieldsToCleanup = array_filter( explode( ',', $this->getOption( 'fieldsToDelete', '' ) ) );
                                      $fieldsToCleanup = array_merge( $fieldsToCleanup, $this->getSearchConfig()->get( "CirrusSearchIndexFieldsToCleanup" ) );
                              Severity: Minor
                              Found in maintenance/UpdateOneSearchIndexConfig.php - About 1 hr to fix

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

                                    public function execute() {
                                        $this->indexSuffix = $this->getOption( 'indexSuffix' );
                                        $this->indexBaseName = $this->getOption( 'baseName',
                                            $this->getSearchConfig()->get( SearchConfig::INDEX_BASE_NAME ) );
                                
                                
                                Severity: Minor
                                Found in maintenance/CopySearchIndex.php - About 1 hr to fix

                                  Function listExposedProfiles has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      public function listExposedProfiles( $type ) {
                                          $profiles = [];
                                          if ( isset( $this->repositories[$type] ) ) {
                                              foreach ( $this->repositories[$type] as $repo ) {
                                                  foreach ( $repo->listExposedProfiles() as $name => $profile ) {
                                  Severity: Minor
                                  Found in includes/Profile/SearchProfileService.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 getProfileName has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      public function getProfileName( $type, $context = self::CONTEXT_DEFAULT, array $contextParams = [] ) {
                                          $minPrio = PHP_INT_MAX;
                                          if ( !isset( $this->defaultProfiles[$type][$context] ) ) {
                                              throw new SearchProfileException( "No default profile found for $type in context $context" );
                                          }
                                  Severity: Minor
                                  Found in includes/Profile/SearchProfileService.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 collectPrefixSearchResults has a Cognitive Complexity of 10 (exceeds 5 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

                                  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 10 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      public function __construct( SearchConfig $config, $weight, $profile ) {
                                          parent::__construct( $config, $weight );
                                          if ( isset( $profile['k'] ) ) {
                                              $this->k = $this->getOverriddenFactor( $profile['k'] );
                                              if ( $this->k <= 0 ) {
                                  Severity: Minor
                                  Found in includes/Search/Rescore/SatuFunctionScoreBuilder.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