Showing 691 of 718 total issues
Method collect
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function collect( SearchSuggestion $suggestion, $profileName, $index ) {
if ( !$this->canCollect( $suggestion->getSuggestedTitleID(), $suggestion->getScore() ) ) {
return false;
}
Method finishRequest
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function finishRequest( Connection $connection ) {
if ( !$this->currentRequestLog ) {
LoggerFactory::getInstance( 'CirrusSearch' )->warning(
'finishRequest called without staring a request'
);
Method parseValue
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function parseValue( $key, $value, $quotedValue, $valueDelimiter, $suffix, WarningCollector $warningCollector ) {
$values = explode( '|', $value, self::MAX_CONDITIONS + 1 );
if ( count( $values ) > self::MAX_CONDITIONS ) {
$warningCollector->addWarning(
'cirrussearch-feature-too-many-conditions',
Method internalParseValue
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function internalParseValue( $value ) {
$trimQuote = '/^"([^"]*)"\s*$/';
$value = preg_replace( $trimQuote, "$1", $value );
// NS_MAIN by default
$namespaces = [ NS_MAIN ];
Method __construct
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct( SearchConfig $config = null,
CirrusDebugOptions $debugOptions = null,
NamespacePrefixParser $namespacePrefixParser = null,
InterwikiResolver $interwikiResolver = null, TitleHelper $titleHelper = null
) {
Method score
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function score( \CirrusSearch\Search\SearchQuery $query ) {
Assert::parameter( $query->getSearchEngineEntryPoint() === $this->searchEngineEntryPoint,
'query',
"must be {$this->searchEngineEntryPoint} but {$query->getSearchEngineEntryPoint()} given." );
Method getCompiledReplacements
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getCompiledReplacements() {
if ( $this->compiledReplacements === null ) {
$this->compiledReplacements = [];
foreach ( $this->replacements as $repl => $value ) {
if ( !is_string( $repl ) ) {
Method checkConfig
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function checkConfig( $actual, array $required, $indent = null ) {
foreach ( $required as $key => $value ) {
$this->debugCheckConfig( "\n$indent$key: " );
if ( !array_key_exists( $key, $actual ) ) {
$this->debugCheckConfig( "not found..." );
Method getOnWikiBoostTemplates
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function getOnWikiBoostTemplates( SearchConfig $config ) {
$cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
$cacheKey = $cache->makeGlobalKey( 'cirrussearch-boost-templates', $config->getWikiId() );
if ( $config->getWikiId() == WikiMap::getCurrentWikiId() ) {
// Local wiki we can fetch boost templates from system
Method parseValue
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function parseValue( $key, $value, $quotedValue, $valueDelimiter, $suffix, WarningCollector $warningCollector ) {
// en:Programming|id:3041512\
$categories = explode( '|', $value );// en:programming
if ( count( $categories ) > $this->maxConditions ) {
$warningCollector->addWarning(
Method resize
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function resize( Document $document ): array {
$this->stats = [];
$this->document = $document;
$originalDocLength = self::estimateDataSize( $document );
$this->docLength = $originalDocLength;
Consider simplifying this complex logical expression. Open
if ( $optVal === null || $optVal === false || $optName === 'fromId' ||
$optName === 'toId' || $optName === 'buildChunks' ||
( $optName === 'memory-limit' && $optVal === 'max' )
) {
continue;
Method __construct
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
ParsedNode $root,
$query,
$rawQuery,
$queryCleanups,
?NamespaceHeaderNode $namespaceHeader,
Consider simplifying this complex logical expression. Open
if ( $this->hasComplex ) {
$classes[] = self::COMPLEX_QUERY;
// @phan-suppress-next-line PhanSuspiciousValueComparison
} elseif ( $this->maxDepth === 0 && $this->hasWords && !$this->hasSimplePhrase ) {
$classes[] = self::SIMPLE_BAG_OF_WORDS;
Method onPageUndeleteComplete
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
ProperPageIdentity $page,
Authority $restorer,
string $reason,
RevisionRecord $restoredRev,
ManualLogEntry $logEntry,
Function run
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def run(wiki, clusters, index_types, batch_size, start, end, q, stats):
Function addRequest
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function addRequest( RequestLog $log, UserIdentity $user = null, $slowMillis = null ) {
global $wgCirrusSearchLogElasticRequests;
// @todo Is this necessary here? Check on what uses the response value
$finalContext = $log->getLogVariables() + [
- 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 classifyError
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function classifyError( \Elastica\Exception\ExceptionInterface $exception = null ) {
if ( $exception === null ) {
return 'unknown';
}
$error = self::extractFullError( $exception );
- 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 getStatus
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function getStatus() {
if ( $this->response ) {
// task complete
return $this->response;
}
- 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 createFromProfile
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private static function createFromProfile( SearchQuery $query, array $profile, InterwikiResolver $interwikiResolver ): FallbackRunner {
$fallbackMethods = [];
$methodDefs = $profile['methods'] ?? [];
foreach ( $methodDefs as $name => $methodDef ) {
if ( !isset( $methodDef['class'] ) ) {
- 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"