File Searcher.php
has 676 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace CirrusSearch;
use CirrusSearch\Fallbacks\FallbackRunner;
Function searchMulti
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
protected function searchMulti( MSearchRequests $msearches ) {
$searches = $msearches->getRequests();
$contextResultsType = $this->searchContext->getResultsType();
$cirrusDebugOptions = $this->searchContext->getDebugOptions();
Assert::precondition( !$cirrusDebugOptions->isCirrusDumpQuery(), 'Must not reach this method when dumping the query' );
- 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 searchMulti
has 125 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function searchMulti( MSearchRequests $msearches ) {
$searches = $msearches->getRequests();
$contextResultsType = $this->searchContext->getResultsType();
$cirrusDebugOptions = $this->searchContext->getDebugOptions();
Assert::precondition( !$cirrusDebugOptions->isCirrusDumpQuery(), 'Must not reach this method when dumping the query' );
Searcher
has 33 functions (exceeds 20 allowed). Consider refactoring. Open
class Searcher extends ElasticsearchIntermediary implements SearcherFactory {
public const SUGGESTION_HIGHLIGHT_PRE = '<em>';
public const SUGGESTION_HIGHLIGHT_POST = '</em>';
public const HIGHLIGHT_PRE_MARKER = ''; // \uE000. Can't be a unicode literal until php7
public const HIGHLIGHT_PRE = '<span class="searchmatch">';
Function searchTextInternal
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
private function searchTextInternal( $term ) {
// Searcher needs to be cloned before any actual query building is done.
$interleaveSearcher = $this->buildInterleaveSearcher();
$qb = $this->buildFullTextSearch( $term );
- 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 searchTextInternal
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function searchTextInternal( $term ) {
// Searcher needs to be cloned before any actual query building is done.
$interleaveSearcher = $this->buildInterleaveSearcher();
$qb = $this->buildFullTextSearch( $term );
Method get
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get( array $docIds, $sourceFiltering, $usePoolCounter = true ) {
$connection = $this->getOverriddenConnection();
$indexSuffix = $connection->pickIndexSuffixForNamespaces(
$this->searchContext->getNamespaces()
);
Method __construct
has 12 arguments (exceeds 4 allowed). Consider refactoring. Open
Connection $conn, $offset,
$limit,
SearchConfig $config,
array $namespaces = null,
User $user = null,
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() );
Function get
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function get( array $docIds, $sourceFiltering, $usePoolCounter = true ) {
$connection = $this->getOverriddenConnection();
$indexSuffix = $connection->pickIndexSuffixForNamespaces(
$this->searchContext->getNamespaces()
);
- 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 buildFullTextSearch
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function buildFullTextSearch( $term ) {
// Convert the unicode character 'ideographic whitespace' into standard
// whitespace. Cirrussearch treats them both as normal whitespace, but
// the preceding isn't appropriately trimmed.
// No searching for nothing! That takes forever!
- 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
Avoid too many return
statements within this method. Open
return $msearches->failure( Status::newFatal( 'cirrussearch-backend-error' ) );
Avoid too many return
statements within this method. Open
return $msearches->failure( $status );
Avoid too many return
statements within this method. Open
return $mresults->transformAndGetSingle( $this->searchContext->getResultsType(), self::MAINSEARCH_MSEARCH_KEY );
Avoid too many return
statements within this method. Open
return $status;
Avoid too many return
statements within this method. Open
return $work();
Avoid too many return
statements within this method. Open
return $mreponses;
Avoid too many return
statements within this method. Open
return $responses->dumpResults( $description );
Avoid too many return
statements within this method. Open
return $status;
Function getPoolCounterType
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function getPoolCounterType(): string {
// Default pool counter for all search requests. Note that not all
// possible requests go through Searcher, so this isn't globally
// definitive.
$pool = 'CirrusSearch-Search';
- 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"