File SpecialSearch.php
has 588 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Implements Special:Search
*
* Copyright © 2004 Brooke Vibber <bvibber@wikimedia.org>
Method showResults
has 152 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function showResults( $term ) {
if ( $this->searchEngineType !== null ) {
$this->setExtraParam( 'srbackend', $this->searchEngineType );
}
Function showResults
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
public function showResults( $term ) {
if ( $this->searchEngineType !== null ) {
$this->setExtraParam( 'srbackend', $this->searchEngineType );
}
- 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
SpecialSearch
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
class SpecialSearch extends SpecialPage {
/**
* Current search profile. Search profile is just a name that identifies
* the active search tab on the search page (content, discussions...)
* For users tt replaces the set of enabled namespaces from the query
Method load
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function load() {
$this->loadStatus = new Status();
$request = $this->getRequest();
$this->searchEngineType = $request->getVal( 'srbackend' );
Function load
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function load() {
$this->loadStatus = new Status();
$request = $this->getRequest();
$this->searchEngineType = $request->getVal( 'srbackend' );
- 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 execute
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute( $par ) {
$request = $this->getRequest();
$out = $this->getOutput();
// Fetch the search term
Function execute
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function execute( $par ) {
$request = $this->getRequest();
$out = $this->getOutput();
// Fetch the search 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 setupPage
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function setupPage( $term ) {
$out = $this->getOutput();
$this->setHeaders();
$this->outputHeader();
Method getSearchProfiles
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getSearchProfiles() {
// Builds list of Search Types (profiles)
$nsAllSet = array_keys( $this->searchConfig->searchableNamespaces() );
$defaultNs = $this->searchConfig->defaultNamespaces();
$profiles = [
Method __construct
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
SearchEngineConfig $searchConfig,
SearchEngineFactory $searchEngineFactory,
NamespaceInfo $nsInfo,
IContentHandlerFactory $contentHandlerFactory,
InterwikiLookup $interwikiLookup,
Method showCreateLink
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function showCreateLink( $title, $num, $titleMatches, $textMatches ) {
// show direct page/create link if applicable
// Check DBkey !== '' in case of fragment link only.
if ( $title === null || $title->getDBkey() === ''
Function showCreateLink
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected function showCreateLink( $title, $num, $titleMatches, $textMatches ) {
// show direct page/create link if applicable
// Check DBkey !== '' in case of fragment link only.
if ( $title === null || $title->getDBkey() === ''
- 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 prevNextLinks
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function prevNextLinks(
?int $totalRes,
?ISearchResultSet $textMatches,
string $term,
string $class,
- 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
Consider simplifying this complex logical expression. Open
if ( $title === null || $title->getDBkey() === ''
|| ( $titleMatches !== null && $titleMatches->searchContainedSyntax() )
|| ( $textMatches !== null && $textMatches->searchContainedSyntax() )
) {
// invalid title
Method prevNextLinks
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
?int $totalRes,
?ISearchResultSet $textMatches,
string $term,
string $class,
OutputPage $out
Avoid too many return
statements within this method. Open
return $url ?? $title->getFullUrlForRedirect();
Function saveNamespaces
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function saveNamespaces() {
$user = $this->getUser();
$request = $this->getRequest();
if ( $user->isRegistered() &&
- 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"