wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 691 of 718 total issues

Method fromSearchQuery has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function fromSearchQuery(
        SearchQuery $query,
        FallbackRunner $fallbackRunner = null,
        CirrusSearchHookRunner $cirrusSearchHookRunner = null
    ): SearchContext {
Severity: Minor
Found in includes/Search/SearchContext.php - About 1 hr to fix

    Method run has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function run(
            SearcherFactory $factory,
            CirrusSearchResultSet $initialResult,
            MSearchResponses $responses,
            NamespacePrefixParser $namespacePrefixParser,
    Severity: Minor
    Found in includes/Fallbacks/FallbackRunner.php - About 1 hr to fix

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

          public function execute() {
              $this->disablePoolCountersAndLogging();
              $profiles = [];
              $profileService = $this->getSearchConfig()->getProfileService();
              if ( $this->hasOption( 'profile' ) ) {
      Severity: Minor
      Found in maintenance/UpdateDYMIndexTemplates.php - About 1 hr to fix

        Method sendDeletes has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function sendDeletes( $docIds, $indexSuffix = null ) {
                if ( $indexSuffix === null ) {
                    $indexes = $this->connection->getAllIndexSuffixes( Connection::PAGE_DOC_TYPE );
                } else {
                    $indexes = [ $indexSuffix ];
        Severity: Minor
        Found in includes/DataSender.php - About 1 hr to fix

          Method interleaveResults has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function interleaveResults( $a, $b, $limit ) {
                  $interleaved = [];
                  $teamA = [];
                  $teamB = [];
                  $aIds = array_combine( array_keys( $a ), array_keys( $a ) );
          Severity: Minor
          Found in includes/Search/TeamDraftInterleaver.php - About 1 hr to fix

            Method postProcess has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function postProcess( CompletionResultsCollector $collector, ResultSet $results, $indexName ) {
                    $suggestResp = $results->getSuggests();
                    if ( $suggestResp === [] ) {
                        // Edge case where the index contains 0 documents and does not even return the 'suggest' field
                        return 0;
            Severity: Minor
            Found in includes/Query/CompSuggestQueryBuilder.php - About 1 hr to fix

              Method finalizeReal has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function finalizeReal(
                      Document $doc,
                      WikiPage $page,
                      CirrusSearch $engine,
                      RevisionRecord $revision
              Severity: Minor
              Found in includes/BuildDocument/ParserOutputPageProperties.php - About 1 hr to fix

                Method execute has 40 lines of code (exceeds 25 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 1 hr to fix

                  Method getDeletesIterator has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function getDeletesIterator() {
                          $dbr = $this->getDB( DB_REPLICA, [ 'vslow' ] );
                          $it = new BatchRowIterator(
                              $dbr,
                              'logging',
                  Severity: Minor
                  Found in maintenance/ForceSearchIndex.php - About 1 hr to fix

                    Function getCompiledReplacements has a Cognitive Complexity of 13 (exceeds 5 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

                    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 sendOtherIndexUpdates has a Cognitive Complexity of 13 (exceeds 5 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: Minor
                    Found in includes/DataSender.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 isProfileNamespaceSupported has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function isProfileNamespaceSupported( array $profile ) {
                            if ( !is_array( $profile['supported_namespaces'] ) ) {
                                switch ( $profile['supported_namespaces'] ) {
                                    case 'all':
                                        return true;
                    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 transformOneElasticResult has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function transformOneElasticResult( \Elastica\Result $r, array $namespaces = [] ) {
                            $title = $this->getTitleHelper()->makeTitle( $r );
                            $highlights = $r->getHighlights();
                            $resultForTitle = [];
                    
                    
                    Severity: Minor
                    Found in includes/Search/FancyTitleResultsType.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 pushAnalyzerAliasesIntoField has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function pushAnalyzerAliasesIntoField( array $properties, array $aliases ) {
                            foreach ( $properties as &$config ) {
                                foreach ( self::$ANALYZER_FIELDS as $key ) {
                                    if ( isset( $config[$key] ) && isset( $aliases[$config[$key]] ) ) {
                                        $config[$key] = $aliases[$config[$key]];
                    Severity: Minor
                    Found in includes/Maintenance/AnalysisFilter.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 apply has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function apply( SearchContext $context, $term ) {
                            $keyListRegex = implode(
                                '|',
                                array_map(
                                    static function ( $kw ) {
                    Severity: Minor
                    Found in includes/Query/SimpleKeywordFeature.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 getPageIdentities has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function getPageIdentities() {
                            if ( $this->hasOption( 'page' ) ) {
                                $pageName = $this->getOption( 'page' );
                                $title = Title::newFromText( $pageName );
                                if ( !$title ) {
                    Severity: Minor
                    Found in maintenance/UpdateWeightedTags.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 recycle has a Cognitive Complexity of 13 (exceeds 5 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: Minor
                    Found in maintenance/UpdateSuggesterIndex.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

                    Method decideClusters has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function decideClusters( string $updateGroup ) {
                            $params = $this->getParams();
                            $searchConfig = $this->getSearchConfig();
                            $jobType = $this->getType();
                    
                    
                    Severity: Minor
                    Found in includes/Job/JobTraits.php - About 1 hr to fix

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

                          public function __construct( SearchConfig $config, $requestedNamespaces, $localSearch, $withDefaultBoosts, $weight ) {
                              parent::__construct( $config, $weight );
                              // Use the boosted templates from extra indexes if available
                              $queries = [];
                              $weights = [];
                      Severity: Minor
                      Found in includes/Search/Rescore/BoostTemplatesFunctionScoreBuilder.php - About 1 hr to fix

                        Method validateParams has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private function validateParams() {
                                $pageOptionCount = (int)$this->hasOption( 'page' ) + (int)$this->hasOption( 'page-list' )
                                    + (int)$this->hasOption( 'pageid-list' );
                                if ( $pageOptionCount !== 1 ) {
                                    $this->fatalError( "Exactly one of --page, --page-list and --pageid-list must be used" );
                        Severity: Minor
                        Found in maintenance/UpdateWeightedTags.php - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language