wikimedia/mediawiki-core

View on GitHub
includes/Category/CategoryViewer.php

Summary

Maintainability
D
2 days
Test Coverage

File CategoryViewer.php has 532 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * List and paging of category members.
 *
 * This program is free software; you can redistribute it and/or modify
Severity: Major
Found in includes/Category/CategoryViewer.php - About 1 day to fix

    Method doCategoryQuery has 93 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function doCategoryQuery() {
            $dbr = MediaWikiServices::getInstance()->getConnectionProvider()->getReplicaDatabase();
    
            $this->nextPage = [
                'page' => null,
    Severity: Major
    Found in includes/Category/CategoryViewer.php - About 3 hrs to fix

      Function doCategoryQuery has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function doCategoryQuery() {
              $dbr = MediaWikiServices::getInstance()->getConnectionProvider()->getReplicaDatabase();
      
              $this->nextPage = [
                  'page' => null,
      Severity: Minor
      Found in includes/Category/CategoryViewer.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

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

      class CategoryViewer extends ContextSource {
          use ProtectedHookAccessorTrait;
          use DeprecationHelper;
      
          /** @var int */
      Severity: Minor
      Found in includes/Category/CategoryViewer.php - About 2 hrs to fix

        Method getHTML has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getHTML() {
                $this->showGallery = $this->getConfig()->get( MainConfigNames::CategoryMagicGallery )
                    && !$this->getOutput()->mNoGallery;
        
                $this->clearCategoryState();
        Severity: Minor
        Found in includes/Category/CategoryViewer.php - About 1 hr to fix

          Method columnList has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function columnList(
                  $articles,
                  $articles_start_char,
                  $cssClasses = 'mw-category mw-category-columns'
              ) {
          Severity: Minor
          Found in includes/Category/CategoryViewer.php - About 1 hr to fix

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

                private function pagingLinks( $first, $last, $type = '' ) {
                    $prevLink = $this->msg( 'prev-page' )->escaped();
            
                    $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
                    if ( $first != '' ) {
            Severity: Minor
            Found in includes/Category/CategoryViewer.php - About 1 hr to fix

              Function getCountMessage has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function getCountMessage( $rescnt, $dbcnt, $type ) {
                      // There are three cases:
                      //   1) The category table figure seems good.  It might be wrong, but
                      //      we can't do anything about it if we don't recalculate it on ev-
                      //      ery category view.
              Severity: Minor
              Found in includes/Category/CategoryViewer.php - About 45 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

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

                  public function __construct( PageIdentity $page, IContextSource $context, array $from = [],
                      array $until = [], array $query = []
              Severity: Minor
              Found in includes/Category/CategoryViewer.php - About 35 mins to fix

                There are no issues that match your filters.

                Category
                Status