wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 691 of 718 total issues

Method buildFromParsedQuery has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function buildFromParsedQuery( ParsedQuery $query ): AbstractQuery {
        $visitor = new class( $query ) extends LeafVisitor {
            public string $nearMatch;

            public function __construct( ParsedQuery $query ) {
Severity: Major
Found in includes/Query/Builder/NearMatchFieldQueryBuilder.php - About 2 hrs to fix

    File SuggesterAnalysisConfigBuilder.php has 251 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace CirrusSearch\Maintenance;
    
    /**
    Severity: Minor
    Found in includes/Maintenance/SuggesterAnalysisConfigBuilder.php - About 2 hrs to fix

      Method detect has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function detect( $text ) {
              $dirs = $this->config->getElement( 'CirrusSearchTextcatModel' );
              if ( !$dirs ) {
                  return null;
              }
      Severity: Minor
      Found in includes/LanguageDetector/TextCat.php - About 2 hrs to fix

        Method updateOtherIndex has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function updateOtherIndex( $titles ) {
                if ( !$this->connection->getConfig()->getElement( 'CirrusSearchWikimediaExtraPlugin', 'super_detect_noop' ) ) {
                    $this->logFailure( $titles, 'super_detect_noop plugin not enabled' );
                    return;
                }
        Severity: Minor
        Found in includes/OtherIndexesUpdater.php - About 1 hr to fix

          Method explain has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function explain( array $doc ) {
                  $qualityExplain = $this->intermediateExplain( $doc );
                  $pop = $doc['popularity_score'] ?? 0;
                  if ( $pop > self::POPULARITY_MAX ) {
                      $popExplain = [
          Severity: Minor
          Found in includes/BuildDocument/Completion/PQScore.php - About 1 hr to fix

            Method customize has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function customize( array $config, $language ) {
                    $defaultStopSet = $this->getDefaultStopSet( $language );
                    $config['filter']['stop_filter']['stopwords'] = $defaultStopSet;
            
                    switch ( $this->getDefaultTextAnalyzerType( $language ) ) {
            Severity: Minor
            Found in includes/Maintenance/SuggesterAnalysisConfigBuilder.php - About 1 hr to fix

              Function isProfileSyntaxSupported has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function isProfileSyntaxSupported( array $profile ) {
                      if ( ( $profile['supported_syntax'] ?? [] ) !== [] ) {
                          $supportedSyntax = false;
                          foreach ( $profile['supported_syntax'] as $supported ) {
                              if ( $this->context->isSyntaxUsed( $supported ) ) {
              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 parseValue has a Cognitive Complexity of 15 (exceeds 5 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

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

                  private function customize( array $config, $language ) {
                      $defaultStopSet = $this->getDefaultStopSet( $language );
                      $config['filter']['stop_filter']['stopwords'] = $defaultStopSet;
              
                      switch ( $this->getDefaultTextAnalyzerType( $language ) ) {
              Severity: Minor
              Found in includes/Maintenance/SuggesterAnalysisConfigBuilder.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 unify has a Cognitive Complexity of 15 (exceeds 5 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

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

                  private function extractSimilars( $groupHead, array $candidates, $checkVariants = false ) {
                      $group = [
                          'text' => $groupHead,
                          'variants' => []
                      ];
              Severity: Minor
              Found in includes/BuildDocument/Completion/SuggestBuilder.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 loadConfigFromAPI has 47 lines of code (exceeds 25 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 1 hr to fix

                Method get has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function get( array $docIds, $sourceFiltering, $usePoolCounter = true ) {
                        $connection = $this->getOverriddenConnection();
                        $indexSuffix = $connection->pickIndexSuffixForNamespaces(
                            $this->searchContext->getNamespaces()
                        );
                Severity: Minor
                Found in includes/Searcher.php - About 1 hr to fix

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

                      public function parse( string $query ): ParsedQuery {
                          $this->reInit( $query );
                          $queryLen = mb_strlen( $query );
                          if ( $queryLen > self::QUERY_LEN_HARD_LIMIT ) {
                              throw new SearchQueryParseException( 'cirrussearch-query-too-long',
                  Severity: Minor
                  Found in includes/Parser/QueryStringRegex/QueryStringRegexParser.php - About 1 hr to fix

                    Method readLineBatch has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function readLineBatch( SplFileObject $file, bool $useIds ) {
                            $titleParser = MediaWikiServices::getInstance()->getTitleParser();
                            $pageStore = MediaWikiServices::getInstance()->getPageStore();
                            $linkBatchFactory = MediaWikiServices::getInstance()->getLinkBatchFactory();
                            $batchSize = $this->getBatchSize();
                    Severity: Minor
                    Found in maintenance/UpdateWeightedTags.php - About 1 hr to fix

                      Method updatePages has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function updatePages( $pages, $flags, string $updateKind = null, int $rootEventTime = null ): int {
                              // Don't update the same page twice. We shouldn't, but meh
                              $pageIds = [];
                              $pages = array_filter( $pages, static function ( WikiPage $page ) use ( &$pageIds ) {
                                  if ( !in_array( $page->getId(), $pageIds ) ) {
                      Severity: Minor
                      Found in includes/Updater.php - About 1 hr to fix

                        Method getInterwikiResults has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function getInterwikiResults( SearchQuery $query ): Status {
                                $sources = MediaWikiServices::getInstance()
                                    ->getService( InterwikiResolver::SERVICE )
                                    ->getSisterProjectConfigs();
                                if ( !$sources ) {
                        Severity: Minor
                        Found in includes/InterwikiSearcher.php - About 1 hr to fix

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

                            Method buildConfig has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function buildConfig() {
                                    global $wgCirrusSearchWeights;
                            
                                    $page = $this->getDefaultFields();
                            
                            
                            Severity: Minor
                            Found in includes/Maintenance/MappingConfigBuilder.php - About 1 hr to fix

                              Method validate has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function validate() {
                                      $this->out->outputIndented( "Validating new index is different..." );
                                      if ( !$this->oldIndex->exists() ) {
                                          $this->out->output( "ok\n" );
                                          return Status::newGood( true );
                              Severity: Minor
                              Found in includes/Maintenance/Validators/IndexHasChangedValidator.php - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language