File ImagePage.php
has 871 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
Function openShowImage
has a Cognitive Complexity of 86 (exceeds 5 allowed). Consider refactoring. Open
protected function openShowImage() {
$context = $this->getContext();
$mainConfig = $context->getConfig();
$enableUploads = $mainConfig->get( MainConfigNames::EnableUploads );
$send404Code = $mainConfig->get( MainConfigNames::Send404Code );
- 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 openShowImage
has 273 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function openShowImage() {
$context = $this->getContext();
$mainConfig = $context->getConfig();
$enableUploads = $mainConfig->get( MainConfigNames::EnableUploads );
$send404Code = $mainConfig->get( MainConfigNames::Send404Code );
Method imageLinks
has 106 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function imageLinks() {
$limit = 100;
$out = $this->getContext()->getOutput();
Method view
has 101 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function view() {
$context = $this->getContext();
$showEXIF = $context->getConfig()->get( MainConfigNames::ShowEXIF );
// For action=render, include body text only; none of the image extras
Function imageLinks
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
protected function imageLinks() {
$limit = 100;
$out = $this->getContext()->getOutput();
- 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 view
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
public function view() {
$context = $this->getContext();
$showEXIF = $context->getConfig()->get( MainConfigNames::ShowEXIF );
// For action=render, include body text only; none of the image extras
- 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
ImagePage
has 28 functions (exceeds 20 allowed). Consider refactoring. Open
class ImagePage extends Article {
use MediaFileTrait;
/** @var File|false Only temporary false, most code can assume this is a File */
private $displayImg;
Method showTOC
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function showTOC( $metadata ) {
$r = [
Html::rawElement(
'li',
[],
Consider simplifying this complex logical expression. Open
if ( ( ( $size[0] <= $width_orig && $size[1] <= $height_orig )
|| ( $this->displayImg->isVectorized()
&& max( $size[0], $size[1] ) <= $svgMaxSize )
)
&& $size[0] != $width && $size[1] != $height
Method doRenderLangOpt
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function doRenderLangOpt( array $langChoices, $renderLang ) {
$context = $this->getContext();
$script = $context->getConfig()->get( MainConfigNames::Script );
$opts = '';
Function getThumbPrevText
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function getThumbPrevText( $params, $sizeLinkBigImagePreview ) {
if ( $sizeLinkBigImagePreview ) {
// Show a different message of preview is different format from original.
$previewTypeDiffers = false;
$origExt = $thumbExt = $this->displayImg->getExtension();
- 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 imageDupes
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function imageDupes() {
$this->loadFile();
$out = $this->getContext()->getOutput();
$dupes = $this->getPage()->getDuplicates();
Method getThumbPrevText
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getThumbPrevText( $params, $sizeLinkBigImagePreview ) {
if ( $sizeLinkBigImagePreview ) {
// Show a different message of preview is different format from original.
$previewTypeDiffers = false;
$origExt = $thumbExt = $this->displayImg->getExtension();
Method uploadLinksBox
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function uploadLinksBox() {
if ( !$this->getContext()->getConfig()->get( MainConfigNames::EnableUploads ) ) {
return;
}
Function makeMetadataTable
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function makeMetadataTable( $metadata ) {
$r = $this->getContext()->msg( 'metadata-help' )->plain();
// Initial state of collapsible rows is collapsed
// see mediawiki.action.view.filepage.less and mediawiki.action.view.metadata module.
$r .= "<table id=\"mw_metadata\" class=\"mw_metadata collapsed\">\n";
- 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 printSharedImageText
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function printSharedImageText() {
$out = $this->getContext()->getOutput();
$this->loadFile();
$descUrl = $this->getFile()->getDescriptionUrl();
- 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"