wikimedia/mediawiki-core

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

Summary

Maintainability
F
4 days
Test Coverage

File BlockListPager.php has 490 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/BlockListPager.php - About 7 hrs to fix

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

        public function formatValue( $name, $value ) {
            static $msg = null;
            if ( $msg === null ) {
                $keys = [
                    'anononlyblock',
    Severity: Major
    Found in includes/specials/pagers/BlockListPager.php - About 5 hrs to fix

      Method getQueryInfo has 101 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getQueryInfo() {
              $db = $this->getDatabase();
              if ( $this->readStage === SCHEMA_COMPAT_READ_OLD ) {
                  $commentQuery = $this->commentStore->getJoin( 'ipb_reason' );
                  $info = [
      Severity: Major
      Found in includes/specials/pagers/BlockListPager.php - About 4 hrs to fix

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

            public function formatValue( $name, $value ) {
                static $msg = null;
                if ( $msg === null ) {
                    $keys = [
                        'anononlyblock',
        Severity: Minor
        Found in includes/specials/pagers/BlockListPager.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

        Method getRestrictionListHTML has 73 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function getRestrictionListHTML( stdClass $row ) {
                $items = [];
                $linkRenderer = $this->getLinkRenderer();
        
                foreach ( $this->restrictions as $restriction ) {
        Severity: Major
        Found in includes/specials/pagers/BlockListPager.php - About 2 hrs to fix

          Function preprocessResults has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              public function preprocessResults( $result ) {
                  // Do a link batch query
                  $lb = $this->linkBatchFactory->newLinkBatch();
                  $lb->setCaller( __METHOD__ );
          
          
          Severity: Minor
          Found in includes/specials/pagers/BlockListPager.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

          Function getRestrictionListHTML has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              private function getRestrictionListHTML( stdClass $row ) {
                  $items = [];
                  $linkRenderer = $this->getLinkRenderer();
          
                  foreach ( $this->restrictions as $restriction ) {
          Severity: Minor
          Found in includes/specials/pagers/BlockListPager.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 12 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  IContextSource $context,
                  BlockActionInfo $blockActionInfo,
                  BlockRestrictionStore $blockRestrictionStore,
                  BlockUtils $blockUtils,
                  HideUserUtils $hideUserUtils,
          Severity: Major
          Found in includes/specials/pagers/BlockListPager.php - About 1 hr to fix

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

                public function preprocessResults( $result ) {
                    // Do a link batch query
                    $lb = $this->linkBatchFactory->newLinkBatch();
                    $lb->setCaller( __METHOD__ );
            
            
            Severity: Minor
            Found in includes/specials/pagers/BlockListPager.php - About 1 hr to fix

              Method formatTarget has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function formatTarget( $row ) {
                      if ( $row->bt_auto ) {
                          return $this->msg( 'autoblockid', $row->bl_id )->parse();
                      }
              
              
              Severity: Minor
              Found in includes/specials/pagers/BlockListPager.php - About 1 hr to fix

                Function formatTarget has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function formatTarget( $row ) {
                        if ( $row->bt_auto ) {
                            return $this->msg( 'autoblockid', $row->bl_id )->parse();
                        }
                
                
                Severity: Minor
                Found in includes/specials/pagers/BlockListPager.php - About 35 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

                Avoid too many return statements within this method.
                Open

                        return Linker::userLink( $userId, $userName ) .
                            Linker::userToolLinks(
                                $userId,
                                $userName,
                                false,
                Severity: Major
                Found in includes/specials/pagers/BlockListPager.php - About 30 mins to fix

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

                      public function getQueryInfo() {
                          $db = $this->getDatabase();
                          if ( $this->readStage === SCHEMA_COMPAT_READ_OLD ) {
                              $commentQuery = $this->commentStore->getJoin( 'ipb_reason' );
                              $info = [
                  Severity: Minor
                  Found in includes/specials/pagers/BlockListPager.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