Showing 691 of 718 total issues
Method sendWeightedTagsUpdate
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function sendWeightedTagsUpdate(
string $indexSuffix,
string $tagPrefix,
array $tagWeights,
int $batchSize = 30
Function extractMessageAndStatus
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public static function extractMessageAndStatus( \Elastica\Exception\ExceptionInterface $exception = null ) {
if ( !$exception ) {
return [ Status::newFatal( 'cirrussearch-backend-error' ), '' ];
}
- 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 traceRedirects
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function traceRedirects( $title ) {
// Loop through redirects until we get to the ultimate target
$redirects = [];
$wikiPageFactory = MediaWikiServices::getInstance()->getWikiPageFactory();
while ( 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
Function doTitleSnippet
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
private function doTitleSnippet( Title $title, \Elastica\Result $result, array $highlights ) {
$matched = false;
foreach ( $this->highligtedFields[ArrayCirrusSearchResult::TITLE_SNIPPET] as $hlField ) {
if ( isset( $highlights[$hlField->getFieldName()] ) ) {
$nstext = $title->getNamespace() === 0 ? '' : $this->titleHelper->getNamespaceText( $title ) . ':';
- 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 getNamespaces
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function getNamespaces(): array {
$additionalRequired = null;
if ( $this->initialNamespaces != [] && $this->contextualFilters != [] ) {
foreach ( $this->contextualFilters as $filter ) {
$additional = $filter->requiredNamespaces();
- 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 enableICUFolding
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function enableICUFolding( array $config, $language ) {
$unicodeSetFilter = $this->getICUSetFilter( $language );
$filter = [
'type' => 'icu_folding',
];
- 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 indexData
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
private function indexData(): int {
// We build the suggestions by reading CONTENT and GENERAL indices.
// This does not support extra indices like FILES on commons.
$sourceIndexSuffixes = [ Connection::CONTENT_INDEX_SUFFIX, Connection::GENERAL_INDEX_SUFFIX ];
- 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 18 (exceeds 5 allowed). Consider refactoring. Open
public function execute() {
$indexPattern = $this->getSearchConfig()->get( SearchConfig::INDEX_BASE_NAME ) . '_*';
$end = microtime( true ) + 60;
while ( true ) {
try {
- 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 sendConfigDumpRequest
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function sendConfigDumpRequest( $endpoints ) {
$logger = LoggerFactory::getInstance( 'CirrusSearch' );
$reqs = [];
foreach ( $endpoints as $prefix => $info ) {
$reqs[$prefix] = [
Method __construct
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct() {
parent::__construct();
$this->addDescription( "Force indexing some pages. Setting --from or --to will switch "
. "from page id based indexing to "
. "date based indexing which uses less efficient queries and follows redirects.\n\n"
Method execute
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute() {
global $wgLanguageCode,
$wgCirrusSearchBannedPlugins,
$wgCirrusSearchMasterTimeout;
Method truncateField
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function truncateField( string $field, bool $keyword, int $minFieldLength, int $maxDocSize, string $statBucket ): void {
if ( !$this->document->has( $field ) ) {
return;
}
$fieldData = $this->document->get( $field );
File MetaStoreIndex.php
has 264 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace CirrusSearch\MetaStore;
use CirrusSearch\Connection;
SearchQuery
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
class SearchQuery {
/**
* Identifier for the fulltext SearchEngine entry point
* @see \SearchEngine::searchText()
*/
Util
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
class Util {
/**
* Cache getDefaultBoostTemplates()
*
* @var array|null boost templates
Method getImplementation
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getImplementation( $func ) {
$weight = $func['weight'] ?? 1;
$config = $this->context->getConfig();
switch ( $func['type'] ) {
case 'boostlinks':
Method overrideMoreLikeThisOptionsFromMessage
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function overrideMoreLikeThisOptionsFromMessage() {
global $wgCirrusSearchMoreLikeThisConfig,
$wgCirrusSearchMoreLikeThisAllowedFields,
$wgCirrusSearchMoreLikeThisMaxQueryTermsLimit,
$wgCirrusSearchMoreLikeThisFields;
Method buildExpQuery
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function buildExpQuery( $queryString ) {
$query = new \Elastica\Query\BoolQuery();
$query->setMinimumShouldMatch( 0 );
$this->attachFilter( $this->filter, $queryString, $query );
$dismaxQueries = [];
Method build
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function build( $inputDocs, $explain = false ) {
$titleFactory = MediaWikiServices::getInstance()->getTitleFactory();
// Cross namespace titles
$crossNsTitles = [];
$docs = [];
Method parse
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function parse( string $query, int $start, int $end ) {
$match = [];
Assert::precondition( $start < $end, '$start < $end' );
Assert::precondition( $end <= strlen( $query ), '$end <= strlen( $query )' );
$ret = preg_match( self::NEGATION, $query, $match, PREG_OFFSET_CAPTURE, $start );