wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 691 of 718 total issues

Function extractResults has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function extractResults() {
        if ( $this->results === null ) {
            $this->results = [];
            if ( $this->result !== null ) {
                $this->preCacheContainedTitles( $this->result );
Severity: Minor
Found in includes/Search/ResultSet.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 getElasticSuggesters has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function getElasticSuggesters(): array {
        $suggesters = [];
        foreach ( $this->fallbackMethods as $method ) {
            if ( $method instanceof ElasticSearchSuggestFallbackMethod ) {
                $suggestQueries = $method->getSuggestQueries();
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 validate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function validate() {
        $this->outputIndented( "\tValidating shard allocation settings..." );

        $actual = $this->fetchActualAllocation();
        $changed = false;
Severity: Minor
Found in includes/Maintenance/Validators/ShardAllocationValidator.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 10 (exceeds 5 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

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

    public function validate() {
        $this->out->outputIndented( "Validating new index is different..." );
        if ( !$this->oldIndex->exists() ) {
            $this->out->output( "ok\n" );
            return Status::newGood( true );
Severity: Minor
Found in includes/Maintenance/Validators/IndexHasChangedValidator.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 extractResponseVariables has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    protected function extractResponseVariables( $responseData ) {
        if ( !is_array( $responseData ) ) {
            // No known offenders, but just in case...
            return [];
        }
Severity: Minor
Found in includes/SearchRequestLog.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 resize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function resize( Document $document ): array {
        $this->stats = [];
        $this->document = $document;
        $originalDocLength = self::estimateDataSize( $document );
        $this->docLength = $originalDocLength;
Severity: Minor
Found in includes/BuildDocument/DocumentSizeLimiter.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 explainTemplateBoosts has a Cognitive Complexity of 10 (exceeds 5 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

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 identifyNamespace has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public static function identifyNamespace( $namespace, $method = 'naive', Language $language = null ) {
        static $naive = null;
        static $utr30 = null;

        $normalizer = null;
Severity: Minor
Found in includes/Util.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 applyGlobals has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    protected function applyGlobals() {
        $optionsData = $this->getOption( 'options', 'false' );
        if ( substr_compare( $optionsData, 'B64://', 0, strlen( 'B64://' ) ) === 0 ) {
            $optionsData = base64_decode( substr( $optionsData, strlen( 'B64://' ) ) );
        }
Severity: Minor
Found in maintenance/RunSearch.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 printErrorRecursive has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    private function printErrorRecursive( $indent, array $array ) {
        foreach ( $array as $key => $value ) {
            $line = $indent;
            if ( !is_numeric( $key ) ) {
                $line .= "$key...";
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 check has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function check( array $pageIds ) {
        $docIds = array_map( [ $this->searchConfig, 'makeId' ], $pageIds );

        $pagesFromDb = $this->loadPagesFromDB( $pageIds );
        $pagesFromIndex = $this->loadPagesFromIndex( $docIds );
Severity: Minor
Found in includes/Sanity/Checker.php - About 1 hr to fix

    Method getAllIndexSuffixes has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getAllIndexSuffixes( $documentType = self::PAGE_DOC_TYPE ) {
            Assert::parameter( $documentType === null || isset( self::SUFFIX_MAPPING[$documentType] ),
                '$documentType', "Unknown mapping type $documentType" );
            $indexSuffixes = [];
    
    
    Severity: Minor
    Found in includes/Connection.php - About 1 hr to fix

      Method requeueError has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function requeueError( Connection $conn ) {
              if ( $this->params['errorCount'] >= self::MAX_ERROR_RETRY ) {
                  LoggerFactory::getInstance( 'CirrusSearchChangeFailed' )->warning(
                      "Dropping failing ElasticaWrite job for DataSender::{method} in cluster {cluster} after repeated failure",
                      [
      Severity: Minor
      Found in includes/Job/ElasticaWrite.php - About 1 hr to fix

        Method getAllowedParams has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getAllowedParams() {
                $assignment = $this->getSearchConfig()->getClusterAssignment();
                return [
                    'cluster' => [
                        ParamValidator::PARAM_DEFAULT => $assignment->getSearchCluster(),
        Severity: Minor
        Found in includes/Api/CheckSanity.php - About 1 hr to fix

          Method onView has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function onView() {
                  // Disable regular results
                  $this->getOutput()->disable();
          
                  $response = $this->getRequest()->response();
          Severity: Minor
          Found in includes/Dump.php - About 1 hr to fix

            Method bestRoute has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function bestRoute( SearchQuery $query ): SearchQueryRoute {
                    Assert::parameter( isset( $this->routes[$query->getSearchEngineEntryPoint()] ), 'query',
                        "Unsupported search engine entry point {$query->getSearchEngineEntryPoint()}" );
            
                    $routes = $this->routes[$query->getSearchEngineEntryPoint()];
            Severity: Minor
            Found in includes/Dispatch/DefaultSearchQueryDispatchService.php - About 1 hr to fix

              Method getPrefixSearchRequest has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function getPrefixSearchRequest( $term, $variants ) {
                      $namespaces = $this->searchContext->getNamespaces();
                      if ( $namespaces === null ) {
                          return null;
                      }
              Severity: Minor
              Found in includes/CompletionSuggester.php - About 1 hr to fix

                Method collectPrefixSearchResults has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function collectPrefixSearchResults( CompletionResultsCollector $collector, array $results, CompletionRequestLog $log ) {
                        if ( !isset( $results[self::MSEARCH_KEY_PREFIX] ) ) {
                            return 0;
                        }
                        $indexName = $this->prefixSearchRequestBuilder->getIndex()->getName();
                Severity: Minor
                Found in includes/CompletionSuggester.php - About 1 hr to fix

                  Method pickTextSnippet has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function pickTextSnippet( $highlights ) {
                          // This can get skipped if there the page was sent to Elasticsearch without text.
                          // This could be a bug or it could be that the page simply doesn't have any text.
                          $mainSnippet = '';
                          // Prefer source_text.plain it's likely a regex
                  Severity: Minor
                  Found in includes/Search/Result.php - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language