wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 718 of 718 total issues

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

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

                    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 updateIndices has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected function updateIndices( array $add, array $remove ) {
                            if ( !$remove ) {
                                return $this->updateFreeIndices( $add );
                            }
                    
                    
                    Severity: Minor
                    Found in includes/Maintenance/Validators/SpecificAliasValidator.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 pickIndexIdentifierFromOption has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function pickIndexIdentifierFromOption( $option, $typeName ): Status {
                            if ( $option === 'now' ) {
                                $identifier = strval( time() );
                                $this->outputIndented( "Setting index identifier...{$typeName}_{$identifier}\n" );
                                return Status::newGood( $identifier );
                    Severity: Minor
                    Found in includes/Maintenance/ConfigUtils.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 runMSearch has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected function runMSearch(
                            Search $search,
                            RequestLog $log,
                            Connection $connection = null,
                            callable $resultsTransformer = null
                    Severity: Minor
                    Found in includes/ElasticsearchIntermediary.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