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.
*
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;
}
- Read upRead up
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 );
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."
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;
}
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;
- Read upRead up
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 );
- Read upRead up
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() ) ) {
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;
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() ) ) {
- Read upRead up
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"
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 );
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."
- Read upRead up
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' )
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() ),
Method doUpdate
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
private function doUpdate( IDatabase $db, $op, $table, $nsField, $titleField, $row ) {
Method processTable
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
private function processTable( IDatabase $db, $op, $table, $nsField, $titleField, $pkFields ) {
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return $this->namespaces;
Avoid too many return
statements within this method. Open
return 1;
Avoid too many return
statements within this method. Open
return 0;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
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' )
- Read upRead up
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"