File EntityDataRequestHandler.php
has 359 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Wikibase\Repo\LinkedData;
use HttpError;
Function handleRequest
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public function handleRequest( $doc, WebRequest $request, OutputPage $output ) {
// No matter what: The response is always public
$output->getRequest()->response()->header( 'Access-Control-Allow-Origin: *' );
$revision = 0;
- 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 getEntityRevision
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getEntityRevision( EntityId $id, $revision, $allowRedirects = false ) {
$prefixedId = $id->getSerialization();
$redirectRevision = null;
try {
Method handleRequest
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function handleRequest( $doc, WebRequest $request, OutputPage $output ) {
// No matter what: The response is always public
$output->getRequest()->response()->header( 'Access-Control-Allow-Origin: *' );
$revision = 0;
Method showData
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function showData( WebRequest $request, OutputPage $output, $format, EntityId $id, $revision ) {
$flavor = $request->getRawVal( 'flavor' );
/** @var EntityRevision $entityRevision */
/** @var RedirectRevision $followedRedirectRevision */
Method __construct
has 14 arguments (exceeds 4 allowed). Consider refactoring. Open
EntityDataUriManager $uriManager,
HTMLCacheUpdater $htmlCacheUpdater,
EntityIdParser $entityIdParser,
EntityRevisionLookup $entityRevisionLookup,
EntityRedirectLookup $entityRedirectLookup,
Method httpContentNegotiation
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function httpContentNegotiation( WebRequest $request, OutputPage $output, EntityId $id, $revision = 0 ) {
$headers = $request->getAllHeaders();
if ( isset( $headers['ACCEPT'] ) ) {
$parser = new HttpAcceptParser();
$accept = $parser->parseWeights( $headers['ACCEPT'] );
Method outputData
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
WebRequest $request,
EntityId $requestId,
int $requestRevision,
WebResponse $response,
string $data,
Function getEntityRevision
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function getEntityRevision( EntityId $id, $revision, $allowRedirects = false ) {
$prefixedId = $id->getSerialization();
$redirectRevision = null;
try {
- 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 showData
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function showData( WebRequest $request, OutputPage $output, $format, EntityId $id, $revision ) {
Function showData
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function showData( WebRequest $request, OutputPage $output, $format, EntityId $id, $revision ) {
$flavor = $request->getRawVal( 'flavor' );
/** @var EntityRevision $entityRevision */
/** @var RedirectRevision $followedRedirectRevision */
- 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 httpContentNegotiation
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function httpContentNegotiation( WebRequest $request, OutputPage $output, EntityId $id, $revision = 0 ) {
$headers = $request->getAllHeaders();
if ( isset( $headers['ACCEPT'] ) ) {
$parser = new HttpAcceptParser();
$accept = $parser->parseWeights( $headers['ACCEPT'] );
- 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"