Function loadEntity
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function loadEntity( array $requestParams, ?EntityId $entityId = null, $assignFreshId = self::ASSIGN_FRESH_ID ): EntityDocument {
if ( !in_array( $assignFreshId, [ self::ASSIGN_FRESH_ID, self::NO_FRESH_ID ] ) ) {
throw new InvalidArgumentException(
'$assignFreshId must be either of the EntitySavingHelper::ASSIGN_FRESH_ID/NO_FRESH_ID constants.'
);
- 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
File EntitySavingHelper.php
has 268 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare( strict_types = 1 );
namespace Wikibase\Repo\Api;
Method loadEntity
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function loadEntity( array $requestParams, ?EntityId $entityId = null, $assignFreshId = self::ASSIGN_FRESH_ID ): EntityDocument {
if ( !in_array( $assignFreshId, [ self::ASSIGN_FRESH_ID, self::NO_FRESH_ID ] ) ) {
throw new InvalidArgumentException(
'$assignFreshId must be either of the EntitySavingHelper::ASSIGN_FRESH_ID/NO_FRESH_ID constants.'
);
Method attemptSaveEntity
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function attemptSaveEntity(
EntityDocument $entity,
$summary,
array $requestParams,
IContextSource $context,
Method createEntity
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function createEntity( $entityType, EntityId $customId = null, $assignFreshId = self::ASSIGN_FRESH_ID ): EntityDocument {
if ( $customId ) {
$entityType = $customId->getEntityType();
} elseif ( !$entityType ) {
$this->errorReporter->dieError(
Method __construct
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
bool $isWriteMode,
$needsToken,
RevisionLookup $revisionLookup,
TitleFactory $titleFactory,
EntityIdParser $idParser,
Function createEntity
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function createEntity( $entityType, EntityId $customId = null, $assignFreshId = self::ASSIGN_FRESH_ID ): EntityDocument {
if ( $customId ) {
$entityType = $customId->getEntityType();
} elseif ( !$entityType ) {
$this->errorReporter->dieError(
- 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 attemptSaveEntity
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
EntityDocument $entity,
$summary,
array $requestParams,
IContextSource $context,
int $flags = 0
Function attemptSaveEntity
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function attemptSaveEntity(
EntityDocument $entity,
$summary,
array $requestParams,
IContextSource $context,
- 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"