wikimedia/mediawiki-core

View on GitHub
maintenance/uppercaseTitlesForUnicodeTransition.php

Summary

Maintainability
F
5 days
Test Coverage

File uppercaseTitlesForUnicodeTransition.php has 519 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Obligatory redundant license notice. Exception to the GPL's "keep intact all
 * the notices" clause with respect to this notice is hereby granted.
 *
Severity: Major
Found in maintenance/uppercaseTitlesForUnicodeTransition.php - About 1 day to fix

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

        private function processTable( IDatabase $db, $op, $table, $nsField, $titleField, $pkFields ) {
            if ( $this->tables !== null && !in_array( $table, $this->tables, true ) ) {
                $this->output( "Skipping table `$table`, not in --tables.\n" );
                return;
            }
    Severity: Minor
    Found in maintenance/uppercaseTitlesForUnicodeTransition.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 execute has 78 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function execute() {
            $this->run = $this->getOption( 'run', false );
    
            if ( $this->run ) {
                $username = $this->getOption( 'user', User::MAINTENANCE_SCRIPT_USER );
    Severity: Major
    Found in maintenance/uppercaseTitlesForUnicodeTransition.php - About 3 hrs to fix

      Method doMove has 75 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function doMove( IDatabase $db, $ns, $title ) {
              $char = mb_substr( $title, 0, 1 );
              if ( !array_key_exists( $char, $this->charmap ) ) {
                  $this->error(
                      "Query returned NS$ns $title, which does not begin with a character in the charmap."
      Severity: Major
      Found in maintenance/uppercaseTitlesForUnicodeTransition.php - About 3 hrs to fix

        Method processTable has 62 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function processTable( IDatabase $db, $op, $table, $nsField, $titleField, $pkFields ) {
                if ( $this->tables !== null && !in_array( $table, $this->tables, true ) ) {
                    $this->output( "Skipping table `$table`, not in --tables.\n" );
                    return;
                }
        Severity: Major
        Found in maintenance/uppercaseTitlesForUnicodeTransition.php - About 2 hrs to fix

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

              private function processUsers( IReadableDatabase $db ) {
                  $userlistFile = $this->getOption( 'userlist' );
                  if ( $userlistFile === null ) {
                      $this->output( "Not generating user list, --userlist was not specified.\n" );
                      return;
          Severity: Minor
          Found in maintenance/uppercaseTitlesForUnicodeTransition.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 execute has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

              public function execute() {
                  $this->run = $this->getOption( 'run', false );
          
                  if ( $this->run ) {
                      $username = $this->getOption( 'user', User::MAINTENANCE_SCRIPT_USER );
          Severity: Minor
          Found in maintenance/uppercaseTitlesForUnicodeTransition.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 mungeTitle has 53 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function mungeTitle( IReadableDatabase $db, Title $oldTitle, Title &$newTitle ) {
                  $nt = $newTitle->getPrefixedText();
          
                  $munge = false;
                  if ( $this->isUserPage( $db, $newTitle->getNamespace(), $newTitle->getText() ) ) {
          Severity: Major
          Found in maintenance/uppercaseTitlesForUnicodeTransition.php - About 2 hrs to fix

            Method processUsers has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function processUsers( IReadableDatabase $db ) {
                    $userlistFile = $this->getOption( 'userlist' );
                    if ( $userlistFile === null ) {
                        $this->output( "Not generating user list, --userlist was not specified.\n" );
                        return;
            Severity: Minor
            Found in maintenance/uppercaseTitlesForUnicodeTransition.php - About 1 hr to fix

              Function mungeTitle has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function mungeTitle( IReadableDatabase $db, Title $oldTitle, Title &$newTitle ) {
                      $nt = $newTitle->getPrefixedText();
              
                      $munge = false;
                      if ( $this->isUserPage( $db, $newTitle->getNamespace(), $newTitle->getText() ) ) {
              Severity: Minor
              Found in maintenance/uppercaseTitlesForUnicodeTransition.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 __construct has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function __construct() {
                      parent::__construct();
                      $this->addDescription(
                          "Rename titles when changing behavior of Language::ucfirst().\n"
                          . "\n"
              Severity: Minor
              Found in maintenance/uppercaseTitlesForUnicodeTransition.php - About 1 hr to fix

                Method doUpdate has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function doUpdate( IDatabase $db, $op, $table, $nsField, $titleField, $row ) {
                        $ns = is_int( $nsField ) ? $nsField : (int)$row->$nsField;
                        $title = $row->$titleField;
                
                        $char = mb_substr( $title, 0, 1 );
                Severity: Minor
                Found in maintenance/uppercaseTitlesForUnicodeTransition.php - About 1 hr to fix

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

                      private function doMove( IDatabase $db, $ns, $title ) {
                          $char = mb_substr( $title, 0, 1 );
                          if ( !array_key_exists( $char, $this->charmap ) ) {
                              $this->error(
                                  "Query returned NS$ns $title, which does not begin with a character in the charmap."
                  Severity: Minor
                  Found in maintenance/uppercaseTitlesForUnicodeTransition.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 shouldDelete has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function shouldDelete( IReadableDatabase $db, Title $oldTitle, Title $newTitle ) {
                          $oldRow = $db->newSelectQueryBuilder()
                              ->select( [ 'ns' => 'rd_namespace', 'title' => 'rd_title' ] )
                              ->from( 'page' )
                              ->join( 'redirect', null, 'rd_from = page_id' )
                  Severity: Minor
                  Found in maintenance/uppercaseTitlesForUnicodeTransition.php - About 1 hr to fix

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

                        private function getNamespaces() {
                            if ( $this->namespaces === null ) {
                                $nsinfo = $this->getServiceContainer()->getNamespaceInfo();
                                $this->namespaces = array_filter(
                                    array_keys( $nsinfo->getCanonicalNamespaces() ),
                    Severity: Minor
                    Found in maintenance/uppercaseTitlesForUnicodeTransition.php - About 1 hr to fix

                      Method doUpdate has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          private function doUpdate( IDatabase $db, $op, $table, $nsField, $titleField, $row ) {
                      Severity: Minor
                      Found in maintenance/uppercaseTitlesForUnicodeTransition.php - About 45 mins to fix

                        Method processTable has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            private function processTable( IDatabase $db, $op, $table, $nsField, $titleField, $pkFields ) {
                        Severity: Minor
                        Found in maintenance/uppercaseTitlesForUnicodeTransition.php - About 45 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                  return true;
                          Severity: Major
                          Found in maintenance/uppercaseTitlesForUnicodeTransition.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                    return $this->namespaces;
                            Severity: Major
                            Found in maintenance/uppercaseTitlesForUnicodeTransition.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                                  return 1;
                              Severity: Major
                              Found in maintenance/uppercaseTitlesForUnicodeTransition.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                return 0;
                                Severity: Major
                                Found in maintenance/uppercaseTitlesForUnicodeTransition.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                              return true;
                                  Severity: Major
                                  Found in maintenance/uppercaseTitlesForUnicodeTransition.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                    return false;
                                    Severity: Major
                                    Found in maintenance/uppercaseTitlesForUnicodeTransition.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                              return true;
                                      Severity: Major
                                      Found in maintenance/uppercaseTitlesForUnicodeTransition.php - About 30 mins to fix

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

                                            private function shouldDelete( IReadableDatabase $db, Title $oldTitle, Title $newTitle ) {
                                                $oldRow = $db->newSelectQueryBuilder()
                                                    ->select( [ 'ns' => 'rd_namespace', 'title' => 'rd_title' ] )
                                                    ->from( 'page' )
                                                    ->join( 'redirect', null, 'rd_from = page_id' )
                                        Severity: Minor
                                        Found in maintenance/uppercaseTitlesForUnicodeTransition.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