wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 691 of 718 total issues

Function interleaveResults has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public static function interleaveResults( $a, $b, $limit ) {
        $interleaved = [];
        $teamA = [];
        $teamB = [];
        $aIds = array_combine( array_keys( $a ), array_keys( $a ) );
Severity: Minor
Found in includes/Search/TeamDraftInterleaver.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 updateIndices has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    protected function updateIndices( array $add, array $remove ) {
        if ( !$remove ) {
            return $this->updateFreeIndices( $add );
        }

Severity: Minor
Found in includes/Maintenance/Validators/SpecificAliasValidator.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 pickIndexIdentifierFromOption has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function pickIndexIdentifierFromOption( $option, $typeName ): Status {
        if ( $option === 'now' ) {
            $identifier = strval( time() );
            $this->outputIndented( "Setting index identifier...{$typeName}_{$identifier}\n" );
            return Status::newGood( $identifier );
Severity: Minor
Found in includes/Maintenance/ConfigUtils.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 runMSearch has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    protected function runMSearch(
        Search $search,
        RequestLog $log,
        Connection $connection = null,
        callable $resultsTransformer = null
Severity: Minor
Found in includes/ElasticsearchIntermediary.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 execute has a Cognitive Complexity of 12 (exceeds 5 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

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

    public function execute() {
        if ( $this->hasOption( 'nagios' ) ) {
            // Force silent running mode so we can match Nagios expected output.
            $this->mQuiet = true;
        }
Severity: Minor
Found in maintenance/CheckIndexes.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 retry has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function retry( $cause, $newFrom, $cluster = null ) {
        if ( $this->params['retryCount'] >= self::JOB_MAX_RETRIES ) {
            LoggerFactory::getInstance( 'CirrusSearch' )->info(
                "Sanitize CheckerJob: $cause ({fromPageId}:{toPageId}), Abandonning CheckerJob after {retries} retries " .
                "for {cluster}, (jobs_chunk_size too high?).",
Severity: Minor
Found in includes/Job/CheckerJob.php - About 1 hr to fix

    Method switchAliasTo has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function switchAliasTo( $index ) {
            $name = $index->getName();
            $oldIndexName = $this->getAliasedIndexName();
            if ( $oldIndexName !== null ) {
                $this->log( "Switching " . self::INDEX_NAME . " alias from $oldIndexName to $name.\n" );
    Severity: Minor
    Found in includes/MetaStore/MetaStoreIndex.php - About 1 hr to fix

      Method suggest has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function suggest( $text, $variants = null ) {
              $suggestSearch = $this->getSuggestSearchRequest( $text, $variants );
              $mSearchRequests = new MSearchRequests();
      
              if ( $suggestSearch !== null ) {
      Severity: Minor
      Found in includes/CompletionSuggester.php - About 1 hr to fix

        Method buildRegexWithGroovy has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function buildRegexWithGroovy( $pattern, $insensitive ) {
                $filters = [];
                foreach ( $this->fields as $field ) {
                    $script = <<<GROOVY
        import org.apache.lucene.util.automaton.*;
        Severity: Minor
        Found in includes/Query/BaseRegexFeature.php - About 1 hr to fix

          Method explainTemplateBoosts has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function explainTemplateBoosts( array $doc ) {
                  if ( !isset( $doc['template'] ) ) {
                      return [
                          'value' => 1,
                          'description' => 'No templates'
          Severity: Minor
          Found in includes/BuildDocument/Completion/QualityScore.php - About 1 hr to fix

            Method getHighlightingConfiguration has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getHighlightingConfiguration( array $extraHighlightFields = [] ) {
                    global $wgCirrusSearchUseExperimentalHighlighter;
            
                    if ( $wgCirrusSearchUseExperimentalHighlighter ) {
                        // This is much less esoteric then the plain highlighter based
            Severity: Minor
            Found in includes/Search/FancyTitleResultsType.php - About 1 hr to fix

              Method validate has 34 lines of code (exceeds 25 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

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

                    public function __construct(
                        SearchConfig $config,
                        CirrusSearchHookRunner $cirrusSearchHookRunner = null,
                        NamespacePrefixParser $namespacePrefixParser = null,
                        SparqlClient $client = null
                Severity: Minor
                Found in includes/Parser/FullTextKeywordRegistry.php - About 1 hr to fix

                  Method addSharedOptions has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function addSharedOptions( $maintenance ) {
                          $maintenance->addOption( 'startOver', 'Blow away the identified index and rebuild it with ' .
                              'no data.' );
                          $maintenance->addOption( 'indexIdentifier', "Set the identifier of the index to work on.  " .
                              "You'll need this if you have an index in production serving queries and you have " .
                  Severity: Minor
                  Found in maintenance/UpdateOneSearchIndexConfig.php - About 1 hr to fix

                    Method createIndex has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function createIndex() {
                            // This is "create only" for now.
                            if ( $this->getIndex()->exists() ) {
                                throw new RuntimeException( "Index already exists." );
                            }
                    Severity: Minor
                    Found in maintenance/UpdateSuggesterIndex.php - About 1 hr to fix

                      Method reportUpdateMetrics has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function reportUpdateMetrics(
                              \Elastica\Bulk\ResponseSet $responseSet, $indexSuffix, $sent
                          ) {
                              $updateStats = [
                                  'sent' => $sent,
                      Severity: Minor
                      Found in includes/DataSender.php - About 1 hr to fix

                        Method determineCirrusDocId has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private function determineCirrusDocId( PageIdentity $title ) {
                                $hasRedirects = false;
                                $seen = [];
                                $now = wfTimestamp( TS_MW );
                                $services = MediaWikiServices::getInstance();
                        Severity: Minor
                        Found in includes/Api/ApiTrait.php - About 1 hr to fix

                          Method fixupWholeQueryString has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function fixupWholeQueryString( $string ) {
                                  $escapeBadSyntax = static function ( $matches ) {
                                      return preg_replace( '/(?=[^\s\w])/', '\\', $matches[0] );
                                  };
                          
                          
                          Severity: Minor
                          Found in includes/Search/Escaper.php - About 1 hr to fix

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

                                public function __construct(
                                    $langCode,
                                    array $plugins,
                                    SearchConfig $config = null,
                                    CirrusSearchHookRunner $cirrusSearchHookRunner = null
                            Severity: Minor
                            Found in includes/Maintenance/AnalysisConfigBuilder.php - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language