Showing 691 of 718 total issues
Function extractResults
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function extractResults() {
if ( $this->results === null ) {
$this->results = [];
if ( $this->result !== null ) {
$this->preCacheContainedTitles( $this->result );
- 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 getElasticSuggesters
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function getElasticSuggesters(): array {
$suggesters = [];
foreach ( $this->fallbackMethods as $method ) {
if ( $method instanceof ElasticSearchSuggestFallbackMethod ) {
$suggestQueries = $method->getSuggestQueries();
- 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 validate
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function validate() {
$this->outputIndented( "\tValidating shard allocation settings..." );
$actual = $this->fetchActualAllocation();
$changed = false;
- 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 run
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function run( Document $jobInfo, $numJobs, $minId, $maxId ) {
// @var int
$from = $jobInfo->get( 'sanitize_job_id_offset' );
$lastLoop = $jobInfo->get( 'sanitize_job_last_loop' );
// ternary is BC for when loop_id didn't exist.
- 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 validate
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function validate() {
$this->out->outputIndented( "Validating new index is different..." );
if ( !$this->oldIndex->exists() ) {
$this->out->output( "ok\n" );
return Status::newGood( 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 extractResponseVariables
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function extractResponseVariables( $responseData ) {
if ( !is_array( $responseData ) ) {
// No known offenders, but just in case...
return [];
}
- 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 resize
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function resize( Document $document ): array {
$this->stats = [];
$this->document = $document;
$originalDocLength = self::estimateDataSize( $document );
$this->docLength = $originalDocLength;
- 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 explainTemplateBoosts
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function explainTemplateBoosts( array $doc ) {
if ( !isset( $doc['template'] ) ) {
return [
'value' => 1,
'description' => 'No templates'
- 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 identifyNamespace
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function identifyNamespace( $namespace, $method = 'naive', Language $language = null ) {
static $naive = null;
static $utr30 = null;
$normalizer = 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 applyGlobals
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function applyGlobals() {
$optionsData = $this->getOption( 'options', 'false' );
if ( substr_compare( $optionsData, 'B64://', 0, strlen( 'B64://' ) ) === 0 ) {
$optionsData = base64_decode( substr( $optionsData, strlen( 'B64://' ) ) );
}
- 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 printErrorRecursive
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function printErrorRecursive( $indent, array $array ) {
foreach ( $array as $key => $value ) {
$line = $indent;
if ( !is_numeric( $key ) ) {
$line .= "$key...";
- 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 check
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function check( array $pageIds ) {
$docIds = array_map( [ $this->searchConfig, 'makeId' ], $pageIds );
$pagesFromDb = $this->loadPagesFromDB( $pageIds );
$pagesFromIndex = $this->loadPagesFromIndex( $docIds );
Method getAllIndexSuffixes
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getAllIndexSuffixes( $documentType = self::PAGE_DOC_TYPE ) {
Assert::parameter( $documentType === null || isset( self::SUFFIX_MAPPING[$documentType] ),
'$documentType', "Unknown mapping type $documentType" );
$indexSuffixes = [];
Method requeueError
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function requeueError( Connection $conn ) {
if ( $this->params['errorCount'] >= self::MAX_ERROR_RETRY ) {
LoggerFactory::getInstance( 'CirrusSearchChangeFailed' )->warning(
"Dropping failing ElasticaWrite job for DataSender::{method} in cluster {cluster} after repeated failure",
[
Method getAllowedParams
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getAllowedParams() {
$assignment = $this->getSearchConfig()->getClusterAssignment();
return [
'cluster' => [
ParamValidator::PARAM_DEFAULT => $assignment->getSearchCluster(),
Method onView
has 27 lines of code (exceeds 25 allowed). Consider refactoring. 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
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
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
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
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