wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 691 of 718 total issues

Method sendWeightedTagsUpdate has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function sendWeightedTagsUpdate(
        string $indexSuffix,
        string $tagPrefix,
        array $tagWeights,
        int $batchSize = 30
Severity: Major
Found in includes/DataSender.php - About 2 hrs to fix

    Function extractMessageAndStatus has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function extractMessageAndStatus( \Elastica\Exception\ExceptionInterface $exception = null ) {
            if ( !$exception ) {
                return [ Status::newFatal( 'cirrussearch-backend-error' ), '' ];
            }
    
    
    Severity: Minor
    Found in includes/ElasticaErrorHandler.php - About 2 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 traceRedirects has a Cognitive Complexity of 18 (exceeds 5 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 2 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 doTitleSnippet has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        private function doTitleSnippet( Title $title, \Elastica\Result $result, array $highlights ) {
            $matched = false;
            foreach ( $this->highligtedFields[ArrayCirrusSearchResult::TITLE_SNIPPET] as $hlField ) {
                if ( isset( $highlights[$hlField->getFieldName()] ) ) {
                    $nstext = $title->getNamespace() === 0 ? '' : $this->titleHelper->getNamespaceText( $title ) . ':';
    Severity: Minor
    Found in includes/Search/FullTextCirrusSearchResultBuilder.php - About 2 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 getNamespaces has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getNamespaces(): array {
            $additionalRequired = null;
            if ( $this->initialNamespaces != [] && $this->contextualFilters != [] ) {
                foreach ( $this->contextualFilters as $filter ) {
                    $additional = $filter->requiredNamespaces();
    Severity: Minor
    Found in includes/Search/SearchQuery.php - About 2 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 enableICUFolding has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        public function enableICUFolding( array $config, $language ) {
            $unicodeSetFilter = $this->getICUSetFilter( $language );
            $filter = [
                'type' => 'icu_folding',
            ];
    Severity: Minor
    Found in includes/Maintenance/AnalysisConfigBuilder.php - About 2 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 indexData has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        private function indexData(): int {
            // We build the suggestions by reading CONTENT and GENERAL indices.
            // This does not support extra indices like FILES on commons.
            $sourceIndexSuffixes = [ Connection::CONTENT_INDEX_SUFFIX, Connection::GENERAL_INDEX_SUFFIX ];
    
    
    Severity: Minor
    Found in maintenance/UpdateSuggesterIndex.php - About 2 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 18 (exceeds 5 allowed). Consider refactoring.
    Open

        public function execute() {
            $indexPattern = $this->getSearchConfig()->get( SearchConfig::INDEX_BASE_NAME ) . '_*';
            $end = microtime( true ) + 60;
            while ( true ) {
                try {
    Severity: Minor
    Found in maintenance/CirrusNeedsToBeBuilt.php - About 2 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 sendConfigDumpRequest has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function sendConfigDumpRequest( $endpoints ) {
            $logger = LoggerFactory::getInstance( 'CirrusSearch' );
            $reqs = [];
            foreach ( $endpoints as $prefix => $info ) {
                $reqs[$prefix] = [
    Severity: Major
    Found in includes/BaseInterwikiResolver.php - About 2 hrs to fix

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

          public function __construct() {
              parent::__construct();
              $this->addDescription( "Force indexing some pages.  Setting --from or --to will switch "
                  . "from page id based indexing to "
                  . "date based indexing which uses less efficient queries and follows redirects.\n\n"
      Severity: Major
      Found in maintenance/ForceSearchIndex.php - About 2 hrs to fix

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

            public function execute() {
                global $wgLanguageCode,
                    $wgCirrusSearchBannedPlugins,
                    $wgCirrusSearchMasterTimeout;
        
        
        Severity: Major
        Found in maintenance/UpdateSuggesterIndex.php - About 2 hrs to fix

          Method truncateField has 59 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function truncateField( string $field, bool $keyword, int $minFieldLength, int $maxDocSize, string $statBucket ): void {
                  if ( !$this->document->has( $field ) ) {
                      return;
                  }
                  $fieldData = $this->document->get( $field );
          Severity: Major
          Found in includes/BuildDocument/DocumentSizeLimiter.php - About 2 hrs to fix

            File MetaStoreIndex.php has 264 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            
            namespace CirrusSearch\MetaStore;
            
            use CirrusSearch\Connection;
            Severity: Minor
            Found in includes/MetaStore/MetaStoreIndex.php - About 2 hrs to fix

              SearchQuery has 22 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class SearchQuery {
                  /**
                   * Identifier for the fulltext SearchEngine entry point
                   * @see \SearchEngine::searchText()
                   */
              Severity: Minor
              Found in includes/Search/SearchQuery.php - About 2 hrs to fix

                Util has 22 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class Util {
                    /**
                     * Cache getDefaultBoostTemplates()
                     *
                     * @var array|null boost templates
                Severity: Minor
                Found in includes/Util.php - About 2 hrs to fix

                  Method getImplementation has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function getImplementation( $func ) {
                          $weight = $func['weight'] ?? 1;
                          $config = $this->context->getConfig();
                          switch ( $func['type'] ) {
                              case 'boostlinks':
                  Severity: Major
                  Found in includes/Search/Rescore/FunctionScoreChain.php - About 2 hrs to fix

                    Method overrideMoreLikeThisOptionsFromMessage has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private static function overrideMoreLikeThisOptionsFromMessage() {
                            global $wgCirrusSearchMoreLikeThisConfig,
                                $wgCirrusSearchMoreLikeThisAllowedFields,
                                $wgCirrusSearchMoreLikeThisMaxQueryTermsLimit,
                                $wgCirrusSearchMoreLikeThisFields;
                    Severity: Major
                    Found in includes/Hooks.php - About 2 hrs to fix

                      Method buildExpQuery has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function buildExpQuery( $queryString ) {
                              $query = new \Elastica\Query\BoolQuery();
                              $query->setMinimumShouldMatch( 0 );
                              $this->attachFilter( $this->filter, $queryString, $query );
                              $dismaxQueries = [];
                      Severity: Major
                      Found in includes/Query/FullTextSimpleMatchQueryBuilder.php - About 2 hrs to fix

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

                            public function build( $inputDocs, $explain = false ) {
                                $titleFactory = MediaWikiServices::getInstance()->getTitleFactory();
                                // Cross namespace titles
                                $crossNsTitles = [];
                                $docs = [];
                        Severity: Major
                        Found in includes/BuildDocument/Completion/SuggestBuilder.php - About 2 hrs to fix

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

                              public function parse( string $query, int $start, int $end ) {
                                  $match = [];
                                  Assert::precondition( $start < $end, '$start < $end' );
                                  Assert::precondition( $end <= strlen( $query ), '$end <= strlen( $query )' );
                                  $ret = preg_match( self::NEGATION, $query, $match, PREG_OFFSET_CAPTURE, $start );
                          Severity: Major
                          Found in includes/Parser/QueryStringRegex/NonPhraseParser.php - About 2 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language