File MediaWikiEditEntity.php
has 435 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare( strict_types = 1 );
namespace Wikibase\Repo\EditEntity;
MediaWikiEditEntity
has 30 functions (exceeds 20 allowed). Consider refactoring. Open
class MediaWikiEditEntity implements EditEntity {
private EntityRevisionLookup $entityRevisionLookup;
private EntityTitleStoreLookup $titleLookup;
private EntityStore $entityStore;
Method attemptSave
has 90 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function attemptSave( EntityDocument $newEntity, string $summary, $flags, $token, $watch = null, array $tags = [] ) {
$this->checkReadOnly( $newEntity ); // throws, exception formatted by MediaWiki (cf. MWExceptionRenderer::getExceptionTitle)
$this->checkEntityId( $newEntity->getId() ); // throws internal error (unexpected condition)
$watch = $this->getDesiredWatchState( $watch );
Function attemptSave
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function attemptSave( EntityDocument $newEntity, string $summary, $flags, $token, $watch = null, array $tags = [] ) {
$this->checkReadOnly( $newEntity ); // throws, exception formatted by MediaWiki (cf. MWExceptionRenderer::getExceptionTitle)
$this->checkEntityId( $newEntity->getId() ); // throws internal error (unexpected condition)
$watch = $this->getDesiredWatchState( $watch );
- 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 15 arguments (exceeds 4 allowed). Consider refactoring. Open
EntityTitleStoreLookup $titleLookup,
EntityRevisionLookup $entityLookup,
EntityStore $entityStore,
EntityPermissionChecker $permissionChecker,
EntityDiffer $entityDiffer,
Function fixEditConflict
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function fixEditConflict( EntityDocument $newEntity ): ?EntityDocument {
$baseRev = $this->getBaseRevision();
$latestRev = $this->getLatestRevision();
if ( !$latestRev ) {
- 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 fixEditConflict
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function fixEditConflict( EntityDocument $newEntity ): ?EntityDocument {
$baseRev = $this->getBaseRevision();
$latestRev = $this->getLatestRevision();
if ( !$latestRev ) {
Method attemptSave
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function attemptSave( EntityDocument $newEntity, string $summary, $flags, $token, $watch = null, array $tags = [] ) {
Function getBaseRevision
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getBaseRevision(): ?EntityRevision {
if ( $this->baseRev === null ) {
$baseRevId = $this->getBaseRevisionId();
if ( $baseRevId === $this->getLatestRevisionId() ) {
- 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 $this->status;
Avoid too many return
statements within this method. Open
return $this->status;
Avoid too many return
statements within this method. Open
return $this->status;
Avoid too many return
statements within this method. Open
return $patchedLatest;
Avoid too many return
statements within this method. Open
return $this->status;
Avoid too many return
statements within this method. Open
return $this->status;