wikimedia/mediawiki-core

View on GitHub
includes/specials/SpecialBlock.php

Summary

Maintainability
F
6 days
Test Coverage

File SpecialBlock.php has 705 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Implements Special:Block
 *
 * This program is free software; you can redistribute it and/or modify
Severity: Major
Found in includes/specials/SpecialBlock.php - About 1 day to fix

    Function maybeAlterFormDefaults has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function maybeAlterFormDefaults( &$fields ) {
            // This will be overwritten by request data
            $fields['Target']['default'] = (string)$this->target;
    
            if ( $this->target ) {
    Severity: Minor
    Found in includes/specials/SpecialBlock.php - About 7 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 getFormFields has 187 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function getFormFields() {
            $conf = $this->getConfig();
            $blockAllowsUTEdit = $conf->get( MainConfigNames::BlockAllowsUTEdit );
    
            $this->getOutput()->enableOOUI();
    Severity: Major
    Found in includes/specials/SpecialBlock.php - About 7 hrs to fix

      Function processFormInternal has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

          private static function processFormInternal(
              array $data,
              Authority $performer,
              BlockUserFactory $blockUserFactory,
              BlockUtils $blockUtils
      Severity: Minor
      Found in includes/specials/SpecialBlock.php - About 4 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 processFormInternal has 95 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private static function processFormInternal(
              array $data,
              Authority $performer,
              BlockUserFactory $blockUserFactory,
              BlockUtils $blockUtils
      Severity: Major
      Found in includes/specials/SpecialBlock.php - About 3 hrs to fix

        Method maybeAlterFormDefaults has 86 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function maybeAlterFormDefaults( &$fields ) {
                // This will be overwritten by request data
                $fields['Target']['default'] = (string)$this->target;
        
                if ( $this->target ) {
        Severity: Major
        Found in includes/specials/SpecialBlock.php - About 3 hrs to fix

          Method postHtml has 79 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function postHtml() {
                  $links = [];
          
                  $this->getOutput()->addModuleStyles( 'mediawiki.special' );
          
          
          Severity: Major
          Found in includes/specials/SpecialBlock.php - About 3 hrs to fix

            SpecialBlock has 24 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class SpecialBlock extends FormSpecialPage {
            
                private BlockUtils $blockUtils;
                private BlockPermissionCheckerFactory $blockPermissionCheckerFactory;
                private BlockUserFactory $blockUserFactory;
            Severity: Minor
            Found in includes/specials/SpecialBlock.php - About 2 hrs to fix

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

                  protected function preHtml() {
                      $this->getOutput()->addModuleStyles( [ 'mediawiki.special' ] );
                      $this->getOutput()->addModules( [ 'mediawiki.special.block' ] );
              
                      $blockCIDRLimit = $this->getConfig()->get( MainConfigNames::BlockCIDRLimit );
              Severity: Minor
              Found in includes/specials/SpecialBlock.php - About 1 hr to fix

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

                        BlockUtils $blockUtils,
                        BlockPermissionCheckerFactory $blockPermissionCheckerFactory,
                        BlockUserFactory $blockUserFactory,
                        DatabaseBlockStore $blockStore,
                        UserNameUtils $userNameUtils,
                Severity: Major
                Found in includes/specials/SpecialBlock.php - About 1 hr to fix

                  Function getFormFields has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function getFormFields() {
                          $conf = $this->getConfig();
                          $blockAllowsUTEdit = $conf->get( MainConfigNames::BlockAllowsUTEdit );
                  
                          $this->getOutput()->enableOOUI();
                  Severity: Minor
                  Found in includes/specials/SpecialBlock.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 preHtml has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function preHtml() {
                          $this->getOutput()->addModuleStyles( [ 'mediawiki.special' ] );
                          $this->getOutput()->addModules( [ 'mediawiki.special.block' ] );
                  
                          $blockCIDRLimit = $this->getConfig()->get( MainConfigNames::BlockCIDRLimit );
                  Severity: Minor
                  Found in includes/specials/SpecialBlock.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

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

                      protected function postHtml() {
                          $links = [];
                  
                          $this->getOutput()->addModuleStyles( 'mediawiki.special' );
                  
                  
                  Severity: Minor
                  Found in includes/specials/SpecialBlock.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 new ActionRestriction( 0, $id );
                  Severity: Major
                  Found in includes/specials/SpecialBlock.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return $status;
                    Severity: Major
                    Found in includes/specials/SpecialBlock.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                              return true;
                      Severity: Major
                      Found in includes/specials/SpecialBlock.php - About 30 mins to fix

                        There are no issues that match your filters.

                        Category
                        Status