wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 691 of 718 total issues

Method getProfile has 99 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getProfile( $name ) {
        $settings = $this->wrapped->getProfile( $name );
        if ( $settings === null ) {
            return null;
        }
Severity: Major
Found in includes/Profile/PhraseSuggesterProfileRepoWrapper.php - About 3 hrs to fix

    Method siteMatrixLoader has 97 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function siteMatrixLoader() {
            return function () {
                global $wgConf;
    
                $matrix = new SiteMatrix;
    Severity: Major
    Found in includes/SiteMatrixInterwikiResolver.php - About 3 hrs to fix

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

          public function build( array $config ): array {
              $langStem = "{$this->langName}_stemmer";
      
              if ( $this->unpacked ) {
                  // Analyzer config for char_filter and filter will be in the order below,
      Severity: Major
      Found in includes/Maintenance/AnalyzerBuilder.php - About 3 hrs to fix

        Method expression has 94 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function expression() {
                $clauses = [];
                $left = null;
                // Last boolean operator seen, -1 means none
                $lastBoolType = -1;
        Severity: Major
        Found in includes/Parser/QueryStringRegex/QueryStringRegexParser.php - About 3 hrs to fix

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

              public function execute() {
                  $this->disablePoolCountersAndLogging();
                  $wiki = sprintf( "[%20s]", WikiMap::getCurrentWikiId() );
          
                  // Make sure we've actually got indices to populate
          Severity: Major
          Found in maintenance/ForceSearchIndex.php - About 3 hrs to fix

            Function parse has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
            Open

                public function parse( $query, KeywordFeature $feature, OffsetTracker $tracker, $startOffset = 0 ) {
                    if ( $feature->greedy() ) {
                        Assert::precondition( !$feature->allowEmptyValue(),
                            "greedy keywords must not accept empty value" );
                        // XXX: we ignore value delimiter for greedy keywords
            Severity: Minor
            Found in includes/Parser/QueryStringRegex/KeywordParser.php - About 3 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 buildExpQuery has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
            Open

                private function buildExpQuery( $queryString ) {
                    $query = new \Elastica\Query\BoolQuery();
                    $query->setMinimumShouldMatch( 0 );
                    $this->attachFilter( $this->filter, $queryString, $query );
                    $dismaxQueries = [];
            Severity: Minor
            Found in includes/Query/FullTextSimpleMatchQueryBuilder.php - About 3 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

            Hooks has 30 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class Hooks implements
                UserGetDefaultOptionsHook,
                GetPreferencesHook,
                APIAfterExecuteHook,
                ApiBeforeMainHook,
            Severity: Minor
            Found in includes/Hooks.php - About 3 hrs to fix

              UpdateOneSearchIndexConfig has 30 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class UpdateOneSearchIndexConfig extends Maintenance {
                  /**
                   * @var string
                   */
                  private $indexSuffix;
              Severity: Minor
              Found in maintenance/UpdateOneSearchIndexConfig.php - About 3 hrs to fix

                File Util.php has 318 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                
                namespace CirrusSearch;
                
                use MediaWiki\Context\RequestContext;
                Severity: Minor
                Found in includes/Util.php - About 3 hrs to fix

                  Function updateLinkedArticles has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function updateLinkedArticles( $titles ): void {
                          $pages = [];
                          $wikiPageFactory = MediaWikiServices::getInstance()->getWikiPageFactory();
                          foreach ( $titles as $title ) {
                              // Special pages don't get updated, we only index
                  Severity: Minor
                  Found in includes/Updater.php - About 3 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

                  BaseHighlightedField has 29 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  class BaseHighlightedField extends HighlightedField {
                      public const TYPE = 'highlighting';
                  
                      public const FVH_HL_TYPE = 'fvh';
                  
                  
                  Severity: Minor
                  Found in includes/Search/Fetch/BaseHighlightedField.php - About 3 hrs to fix

                    File check_indices.py has 310 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    """
                    Reconcile expected indices against live cluster state
                    
                    Reconciles the state of multiple elasticsearch clusters against the expected
                    state of multiple wikis. The reconciliation process is accept based. Some
                    Severity: Minor
                    Found in scripts/check_indices.py - About 3 hrs to fix

                      Function execute has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function execute() {
                              $result = $this->getResult();
                              $services = MediaWikiServices::getInstance();
                              $engine = $services->getSearchEngineFactory()->create();
                              if ( !( $engine instanceof CirrusSearch ) ) {
                      Severity: Minor
                      Found in includes/Api/QueryBuildDocument.php - About 3 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 execute has 84 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function execute() {
                              $result = $this->getResult();
                              $services = MediaWikiServices::getInstance();
                              $engine = $services->getSearchEngineFactory()->create();
                              if ( !( $engine instanceof CirrusSearch ) ) {
                      Severity: Major
                      Found in includes/Api/QueryBuildDocument.php - About 3 hrs to fix

                        File Updater.php has 304 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        <?php
                        
                        namespace CirrusSearch;
                        
                        use CirrusSearch\BuildDocument\BuildDocument;
                        Severity: Minor
                        Found in includes/Updater.php - About 3 hrs to fix

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

                              public function parse( $query, KeywordFeature $feature, OffsetTracker $tracker, $startOffset = 0 ) {
                                  if ( $feature->greedy() ) {
                                      Assert::precondition( !$feature->allowEmptyValue(),
                                          "greedy keywords must not accept empty value" );
                                      // XXX: we ignore value delimiter for greedy keywords
                          Severity: Major
                          Found in includes/Parser/QueryStringRegex/KeywordParser.php - About 3 hrs to fix

                            Function deduplicateAnalysisConfig has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function deduplicateAnalysisConfig( array $analysis ) {
                                    // Deduplicate children first to normalize analyzer configuration.
                                    foreach ( [ 'tokenizer', 'filter', 'char_filter' ] as $k ) {
                                        if ( !isset( $analysis[$k] ) ) {
                                            continue;
                            Severity: Minor
                            Found in includes/Maintenance/AnalysisFilter.php - About 3 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 collectTitlesFromDB has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                            Open

                                private function collectTitlesFromDB( $term ) {
                                    $titles = [];
                                    $found = [];
                                    $titleFactory = MediaWikiServices::getInstance()->getTitleFactory();
                                    $wikiPageFactory = MediaWikiServices::getInstance()->getWikiPageFactory();
                            Severity: Minor
                            Found in includes/Query/MoreLikeTrait.php - About 3 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

                            File SaneitizeJobs.php has 301 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            <?php
                            
                            namespace CirrusSearch\Maintenance;
                            
                            use CirrusSearch\Connection;
                            Severity: Minor
                            Found in maintenance/SaneitizeJobs.php - About 3 hrs to fix
                              Severity
                              Category
                              Status
                              Source
                              Language