SearchEngine
has 44 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class SearchEngine {
public const DEFAULT_SORT = 'relevance';
/** @var string */
public $prefix = '';
File SearchEngine.php
has 394 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Basic search engine
*
* This program is free software; you can redistribute it and/or modify
Function parseNamespacePrefixes
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public static function parseNamespacePrefixes(
$query,
$withAllKeyword = true,
$withPrefixSearchExtractNamespaceHook = 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 getSearchIndexFields
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public function getSearchIndexFields() {
$models = MediaWikiServices::getInstance()->getContentHandlerFactory()->getContentModels();
$fields = [];
$seenHandlers = new SplObjectStorage();
foreach ( $models as $model ) {
- 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 parseNamespacePrefixes
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function parseNamespacePrefixes(
$query,
$withAllKeyword = true,
$withPrefixSearchExtractNamespaceHook = false
) {
Method processCompletionResults
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function processCompletionResults( $search, SearchSuggestionSet $suggestions ) {
// We over-fetched to determine pagination. Shrink back down if we have extra results
// and mark if pagination is possible
$suggestions->shrink( $this->limit );
Function processCompletionResults
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
protected function processCompletionResults( $search, SearchSuggestionSet $suggestions ) {
// We over-fetched to determine pagination. Shrink back down if we have extra results
// and mark if pagination is possible
$suggestions->shrink( $this->limit );
- 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 getSearchIndexFields
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getSearchIndexFields() {
$models = MediaWikiServices::getInstance()->getContentHandlerFactory()->getContentModels();
$fields = [];
$seenHandlers = new SplObjectStorage();
foreach ( $models as $model ) {
Function augmentSearchResults
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function augmentSearchResults( ISearchResultSet $resultSet ) {
$setAugmentors = [];
$rowAugmentors = [];
$this->getHookRunner()->onSearchResultsAugment( $setAugmentors, $rowAugmentors );
if ( !$setAugmentors && !$rowAugmentors ) {
- 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 completionSearchWithVariants
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function completionSearchWithVariants( $search ) {
if ( trim( $search ) === '' ) {
return SearchSuggestionSet::emptySuggestionSet(); // Return empty result
}
$search = $this->normalizeNamespaces( $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
Function maybePaginate
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function maybePaginate( Closure $fn ) {
if ( $this instanceof PaginatingSearchEngine ) {
return $fn();
}
$this->limit++;
- 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"