File CirrusSearch.php
has 366 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace CirrusSearch;
use CirrusSearch\Extra\MultiList\MultiListBuilder;
CirrusSearch
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
class CirrusSearch extends SearchEngine {
/**
* Special profile to instruct this class to use profile
* selection mechanism.
Function searchTextReal
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
protected function searchTextReal( SearchQuery $query ) {
$searcher = $this->makeSearcher( $query->getSearchConfig() );
$status = $searcher->search( $query );
$this->lastSearchMetrics = $searcher->getSearchMetrics();
if ( !$status->isOK() ) {
- 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 doSearchText
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function doSearchText( $term ) {
try {
$builder = SearchQueryBuilder::newFTSearchQueryBuilder( $this->config,
$term, $this->namespacePrefixParser, $this->getCirrusSearchHookRunner() );
} catch ( SearchQueryParseException $e ) {
Method searchTextReal
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function searchTextReal( SearchQuery $query ) {
$searcher = $this->makeSearcher( $query->getSearchConfig() );
$status = $searcher->search( $query );
$this->lastSearchMetrics = $searcher->getSearchMetrics();
if ( !$status->isOK() ) {
Method getProfiles
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getProfiles( $profileType, User $user = null ) {
$profileService = $this->config->getProfileService();
$serviceProfileType = null;
switch ( $profileType ) {
case SearchEngine::COMPLETION_PROFILE_TYPE:
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 __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __construct( SearchConfig $config = null,
CirrusDebugOptions $debugOptions = null,
NamespacePrefixParser $namespacePrefixParser = null,
InterwikiResolver $interwikiResolver = null, TitleHelper $titleHelper = null
Function prefixSearch
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function prefixSearch( $search, $variants ) {
$searcher = $this->makeSearcher();
if ( $search ) {
$searcher->setResultsType( new FancyTitleResultsType( 'prefix' ) );
- 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 getProfiles
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getProfiles( $profileType, User $user = null ) {
$profileService = $this->config->getProfileService();
$serviceProfileType = null;
switch ( $profileType ) {
case SearchEngine::COMPLETION_PROFILE_TYPE:
- 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 completionSearchBackend
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function completionSearchBackend( $search ) {
if ( in_array( NS_SPECIAL, $this->namespaces ) ) {
// delegate special search to parent
return parent::completionSearchBackend( $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"
Further reading
Avoid too many return
statements within this method. Open
return $this->getSuggestions( $search, $variants, $this->config );