wikimedia/mediawiki-core

View on GitHub
includes/specials/pagers/ImageListPager.php

Summary

Maintainability
F
3 days
Test Coverage

File ImageListPager.php has 444 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: Minor
Found in includes/specials/pagers/ImageListPager.php - About 6 hrs to fix

    Method formatValue has 72 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function formatValue( $field, $value ) {
            $linkRenderer = $this->getLinkRenderer();
            switch ( $field ) {
                case 'thumb':
                    $opt = [ 'time' => wfTimestamp( TS_MW, $this->mCurrentRow->img_timestamp ) ];
    Severity: Major
    Found in includes/specials/pagers/ImageListPager.php - About 2 hrs to fix

      ImageListPager has 22 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class ImageListPager extends TablePager {
      
          /** @var string[]|null */
          protected $mFieldNames = null;
          /**
      Severity: Minor
      Found in includes/specials/pagers/ImageListPager.php - About 2 hrs to fix

        Function __construct has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            public function __construct(
                IContextSource $context,
                CommentStore $commentStore,
                LinkRenderer $linkRenderer,
                IConnectionProvider $dbProvider,
        Severity: Minor
        Found in includes/specials/pagers/ImageListPager.php - About 2 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

        Method getQueryInfoReal has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function getQueryInfoReal( $table ) {
                $dbr = $this->getDatabase();
                $prefix = $table === 'oldimage' ? 'oi' : 'img';
        
                $tables = [ $table, 'actor' ];
        Severity: Minor
        Found in includes/specials/pagers/ImageListPager.php - About 1 hr to fix

          Function formatValue has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              public function formatValue( $field, $value ) {
                  $linkRenderer = $this->getLinkRenderer();
                  switch ( $field ) {
                      case 'thumb':
                          $opt = [ 'time' => wfTimestamp( TS_MW, $this->mCurrentRow->img_timestamp ) ];
          Severity: Minor
          Found in includes/specials/pagers/ImageListPager.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 reallyDoQuery has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function reallyDoQuery( $offset, $limit, $order ) {
                  $dbr = $this->getDatabase();
                  $prevTableName = $this->mTableName;
                  $this->mTableName = 'image';
                  [ $tables, $fields, $conds, $fname, $options, $join_conds ] =
          Severity: Minor
          Found in includes/specials/pagers/ImageListPager.php - About 1 hr to fix

            Method getForm has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getForm() {
                    $formDescriptor = [];
                    $formDescriptor['limit'] = [
                        'type' => 'radio',
                        'name' => 'limit',
            Severity: Minor
            Found in includes/specials/pagers/ImageListPager.php - About 1 hr to fix

              Method __construct has 12 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      IContextSource $context,
                      CommentStore $commentStore,
                      LinkRenderer $linkRenderer,
                      IConnectionProvider $dbProvider,
                      RepoGroup $repoGroup,
              Severity: Major
              Found in includes/specials/pagers/ImageListPager.php - About 1 hr to fix

                Function combineResult has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function combineResult( $res1, $res2, $limit, $order ) {
                        $res1->rewind();
                        $res2->rewind();
                        $topRes1 = $res1->fetchObject();
                        $topRes2 = $res2->fetchObject();
                Severity: Minor
                Found in includes/specials/pagers/ImageListPager.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 combineResult has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function combineResult( $res1, $res2, $limit, $order ) {
                        $res1->rewind();
                        $res2->rewind();
                        $topRes1 = $res1->fetchObject();
                        $topRes2 = $res2->fetchObject();
                Severity: Minor
                Found in includes/specials/pagers/ImageListPager.php - About 1 hr to fix

                  Method __construct has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function __construct(
                          IContextSource $context,
                          CommentStore $commentStore,
                          LinkRenderer $linkRenderer,
                          IConnectionProvider $dbProvider,
                  Severity: Minor
                  Found in includes/specials/pagers/ImageListPager.php - About 1 hr to fix

                    Avoid too many return statements within this method.
                    Open

                                    return htmlspecialchars( $this->getLanguage()->formatNum( intval( $value ) + 1 ) );
                    Severity: Major
                    Found in includes/specials/pagers/ImageListPager.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                          return htmlspecialchars( $value );
                      Severity: Major
                      Found in includes/specials/pagers/ImageListPager.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                            return $html;
                        Severity: Major
                        Found in includes/specials/pagers/ImageListPager.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                          return $link;
                          Severity: Major
                          Found in includes/specials/pagers/ImageListPager.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                            return $this->commentFormatter->format( $value );
                            Severity: Major
                            Found in includes/specials/pagers/ImageListPager.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                              return htmlspecialchars( $this->getLanguage()->formatSize( (int)$value ) );
                              Severity: Major
                              Found in includes/specials/pagers/ImageListPager.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                return $this->msg( 'listfiles-latestversion-' . $value )->escaped();
                                Severity: Major
                                Found in includes/specials/pagers/ImageListPager.php - About 30 mins to fix

                                  Function getPagingQueries has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      public function getPagingQueries() {
                                          $queries = parent::getPagingQueries();
                                          if ( $this->mUserName !== null ) {
                                              # Append the username to the query string
                                              foreach ( $queries as &$query ) {
                                  Severity: Minor
                                  Found in includes/specials/pagers/ImageListPager.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 getFieldNames has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      protected function getFieldNames() {
                                          if ( !$this->mFieldNames ) {
                                              $this->mFieldNames = [
                                                  'img_timestamp' => $this->msg( 'listfiles_date' )->text(),
                                                  'img_name' => $this->msg( 'listfiles_name' )->text(),
                                  Severity: Minor
                                  Found in includes/specials/pagers/ImageListPager.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