wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 691 of 718 total issues

Method doSearchText has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function doSearchText( $term ) {
        try {
            $builder = SearchQueryBuilder::newFTSearchQueryBuilder( $this->config,
                $term, $this->namespacePrefixParser, $this->getCirrusSearchHookRunner() );
        } catch ( SearchQueryParseException $e ) {
Severity: Minor
Found in includes/CirrusSearch.php - About 1 hr to fix

    Method traceRedirects has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function traceRedirects( $title ) {
            // Loop through redirects until we get to the ultimate target
            $redirects = [];
            $wikiPageFactory = MediaWikiServices::getInstance()->getWikiPageFactory();
            while ( true ) {
    Severity: Minor
    Found in includes/Updater.php - About 1 hr to fix

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

          public function __construct( $results, $result, TitleHelper $titleHelper = null ) {
              $this->titleHelper = $titleHelper ?: new TitleHelper();
              parent::__construct( $this->titleHelper->makeTitle( $result ) );
              $this->namespaceText = $result->namespace_text;
              $this->docId = $result->getId();
      Severity: Minor
      Found in includes/Search/Result.php - About 1 hr to fix

        Method transformOneElasticResult has 38 lines of code (exceeds 25 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

          Method unify has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function unify( array $mustFilters, array $mustNotFilters ) {
                  // We want to make sure that we execute script filters last.  So we do these steps:
                  // 1.  Strip script filters from $must and $mustNot.
                  // 2.  Unify the non-script filters.
                  // 3.  Build a BoolAnd filter out of the script filters if there are any.
          Severity: Minor
          Found in includes/Search/Filters.php - About 1 hr to fix

            Method parseValue has 38 lines of code (exceeds 25 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

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

                  public function execute() {
                      $this->metaStore = $this->getMetaStore();
              
                      if ( $this->hasOption( 'dump' ) ) {
                          $this->dump();
              Severity: Minor
              Found in maintenance/Metastore.php - About 1 hr to fix

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

                        Connection $conn, $offset,
                        $limit,
                        SearchConfig $config,
                        array $namespaces = null,
                        User $user = null,
                Severity: Major
                Found in includes/Searcher.php - About 1 hr to fix

                  Method buildWeightedTags has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function buildWeightedTags(
                          string $tagPrefix,
                          ?array $tagWeightsByName = null
                      ): array {
                          Assert::precondition(
                  Severity: Minor
                  Found in includes/Extra/MultiList/MultiListBuilder.php - About 1 hr to fix

                    Method searchFor has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function searchFor( $query ) {
                            $searchType = $this->getOption( 'type', 'full_text' );
                    
                            if ( $searchType === 'archive' ) {
                                // Archive has its own engine so go directly there
                    Severity: Minor
                    Found in maintenance/RunSearch.php - About 1 hr to fix

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

                          public function parse( $query, $start, $end ) {
                              $match = [];
                              Assert::precondition( $start < $end, '$start < $end' );
                              Assert::precondition( $end <= strlen( $query ), '$end <= strlen( $query )' );
                              if ( preg_match( self::PHRASE_REGEX, $query, $match, 0, $start ) === 1 ) {
                      Severity: Minor
                      Found in includes/Parser/QueryStringRegex/PhraseQueryParser.php - About 1 hr to fix

                        Method intermediateExplain has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function intermediateExplain( array $doc ) {
                                $incLinks = $this->explainScoreNormLog2( $doc['incoming_links'] ?? 0,
                                    $this->incomingLinksNorm, 'incoming_links' );
                                $pageSize = $this->explainScoreNormLog2( $doc['text_bytes'] ?? 0,
                                    self::PAGE_SIZE_NORM, 'text_bytes' );
                        Severity: Minor
                        Found in includes/BuildDocument/Completion/QualityScore.php - About 1 hr to fix

                          Method pushJobs has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              private function pushJobs() {
                                  $profile = $this->getSearchConfig()
                                      ->getProfileService()
                                      ->loadProfileByName( SearchProfileService::SANEITIZER, $this->profileName );
                                  '@phan-var array $profile';
                          Severity: Minor
                          Found in maintenance/SaneitizeJobs.php - About 1 hr to fix

                            Function sendConfigDumpRequest has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                            Open

                                private function sendConfigDumpRequest( $endpoints ) {
                                    $logger = LoggerFactory::getInstance( 'CirrusSearch' );
                                    $reqs = [];
                                    foreach ( $endpoints as $prefix => $info ) {
                                        $reqs[$prefix] = [
                            Severity: Minor
                            Found in includes/BaseInterwikiResolver.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 serde has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                            Open

                                private static function serde( $method, array $arguments, $serialize = true ) {
                                    if ( isset( self::$SERDE[$method] ) ) {
                                        foreach ( self::$SERDE[$method] as $i => $serde ) {
                                            if ( $serde !== null && array_key_exists( $i, $arguments ) ) {
                                                $impl = new $serde();
                            Severity: Minor
                            Found in includes/Job/ElasticaWrite.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 determineCirrusDocId has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                            Open

                                private function determineCirrusDocId( PageIdentity $title ) {
                                    $hasRedirects = false;
                                    $seen = [];
                                    $now = wfTimestamp( TS_MW );
                                    $services = MediaWikiServices::getInstance();
                            Severity: Minor
                            Found in includes/Api/ApiTrait.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 check has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function check( array $pageIds ) {
                                    $docIds = array_map( [ $this->searchConfig, 'makeId' ], $pageIds );
                            
                                    $pagesFromDb = $this->loadPagesFromDB( $pageIds );
                                    $pagesFromIndex = $this->loadPagesFromIndex( $docIds );
                            Severity: Minor
                            Found in includes/Sanity/Checker.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 pickTextSnippet has a Cognitive Complexity of 12 (exceeds 5 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

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

                                public function __construct( $results, $result, TitleHelper $titleHelper = null ) {
                                    $this->titleHelper = $titleHelper ?: new TitleHelper();
                                    parent::__construct( $this->titleHelper->makeTitle( $result ) );
                                    $this->namespaceText = $result->namespace_text;
                                    $this->docId = $result->getId();
                            Severity: Minor
                            Found in includes/Search/Result.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 successApproximation has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function successApproximation( FallbackRunnerContext $context ) {
                                    $firstPassResults = $context->getInitialResultSet();
                                    if ( !$this->query->isAllowRewrite() ) {
                                        return 0.0;
                                    }
                            Severity: Minor
                            Found in includes/Fallbacks/LangDetectFallbackMethod.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