File PageUpdater.php
has 837 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
PageUpdater
has 55 functions (exceeds 20 allowed). Consider refactoring. Open
class PageUpdater {
/**
* Options that have to be present in the ServiceOptions object passed to the constructor.
* @note When adding options here, also add them to PageUpdaterFactory::CONSTRUCTOR_OPTIONS.
Method doModify
has 94 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function doModify( CommentStoreComment $summary ): PageUpdateStatus {
$wikiPage = $this->getWikiPage(); // TODO: use for legacy hooks only!
// Update article, but only if changed.
$status = PageUpdateStatus::newEmpty( false );
Method saveRevision
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function saveRevision( CommentStoreComment $summary, int $flags = 0 ) {
$this->setFlags( $flags );
if ( $this->wasCommitted() ) {
throw new RuntimeException(
Method doCreate
has 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function doCreate( CommentStoreComment $summary ): PageUpdateStatus {
if ( $this->preventChange ) {
throw new LogicException(
"Content was changed even though preventChange() was called."
);
Function doModify
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
private function doModify( CommentStoreComment $summary ): PageUpdateStatus {
$wikiPage = $this->getWikiPage(); // TODO: use for legacy hooks only!
// Update article, but only if changed.
$status = PageUpdateStatus::newEmpty( false );
- 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 updateRevision
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function updateRevision( int $revId = 0 ) {
if ( $this->wasCommitted() ) {
throw new RuntimeException(
'saveRevision() or updateRevision() has already been called on this PageUpdater!'
);
Function saveRevision
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function saveRevision( CommentStoreComment $summary, int $flags = 0 ) {
$this->setFlags( $flags );
if ( $this->wasCommitted() ) {
throw new RuntimeException(
- 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 makeNewRevision
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function makeNewRevision(
CommentStoreComment $comment,
PageUpdateStatus $status
) {
$wikiPage = $this->getWikiPage();
Method __construct
has 14 arguments (exceeds 4 allowed). Consider refactoring. Open
UserIdentity $author,
WikiPage $wikiPage,
DerivedPageDataUpdater $derivedDataUpdater,
IConnectionProvider $dbProvider,
RevisionStore $revisionStore,
Method getAtomicSectionUpdate
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getAtomicSectionUpdate(
IDatabase $dbw,
WikiPage $wikiPage,
RevisionRecord $newRevisionRecord,
CommentStoreComment $summary,
Method doUpdate
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function doUpdate( RevisionRecord $revision ): PageUpdateStatus {
$currentRevision = $this->grabParentRevision();
if ( !$currentRevision ) {
// Article gone missing
return PageUpdateStatus::newFatal( 'edit-gone-missing' );
Method __construct
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct(
UserIdentity $author,
WikiPage $wikiPage,
DerivedPageDataUpdater $derivedDataUpdater,
IConnectionProvider $dbProvider,
Function makeNewRevision
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function makeNewRevision(
CommentStoreComment $comment,
PageUpdateStatus $status
) {
$wikiPage = $this->getWikiPage();
- 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 updateRevision
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function updateRevision( int $revId = 0 ) {
if ( $this->wasCommitted() ) {
throw new RuntimeException(
'saveRevision() or updateRevision() has already been called on this PageUpdater!'
);
- 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 doCreate
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function doCreate( CommentStoreComment $summary ): PageUpdateStatus {
if ( $this->preventChange ) {
throw new LogicException(
"Content was changed even though preventChange() was called."
);
- 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 getAtomicSectionUpdate
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
IDatabase $dbw,
WikiPage $wikiPage,
RevisionRecord $newRevisionRecord,
CommentStoreComment $summary,
array $hints = []