wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 718 of 718 total issues

File FullTextQueryStringQueryBuilder.php has 344 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace CirrusSearch\Query;

use CirrusSearch\Extra\Query\TokenCountRouter;
Severity: Minor
Found in includes/Query/FullTextQueryStringQueryBuilder.php - About 4 hrs to fix

    Function readLineBatch has a Cognitive Complexity of 29 (exceeds 5 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 4 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

    Searcher has 33 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Searcher extends ElasticsearchIntermediary implements SearcherFactory {
        public const SUGGESTION_HIGHLIGHT_PRE = '<em>';
        public const SUGGESTION_HIGHLIGHT_POST = '</em>';
        public const HIGHLIGHT_PRE_MARKER = ''; // \uE000. Can't be a unicode literal until php7
        public const HIGHLIGHT_PRE = '<span class="searchmatch">';
    Severity: Minor
    Found in includes/Searcher.php - About 4 hrs to fix

      File Reindexer.php has 338 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      namespace CirrusSearch\Maintenance;
      
      use CirrusSearch\Connection;
      Severity: Minor
      Found in includes/Maintenance/Reindexer.php - About 4 hrs to fix

        Function build has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
        Open

            public function build() {
                $resultsType = $this->searchContext->getResultsType();
        
                $query = new Query();
                $query->setTrackTotalHits( $this->searchContext->getTrackTotalHits() );
        Severity: Minor
        Found in includes/Search/SearchRequestBuilder.php - About 4 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 28 (exceeds 5 allowed). Consider refactoring.
        Open

            public function execute() {
                $this->disablePoolCountersAndLogging();
                $wiki = sprintf( "[%20s]", WikiMap::getCurrentWikiId() );
        
                // Make sure we've actually got indices to populate
        Severity: Minor
        Found in maintenance/ForceSearchIndex.php - About 4 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 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

                          Similar blocks of code found in 3 locations. Consider refactoring.
                          Open

                              private function loadDocumentSizeLimiterProfiles( SearchProfileService $service, SearchConfig $config ) {
                                  $service->registerFileRepository( SearchProfileService::DOCUMENT_SIZE_LIMITER, self::CIRRUS_BASE,
                                      __DIR__ . '/../../profiles/DocumentSizeLimiterProfiles.config.php' );
                                  $service->registerRepository( new ConfigProfileRepository( SearchProfileService::DOCUMENT_SIZE_LIMITER,
                                      self::CIRRUS_CONFIG, 'CirrusSearchDocumentSizeLimiterProfiles', $config ) );
                          Severity: Major
                          Found in includes/Profile/SearchProfileServiceFactory.php and 2 other locations - About 3 hrs to fix
                          includes/Profile/SearchProfileServiceFactory.php on lines 179..190
                          includes/Profile/SearchProfileServiceFactory.php on lines 196..208

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 152.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Similar blocks of code found in 3 locations. Consider refactoring.
                          Open

                              private function loadCrossProjectBlockScorer( SearchProfileService $service, SearchConfig $config ) {
                                  $service->registerFileRepository( SearchProfileService::CROSS_PROJECT_BLOCK_SCORER,
                                      self::CIRRUS_BASE, __DIR__ . '/../../profiles/CrossProjectBlockScorerProfiles.config.php' );
                                  $service->registerRepository( new ConfigProfileRepository( SearchProfileService::CROSS_PROJECT_BLOCK_SCORER,
                                      self::CIRRUS_CONFIG, 'CirrusSearchCrossProjectBlockScorerProfiles', $config ) );
                          Severity: Major
                          Found in includes/Profile/SearchProfileServiceFactory.php and 2 other locations - About 3 hrs to fix
                          includes/Profile/SearchProfileServiceFactory.php on lines 196..208
                          includes/Profile/SearchProfileServiceFactory.php on lines 309..320

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 152.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Severity
                          Category
                          Status
                          Source
                          Language