File ResultBuilder.php
has 647 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Wikibase\Repo\Api;
use MediaWiki\Api\ApiResult;
ResultBuilder
has 42 functions (exceeds 20 allowed). Consider refactoring. Open
class ResultBuilder {
/**
* @var ApiResult
*/
Function filterEntitySerializationUsingLangCodes
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
private function filterEntitySerializationUsingLangCodes(
array $serialization,
array $langCodes
) {
if ( $langCodes ) {
- 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 getTermsSerializationWithFallbackInfo
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private function getTermsSerializationWithFallbackInfo(
array $serialization,
array $termFallbackChains
) {
$newSerialization = $serialization;
- 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 getEntitySerializationWithMetaData
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getEntitySerializationWithMetaData( array $serialization ) {
$serializeEmptyListsAsObjects = WikibaseRepo::getSettings()->getSetting( 'tmpSerializeEmptyListsAsObjects' );
$modifications = [];
$makeIdKvpCallback = $this->callbackFactory->getCallbackToSetArrayType( 'kvp', 'id' );
Method addEntityRevision
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function addEntityRevision(
$sourceEntityIdSerialization,
EntityRevision $entityRevision,
$props = 'all',
array $filterSiteIds = null,
Function filterEntitySerializationUsingProps
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function filterEntitySerializationUsingProps( array $serialization, $props ) {
if ( $props !== 'all' ) {
if ( !in_array( 'labels', $props ) ) {
unset( $serialization['labels'] );
}
- 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 8 arguments (exceeds 4 allowed). Consider refactoring. Open
ApiResult $result,
EntityTitleStoreLookup $entityTitleStoreLookup,
SerializerFactory $serializerFactory,
Serializer $entitySerializer,
SiteLookup $siteLookup,
Function addEntityRevision
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function addEntityRevision(
$sourceEntityIdSerialization,
EntityRevision $entityRevision,
$props = 'all',
array $filterSiteIds = null,
- 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 addEntityRevision
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
$sourceEntityIdSerialization,
EntityRevision $entityRevision,
$props = 'all',
array $filterSiteIds = null,
array $filterLangCodes = [],
Method getModifiedEntityArray
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
EntityDocument $entity,
$props,
?array $filterSiteIds,
array $filterLangCodes,
array $termFallbackChains
Function filterEntitySerializationUsingSiteIds
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function filterEntitySerializationUsingSiteIds(
array $serialization,
array $siteIds = null
) {
if ( $siteIds && array_key_exists( 'sitelinks', $serialization ) ) {
- 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 addRevisionIdFromStatusToResult
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function addRevisionIdFromStatusToResult( Status $status, $path, $oldRevId = null ) {
$value = $status->getValue();
if ( isset( $value['revision'] ) ) {
if ( $value['revision'] instanceof EntityRevision ) {
- 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"