wikimedia/mediawiki-extensions-Wikibase

View on GitHub
repo/includes/LinkedData/EntityDataRequestHandler.php

Summary

Maintainability
D
2 days
Test Coverage

File EntityDataRequestHandler.php has 359 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Wikibase\Repo\LinkedData;

use HttpError;
Severity: Minor
Found in repo/includes/LinkedData/EntityDataRequestHandler.php - About 4 hrs to fix

    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;
    Severity: Minor
    Found in repo/includes/LinkedData/EntityDataRequestHandler.php - About 3 hrs to fix

    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 {
    Severity: Major
    Found in repo/includes/LinkedData/EntityDataRequestHandler.php - About 2 hrs to fix

      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;
      Severity: Major
      Found in repo/includes/LinkedData/EntityDataRequestHandler.php - About 2 hrs to fix

        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 */
        Severity: Minor
        Found in repo/includes/LinkedData/EntityDataRequestHandler.php - About 1 hr to fix

          Method __construct has 14 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  EntityDataUriManager $uriManager,
                  HTMLCacheUpdater $htmlCacheUpdater,
                  EntityIdParser $entityIdParser,
                  EntityRevisionLookup $entityRevisionLookup,
                  EntityRedirectLookup $entityRedirectLookup,
          Severity: Major
          Found in repo/includes/LinkedData/EntityDataRequestHandler.php - About 1 hr to fix

            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'] );
            Severity: Minor
            Found in repo/includes/LinkedData/EntityDataRequestHandler.php - About 1 hr to fix

              Method outputData has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      WebRequest $request,
                      EntityId $requestId,
                      int $requestRevision,
                      WebResponse $response,
                      string $data,
              Severity: Major
              Found in repo/includes/LinkedData/EntityDataRequestHandler.php - About 50 mins to fix

                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 {
                Severity: Minor
                Found in repo/includes/LinkedData/EntityDataRequestHandler.php - About 45 mins to fix

                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 ) {
                Severity: Minor
                Found in repo/includes/LinkedData/EntityDataRequestHandler.php - About 35 mins to fix

                  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 */
                  Severity: Minor
                  Found in repo/includes/LinkedData/EntityDataRequestHandler.php - About 35 mins to fix

                  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'] );
                  Severity: Minor
                  Found in repo/includes/LinkedData/EntityDataRequestHandler.php - About 25 mins to fix

                  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

                  There are no issues that match your filters.

                  Category
                  Status