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 ) );
- Read upRead up
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 );
}
- Read upRead up
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 );
- Read upRead up
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
- Read upRead up
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' ) ) {
- Read upRead up
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;
}
- Read upRead up
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?).",
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" );
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 ) {
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.*;
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'
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
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..." );
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
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 " .
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." );
}
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,
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();
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] );
};
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