File XmlDumpWriter.php
has 453 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* XmlDumpWriter
*
* Copyright © 2003, 2005, 2006 Brooke Vibber <bvibber@wikimedia.org>
Function writeSlot
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
private function writeSlot( SlotRecord $slot, $contentMode ) {
$isMain = $slot->getRole() === SlotRecord::MAIN;
$isV11 = $this->schemaVersion >= XML_DUMP_SCHEMA_VERSION_11;
if ( !$isV11 && !$isMain ) {
- 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 writeSlot
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function writeSlot( SlotRecord $slot, $contentMode ) {
$isMain = $slot->getRole() === SlotRecord::MAIN;
$isV11 = $this->schemaVersion >= XML_DUMP_SCHEMA_VERSION_11;
if ( !$isV11 && !$isMain ) {
Method writeRevision
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function writeRevision( $row, $slotRows = null ) {
$rev = $this->getRevisionStore()->newRevisionFromRowAndSlots(
$row,
$slotRows,
0,
XmlDumpWriter
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
class XmlDumpWriter {
/** Output serialized revision content. */
public const WRITE_CONTENT = 0;
Function writeRevision
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function writeRevision( $row, $slotRows = null ) {
$rev = $this->getRevisionStore()->newRevisionFromRowAndSlots(
$row,
$slotRows,
0,
- 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 writeUpload
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function writeUpload( $file, $dumpContents = false ) {
if ( $file->isOld() ) {
/** @var OldLocalFile $file */
'@phan-var OldLocalFile $file';
$archiveName = " " .
Method writeLogItem
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function writeLogItem( $row ) {
$out = " <logitem>\n";
$out .= " " . Xml::element( 'id', null, strval( $row->log_id ) ) . "\n";
$out .= $this->writeTimestamp( $row->log_timestamp, " " );
Function writeUpload
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function writeUpload( $file, $dumpContents = false ) {
if ( $file->isOld() ) {
/** @var OldLocalFile $file */
'@phan-var OldLocalFile $file';
$archiveName = " " .
- 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 writeLogItem
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function writeLogItem( $row ) {
$out = " <logitem>\n";
$out .= " " . Xml::element( 'id', null, strval( $row->log_id ) ) . "\n";
$out .= $this->writeTimestamp( $row->log_timestamp, " " );
- 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 writeUploads
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function writeUploads( $row, $dumpContents = false ) {
if ( $row->page_namespace == NS_FILE ) {
$img = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()
->newFile( $row->page_title );
if ( $img && $img->exists() ) {
- 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
Avoid too many return
statements within this method. Open
return $out;