wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 718 of 718 total issues

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

    public function getQuery() {
        if ( !$this->nonTextQueries ) {
            $mainQuery = $this->mainQuery ?: new \Elastica\Query\MatchAll();
        } else {
            $mainQuery = new \Elastica\Query\BoolQuery();
Severity: Minor
Found in includes/Search/SearchContext.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 extractResults has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    final public function extractResults() {
        if ( $this->results === null ) {
            $this->results = [];
            $elasticaResults = $this->getElasticaResultSet();
            if ( $elasticaResults !== null ) {
Severity: Minor
Found in includes/Search/BaseCirrusSearchResultSet.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 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct( SearchConfig $config, $weight, $profile ) {
        parent::__construct( $config, $weight );
        if ( isset( $profile['impact'] ) ) {
            $this->impact = $this->getOverriddenFactor( $profile['impact'] );
            if ( $this->impact <= 0 ) {
Severity: Minor
Found in includes/Search/Rescore/LogMultFunctionScoreBuilder.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 append has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function append( FunctionScore $functionScore ) {
        if ( !$this->namespacesToBoost || count( $this->namespacesToBoost ) == 1 ) {
            // nothing to boost, no need to initialize anything else.
            return;
        }
Severity: Minor
Found in includes/Search/Rescore/NamespacesFunctionScoreBuilder.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 get has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function get( array $docIds, $sourceFiltering, $usePoolCounter = true ) {
        $connection = $this->getOverriddenConnection();
        $indexSuffix = $connection->pickIndexSuffixForNamespaces(
            $this->searchContext->getNamespaces()
        );
Severity: Minor
Found in includes/Searcher.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 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
          Severity
          Category
          Status
          Source
          Language