repo/includes/Actions/EditEntityAction.php
File EditEntityAction.php
has 359 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php
declare( strict_types = 1 );
namespace Wikibase\Repo\Actions;
Function getStatus
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
Open
private function getStatus( WebRequest $req, RevisionRecord $latestRevision ): Status {
if ( $req->getCheck( 'restore' ) ) { // nearly the same as undoafter without undo
$olderRevision = $this->revisionLookup->getRevisionById( $req->getInt( 'restore' ) );
if ( !$olderRevision ) {
- 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 showUndoForm
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function showUndoForm(): void {
$this->getOutput()->enableOOUI();
$req = $this->getRequest();
if ( $this->showPermissionError( 'read' ) || $this->showPermissionError( 'edit' ) ) {
Method getStatus
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function getStatus( WebRequest $req, RevisionRecord $latestRevision ): Status {
if ( $req->getCheck( 'restore' ) ) { // nearly the same as undoafter without undo
$olderRevision = $this->revisionLookup->getRevisionById( $req->getInt( 'restore' ) );
if ( !$olderRevision ) {
Function showUndoForm
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
Open
private function showUndoForm(): void {
$this->getOutput()->enableOOUI();
$req = $this->getRequest();
if ( $this->showPermissionError( 'read' ) || $this->showPermissionError( 'edit' ) ) {
- 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 showConfirmationForm
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function showConfirmationForm( int $autoSummaryLength, int $undidRevision = 0 ): void {
$req = $this->getRequest();
$args = [
'action' => 'submit',
Method displayUndoDiff
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function displayUndoDiff( EntityContentDiff $diff ): void {
$tableClass = 'diff diff-contentalign-' . $this->getTitle()->getPageLanguage()->alignStart();
// add Wikibase styles, the diff may include entity links with labels, including fallback indicators
$this->getOutput()->addModuleStyles( [ 'wikibase.alltargets' ] );
Method __construct
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
Article $article,
IContextSource $context,
PermissionManager $permissionManager,
RevisionLookup $revisionLookup,
AnonymousEditWarningBuilder $anonymousEditWarningBuilder,
Avoid too many return
statements within this method. Open
Open
return Status::newFatal( 'edit_form_incomplete' ); //XXX: better message?
Avoid too many return
statements within this method. Open
Open
return Status::newFatal( 'wikibase-undo-badpage', $this->getTitle(), $newerRevision->getId() );
Avoid too many return
statements within this method. Open
Open
return Status::newFatal( 'wikibase-undo-samerev', $this->getTitle() );
Avoid too many return
statements within this method. Open
Open
return Status::newFatal( 'wikibase-undo-badpage', $this->getTitle(), $olderRevision->getId() );
Avoid too many return
statements within this method. Open
Open
return Status::newFatal( 'wikibase-undo-nocontent', $this->getTitle(), $olderRevision->getId() );
Avoid too many return
statements within this method. Open
Open
return Status::newFatal( 'wikibase-undo-nocontent', $this->getTitle(), $newerRevision->getId() );
Avoid too many return
statements within this method. Open
Open
return Status::newFatal( 'undo-norev', $req->getInt( 'undo' ) );
Avoid too many return
statements within this method. Open
Open
return Status::newFatal( 'wikibase-undo-nocontent', $this->getTitle(), $latestRevision->getId() );
Avoid too many return
statements within this method. Open
Open
return Status::newGood( [ $olderRevision, $newerRevision, $latestRevision ] );