wikimedia/mediawiki-core

View on GitHub
includes/pager/IndexPager.php

Summary

Maintainability
D
3 days
Test Coverage

File IndexPager.php has 432 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/pager/IndexPager.php - About 6 hrs to fix

    IndexPager has 37 functions (exceeds 20 allowed). Consider refactoring.
    Open

    abstract class IndexPager extends ContextSource implements Pager {
    
        /** Backwards-compatible constant for $mDefaultDirection field (do not change) */
        public const DIR_ASCENDING = false;
        /** Backwards-compatible constant for $mDefaultDirection field (do not change) */
    Severity: Minor
    Found in includes/pager/IndexPager.php - About 4 hrs to fix

      Function extractResultInfo has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function extractResultInfo( $isFirst, $limit, IResultWrapper $res ) {
              $numRows = $res->numRows();
      
              $firstIndex = [];
              $lastIndex = [];
      Severity: Minor
      Found in includes/pager/IndexPager.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 __construct has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function __construct( IContextSource $context = null, LinkRenderer $linkRenderer = null ) {
              if ( $context ) {
                  $this->setContext( $context );
              }
      
      
      Severity: Major
      Found in includes/pager/IndexPager.php - About 2 hrs to fix

        Method extractResultInfo has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function extractResultInfo( $isFirst, $limit, IResultWrapper $res ) {
                $numRows = $res->numRows();
        
                $firstIndex = [];
                $lastIndex = [];
        Severity: Minor
        Found in includes/pager/IndexPager.php - About 1 hr to fix

          Function getBody has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              public function getBody() {
                  $this->getOutput()->addModuleStyles( $this->getModuleStyles() );
                  if ( !$this->mQueryDone ) {
                      $this->doQuery();
                  }
          Severity: Minor
          Found in includes/pager/IndexPager.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

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

              public function __construct( IContextSource $context = null, LinkRenderer $linkRenderer = null ) {
                  if ( $context ) {
                      $this->setContext( $context );
                  }
          
          
          Severity: Minor
          Found in includes/pager/IndexPager.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 getBody has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getBody() {
                  $this->getOutput()->addModuleStyles( $this->getModuleStyles() );
                  if ( !$this->mQueryDone ) {
                      $this->doQuery();
                  }
          Severity: Minor
          Found in includes/pager/IndexPager.php - About 1 hr to fix

            Method buildQueryInfo has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function buildQueryInfo( $offset, $limit, $order ) {
                    $fname = __METHOD__ . ' (' . $this->getSqlComment() . ')';
                    $info = $this->getQueryInfo();
                    $tables = $info['tables'];
                    $fields = $info['fields'];
            Severity: Minor
            Found in includes/pager/IndexPager.php - About 1 hr to fix

              Method getPagingQueries has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getPagingQueries() {
                      if ( !$this->mQueryDone ) {
                          $this->doQuery();
                      }
              
              
              Severity: Minor
              Found in includes/pager/IndexPager.php - About 1 hr to fix

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

                    protected function makeLink( $text, array $query = null, $type = null ) {
                        $attrs = [];
                        if ( $query !== null && in_array( $type, [ 'prev', 'next' ] ) ) {
                            $attrs['rel'] = $type;
                        }
                Severity: Minor
                Found in includes/pager/IndexPager.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