wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 718 of 718 total issues

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

    public function __construct() {
        parent::__construct();
        $this->addDescription( "Force indexing some pages.  Setting --from or --to will switch "
            . "from page id based indexing to "
            . "date based indexing which uses less efficient queries and follows redirects.\n\n"
Severity: Major
Found in maintenance/ForceSearchIndex.php - About 2 hrs to fix

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

        public function execute() {
            global $wgLanguageCode,
                $wgCirrusSearchBannedPlugins,
                $wgCirrusSearchMasterTimeout;
    
    
    Severity: Major
    Found in maintenance/UpdateSuggesterIndex.php - About 2 hrs to fix

      Method truncateField has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function truncateField( string $field, bool $keyword, int $minFieldLength, int $maxDocSize, string $statBucket ): void {
              if ( !$this->document->has( $field ) ) {
                  return;
              }
              $fieldData = $this->document->get( $field );
      Severity: Major
      Found in includes/BuildDocument/DocumentSizeLimiter.php - About 2 hrs to fix

        File MetaStoreIndex.php has 264 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        namespace CirrusSearch\MetaStore;
        
        use CirrusSearch\Connection;
        Severity: Minor
        Found in includes/MetaStore/MetaStoreIndex.php - About 2 hrs to fix

          SearchQuery has 22 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class SearchQuery {
              /**
               * Identifier for the fulltext SearchEngine entry point
               * @see \SearchEngine::searchText()
               */
          Severity: Minor
          Found in includes/Search/SearchQuery.php - About 2 hrs to fix

            Util has 22 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class Util {
                /**
                 * Cache getDefaultBoostTemplates()
                 *
                 * @var array|null boost templates
            Severity: Minor
            Found in includes/Util.php - About 2 hrs to fix

              Method getImplementation has 58 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function getImplementation( $func ) {
                      $weight = $func['weight'] ?? 1;
                      $config = $this->context->getConfig();
                      switch ( $func['type'] ) {
                          case 'boostlinks':
              Severity: Major
              Found in includes/Search/Rescore/FunctionScoreChain.php - About 2 hrs to fix

                Method overrideMoreLikeThisOptionsFromMessage has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private static function overrideMoreLikeThisOptionsFromMessage() {
                        global $wgCirrusSearchMoreLikeThisConfig,
                            $wgCirrusSearchMoreLikeThisAllowedFields,
                            $wgCirrusSearchMoreLikeThisMaxQueryTermsLimit,
                            $wgCirrusSearchMoreLikeThisFields;
                Severity: Major
                Found in includes/Hooks.php - About 2 hrs to fix

                  Method buildExpQuery has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function buildExpQuery( $queryString ) {
                          $query = new \Elastica\Query\BoolQuery();
                          $query->setMinimumShouldMatch( 0 );
                          $this->attachFilter( $this->filter, $queryString, $query );
                          $dismaxQueries = [];
                  Severity: Major
                  Found in includes/Query/FullTextSimpleMatchQueryBuilder.php - About 2 hrs to fix

                    Method build has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function build( $inputDocs, $explain = false ) {
                            $titleFactory = MediaWikiServices::getInstance()->getTitleFactory();
                            // Cross namespace titles
                            $crossNsTitles = [];
                            $docs = [];
                    Severity: Major
                    Found in includes/BuildDocument/Completion/SuggestBuilder.php - About 2 hrs to fix

                      Method parse has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function parse( string $query, int $start, int $end ) {
                              $match = [];
                              Assert::precondition( $start < $end, '$start < $end' );
                              Assert::precondition( $end <= strlen( $query ), '$end <= strlen( $query )' );
                              $ret = preg_match( self::NEGATION, $query, $match, PREG_OFFSET_CAPTURE, $start );
                      Severity: Major
                      Found in includes/Parser/QueryStringRegex/NonPhraseParser.php - About 2 hrs to fix

                        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
                            Severity
                            Category
                            Status
                            Source
                            Language