Showing 718 of 718 total issues
Method onView
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function onView() {
// Disable regular results
$this->getOutput()->disable();
$response = $this->getRequest()->response();
Method bestRoute
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
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()];
Method getPrefixSearchRequest
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function getPrefixSearchRequest( $term, $variants ) {
$namespaces = $this->searchContext->getNamespaces();
if ( $namespaces === null ) {
return null;
}
Method collectPrefixSearchResults
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function collectPrefixSearchResults( CompletionResultsCollector $collector, array $results, CompletionRequestLog $log ) {
if ( !isset( $results[self::MSEARCH_KEY_PREFIX] ) ) {
return 0;
}
$indexName = $this->prefixSearchRequestBuilder->getIndex()->getName();
Method pickTextSnippet
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
Method collect
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
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
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
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
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
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
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
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
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
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
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
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
Open
ParsedNode $root,
$query,
$rawQuery,
$queryCleanups,
?NamespaceHeaderNode $namespaceHeader,
Consider simplifying this complex logical expression. Open
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
Open
ProperPageIdentity $page,
Authority $restorer,
string $reason,
RevisionRecord $restoredRev,
ManualLogEntry $logEntry,