File FullSearchResultWidget.php
has 301 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace MediaWiki\Search\SearchWidgets;
use File;
Method render
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function render( SearchResult $result, $position ) {
// If the page doesn't *exist*... our search index is out of date.
// The least confusing at this point is to drop the result.
// You may get less results, but... on well. :P
if ( $result->isBrokenTitle() || $result->isMissingRevision() ) {
Method generateFileHtml
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function generateFileHtml( SearchResult $result ) {
$title = $result->getTitle();
// don't assume that result is a valid title; e.g. could be an interwiki link target
if ( $title === null || !$title->canExist() ) {
return [ '', null, null ];
Method generateThumbnailHtml
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function generateThumbnailHtml( SearchResult $result, SearchResultThumbnail $thumbnail = null ): ?string {
$title = $result->getTitle();
// don't assume that result is a valid title; e.g. could be an interwiki link target
if ( $title === null || !$title->canExist() ) {
return null;
Function render
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function render( SearchResult $result, $position ) {
// If the page doesn't *exist*... our search index is out of date.
// The least confusing at this point is to drop the result.
// You may get less results, but... on well. :P
if ( $result->isBrokenTitle() || $result->isMissingRevision() ) {
- 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 generateThumbnailHtml
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function generateThumbnailHtml( SearchResult $result, SearchResultThumbnail $thumbnail = null ): ?string {
$title = $result->getTitle();
// don't assume that result is a valid title; e.g. could be an interwiki link target
if ( $title === null || !$title->canExist() ) {
return 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
Method __construct
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
SpecialSearch $specialPage,
LinkRenderer $linkRenderer,
HookContainer $hookContainer,
RepoGroup $repoGroup,
SearchResultThumbnailProvider $thumbnailProvider,
Function generateFileHtml
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function generateFileHtml( SearchResult $result ) {
$title = $result->getTitle();
// don't assume that result is a valid title; e.g. could be an interwiki link target
if ( $title === null || !$title->canExist() ) {
return [ '', null, 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
Avoid too many return
statements within this method. Open
return [
$html,
$this->specialPage->msg( 'parentheses' )->rawParams( $img->getShortDesc() )->escaped(),
$this->generateThumbnailHtml( $result, $thumbnail )
];
Avoid too many return
statements within this method. Open
return $thumb->toHtml( [
'desc-link' => true,
'loading' => 'lazy',
'alt' => $this->specialPage->msg( 'search-thumbnail-alt' )->params( $title ),
] );
Avoid too many return
statements within this method. Open
return $this->generateThumbnailPlaceholderHtml();
Avoid too many return
statements within this method. Open
return $thumb->toHtml( [
'desc-link' => true,
'custom-title-link' => $title,
'loading' => 'lazy',
'alt' => $this->specialPage->msg( 'search-thumbnail-alt' )->params( $title ),