wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 718 of 718 total issues

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

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 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct( SearchConfig $config, $requestedNamespaces, $localSearch, $withDefaultBoosts, $weight ) {
        parent::__construct( $config, $weight );
        // Use the boosted templates from extra indexes if available
        $queries = [];
        $weights = [];
Severity: Minor
Found in includes/Search/Rescore/BoostTemplatesFunctionScoreBuilder.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 run has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function run(
        SearcherFactory $factory,
        CirrusSearchResultSet $initialResult,
        MSearchResponses $responses,
        NamespacePrefixParser $namespacePrefixParser,
Severity: Minor
Found in includes/Fallbacks/FallbackRunner.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 checkConfig has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    protected function checkConfig( $actual, array $required, $indent = null ) {
        foreach ( $required as $key => $value ) {
            $this->debugCheckConfig( "\n$indent$key: " );
            if ( !array_key_exists( $key, $actual ) ) {
                $this->debugCheckConfig( "not found..." );
Severity: Minor
Found in includes/Maintenance/Validators/Validator.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 validate has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function validate(): Status {
        // arrays of aliases to be added/removed
        $add = $remove = [];

        $this->outputIndented( "\tValidating $this->aliasName alias..." );
Severity: Minor
Found in includes/Maintenance/Validators/IndexAliasValidator.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 filterUnusedAnalysisChain has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function filterUnusedAnalysisChain( $analysis, Set $usedAnalyzers ) {
        $sets = [
            'analyzer' => $usedAnalyzers,
            'filter' => new Set(),
            'char_filter' => new Set(),
Severity: Minor
Found in includes/Maintenance/AnalysisFilter.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 addRemoveEmpty has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    protected function addRemoveEmpty( array $config ) {
        foreach ( $config[ 'analyzer' ] as $name => $value ) {
            if ( isset( $value[ 'type' ] ) && $value[ 'type' ] != 'custom' ) {
                continue;
            }
Severity: Minor
Found in includes/Maintenance/AnalysisConfigBuilder.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 finalize has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function finalize( Document $doc, bool $enforceLatest = true, RevisionRecord $revision = null ): bool {
        $flags = CirrusIndexField::getHint( $doc, self::HINT_FLAGS );
        if ( $flags !== null ) {
            $docRevision = $doc->get( 'version' );
            if ( $revision !== null && $docRevision !== $revision->getId() ) {
Severity: Minor
Found in includes/BuildDocument/BuildDocument.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 pickBest has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function pickBest() {
        if ( !$this->titles ) {
            return null;
        }
        if ( !$this->term ) {
Severity: Minor
Found in includes/NearMatchPicker.php - About 1 hr to fix

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

      Method monitorReindexTask has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function monitorReindexTask( ReindexTask $task, Index $target ) {
              $consecutiveErrors = 0;
              $sleepSeconds = self::monitorSleepSeconds( 1, 2, self::MONITOR_SLEEP_SECONDS );
              $completionEstimateGen = self::estimateTimeRemaining();
              while ( !$task->isComplete() ) {
      Severity: Minor
      Found in includes/Maintenance/Reindexer.php - About 1 hr to fix

        Method onLinksUpdateComplete has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function onLinksUpdateComplete( $linksUpdate, $ticket ) {
                if ( !$this->isEnabled() ) {
                    return;
                }
                // defer processing the LinksUpdateComplete hook until other hooks tagged in PageChangeTracker
        Severity: Minor
        Found in includes/ChangeListener.php - About 1 hr to fix

          Method run has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function run( Document $jobInfo, $numJobs, $minId, $maxId ) {
                  // @var int
                  $from = $jobInfo->get( 'sanitize_job_id_offset' );
                  $lastLoop = $jobInfo->get( 'sanitize_job_last_loop' );
                  // ternary is BC for when loop_id didn't exist.
          Severity: Minor
          Found in includes/Maintenance/SaneitizeLoop.php - About 1 hr to fix

            Method replace has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function replace( array $profile, array $replacement ) {
                    $cur = &$profile;
                    foreach ( $replacement['matches'] as $match ) {
                        if ( !is_array( $cur ) ) {
                            return $profile;
            Severity: Minor
            Found in includes/Profile/ArrayPathSetter.php - About 1 hr to fix

              Method doJob has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function doJob() {
                      // While we can only have a single connection per job, we still
                      // use decideClusters() which includes a variety of safeguards.
                      $connections = $this->decideClusters( $this->params['update_group'] );
                      if ( !$connections ) {
              Severity: Minor
              Found in includes/Job/ElasticaWrite.php - About 1 hr to fix

                Method getSupportedProfile has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function getSupportedProfile( $profileName ) {
                        $profile = $this->context->getConfig()
                            ->getProfileService()
                            ->loadProfileByName( SearchProfileService::RESCORE, $profileName );
                        if ( !is_array( $profile ) ) {
                Severity: Minor
                Found in includes/Search/Rescore/RescoreBuilder.php - About 1 hr to fix

                  Method fromSearchQuery has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function fromSearchQuery(
                          SearchQuery $query,
                          FallbackRunner $fallbackRunner = null,
                          CirrusSearchHookRunner $cirrusSearchHookRunner = null
                      ): SearchContext {
                  Severity: Minor
                  Found in includes/Search/SearchContext.php - About 1 hr to fix

                    Method run has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function run(
                            SearcherFactory $factory,
                            CirrusSearchResultSet $initialResult,
                            MSearchResponses $responses,
                            NamespacePrefixParser $namespacePrefixParser,
                    Severity: Minor
                    Found in includes/Fallbacks/FallbackRunner.php - About 1 hr to fix

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

                          public function execute() {
                              $this->disablePoolCountersAndLogging();
                              $profiles = [];
                              $profileService = $this->getSearchConfig()->getProfileService();
                              if ( $this->hasOption( 'profile' ) ) {
                      Severity: Minor
                      Found in maintenance/UpdateDYMIndexTemplates.php - About 1 hr to fix

                        Method sendDeletes has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function sendDeletes( $docIds, $indexSuffix = null ) {
                                if ( $indexSuffix === null ) {
                                    $indexes = $this->connection->getAllIndexSuffixes( Connection::PAGE_DOC_TYPE );
                                } else {
                                    $indexes = [ $indexSuffix ];
                        Severity: Minor
                        Found in includes/DataSender.php - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language