Showing 718 of 718 total issues
Method loadDocuments
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function loadDocuments( PageIdentity $title, $sourceFiltering = true ) {
[ $docId, $hasRedirects ] = $this->determineCirrusDocId( $title );
if ( $docId === null ) {
return [];
}
Method __construct
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function __construct( $repoType, $repoName, SearchConfig $config, callable $arrayLoader ) {
$this->wrapped = ArrayProfileRepository::lazyLoaded( $repoType, $repoName, static function () use ( $arrayLoader, $config ) {
$profiles = [];
$allowedFields = [ 'suggest' => true, 'suggest-stop' => true ];
Method bulkResponseExceptionIsJustDocumentMissing
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function bulkResponseExceptionIsJustDocumentMissing(
ResponseException $exception, $logCallback = null
) {
$justDocumentMissing = true;
foreach ( $exception->getResponseSet()->getBulkResponses() as $bulkResponse ) {
Method upgradeIndexVersion
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function upgradeIndexVersion() {
$pluginsStatus = $this->configUtils->scanAvailableModules();
if ( !$pluginsStatus->isGood() ) {
throw new \RuntimeException( (string)$pluginsStatus );
}
Method buildDocument
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function buildDocument( Connection $connection, $baseName, $typeName ) {
global $IP;
if ( $typeName == Connection::TITLE_SUGGEST_INDEX_SUFFIX ) {
[ $aMaj, $aMin ] = explode( '.', SuggesterAnalysisConfigBuilder::VERSION, 3 );
[ $mMaj, $mMin ] = explode( '.', SuggesterMappingConfigBuilder::VERSION, 3 );
Method searchArchive
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function searchArchive( $term ) {
$this->searchContext->setOriginalSearchTerm( $term );
$term = $this->searchContext->escaper()->fixupWholeQueryString( $term );
$this->setResultsType( new TitleResultsType() );
Method getMapping
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getMapping( SearchEngine $engine ) {
if ( !( $engine instanceof CirrusSearch ) ) {
throw new \LogicException( "Cannot map CirrusSearch fields for another engine." );
}
$this->initFlags();
Method getSearchRequest
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getSearchRequest( Client $client ) {
$fixablePart = $this->queryFixer->getFixablePart();
if ( $fixablePart === null ) {
return null;
}
Method toArray
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function toArray() {
$output = [
'type' => $this->highlighterType
];
Method extractResponseVariables
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function extractResponseVariables( $responseData ) {
if ( !is_array( $responseData ) ) {
// No known offenders, but just in case...
return [];
}
Method format
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function format( array $queryResult ) {
$result = [];
if ( isset( $queryResult['result']['hits']['hits'] ) ) {
$queryResult = [ $queryResult ];
}
Method getValueRegex
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getValueRegex() {
Assert::invariant( $this->hasValue(), __METHOD__ . ' called but hasValue() is false' );
if ( $this->greedy() ) {
Assert::precondition( !$this->allowEmptyValue(), "greedy keywords must not accept empty value" );
// XXX: we ignore value delimiter for greedy keywords
Method toArray
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function toArray() {
$ar = [
'query' => $this->query,
'rawQuery' => $this->rawQuery
];
Method initProfile
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function initProfile() {
$res = $this->getDB( DB_REPLICA )
->newSelectQueryBuilder()
->select( [ 'min_id' => 'MIN(page_id)', 'max_id' => 'MAX(page_id)' ] )
->table( 'page' )
Method validateSpecificAlias
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function validateSpecificAlias() {
$connection = $this->getConnection();
$fieldsToCleanup = array_filter( explode( ',', $this->getOption( 'fieldsToDelete', '' ) ) );
$fieldsToCleanup = array_merge( $fieldsToCleanup, $this->getSearchConfig()->get( "CirrusSearchIndexFieldsToCleanup" ) );
Method execute
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute() {
$this->indexSuffix = $this->getOption( 'indexSuffix' );
$this->indexBaseName = $this->getOption( 'baseName',
$this->getSearchConfig()->get( SearchConfig::INDEX_BASE_NAME ) );
Function listExposedProfiles
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function listExposedProfiles( $type ) {
$profiles = [];
if ( isset( $this->repositories[$type] ) ) {
foreach ( $this->repositories[$type] as $repo ) {
foreach ( $repo->listExposedProfiles() as $name => $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 getProfileName
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function getProfileName( $type, $context = self::CONTEXT_DEFAULT, array $contextParams = [] ) {
$minPrio = PHP_INT_MAX;
if ( !isset( $this->defaultProfiles[$type][$context] ) ) {
throw new SearchProfileException( "No default profile found for $type in context $context" );
}
- 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 collectPrefixSearchResults
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function collectPrefixSearchResults( CompletionResultsCollector $collector, array $results, CompletionRequestLog $log ) {
if ( !isset( $results[self::MSEARCH_KEY_PREFIX] ) ) {
return 0;
}
$indexName = $this->prefixSearchRequestBuilder->getIndex()->getName();
- 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 __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['k'] ) ) {
$this->k = $this->getOverriddenFactor( $profile['k'] );
if ( $this->k <= 0 ) {
- 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"