wikimedia/mediawiki-core

View on GitHub
includes/page/ImagePage.php

Summary

Maintainability
F
1 wk
Test Coverage

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
Severity: Major
Found in includes/page/ImagePage.php - About 2 days to fix

    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 );
    Severity: Minor
    Found in includes/page/ImagePage.php - About 1 day to fix

    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 );
    Severity: Major
    Found in includes/page/ImagePage.php - About 1 day to fix

      Method imageLinks has 106 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function imageLinks() {
              $limit = 100;
      
              $out = $this->getContext()->getOutput();
      
      
      Severity: Major
      Found in includes/page/ImagePage.php - About 4 hrs to fix

        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
        Severity: Major
        Found in includes/page/ImagePage.php - About 4 hrs to fix

          Function imageLinks has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function imageLinks() {
                  $limit = 100;
          
                  $out = $this->getContext()->getOutput();
          
          
          Severity: Minor
          Found in includes/page/ImagePage.php - About 3 hrs to fix

          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
          Severity: Minor
          Found in includes/page/ImagePage.php - About 3 hrs to fix

          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;
          Severity: Minor
          Found in includes/page/ImagePage.php - About 3 hrs to fix

            Method showTOC has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function showTOC( $metadata ) {
                    $r = [
                        Html::rawElement(
                            'li',
                            [],
            Severity: Minor
            Found in includes/page/ImagePage.php - About 1 hr to fix

              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
              Severity: Critical
              Found in includes/page/ImagePage.php - About 1 hr to fix

                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 = '';
                
                
                Severity: Minor
                Found in includes/page/ImagePage.php - About 1 hr to fix

                  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();
                  Severity: Minor
                  Found in includes/page/ImagePage.php - About 1 hr to fix

                  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();
                  Severity: Minor
                  Found in includes/page/ImagePage.php - About 1 hr to fix

                    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();
                    Severity: Minor
                    Found in includes/page/ImagePage.php - About 1 hr to fix

                      Method uploadLinksBox has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected function uploadLinksBox() {
                              if ( !$this->getContext()->getConfig()->get( MainConfigNames::EnableUploads ) ) {
                                  return;
                              }
                      
                      
                      Severity: Minor
                      Found in includes/page/ImagePage.php - About 1 hr to fix

                        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";
                        Severity: Minor
                        Found in includes/page/ImagePage.php - About 25 mins to fix

                        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();
                        Severity: Minor
                        Found in includes/page/ImagePage.php - About 25 mins to fix

                        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

                        There are no issues that match your filters.

                        Category
                        Status