wikimedia/mediawiki-core

View on GitHub
includes/filerepo/ThumbnailEntryPoint.php

Summary

Maintainability
F
5 days
Test Coverage

Function streamThumb has a Cognitive Complexity of 82 (exceeds 5 allowed). Consider refactoring.
Open

    protected function streamThumb( array $params ) {
        $varyOnXFP = $this->getConfig( MainConfigNames::VaryOnXFP );

        $headers = []; // HTTP headers to send

Severity: Minor
Found in includes/filerepo/ThumbnailEntryPoint.php - About 1 day 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 streamThumb has 255 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function streamThumb( array $params ) {
        $varyOnXFP = $this->getConfig( MainConfigNames::VaryOnXFP );

        $headers = []; // HTTP headers to send

Severity: Major
Found in includes/filerepo/ThumbnailEntryPoint.php - About 1 day to fix

    File ThumbnailEntryPoint.php has 451 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * Entry point implementation for retrieving media thumbnails, created by a MediaHandler
     * subclass or proxy request if FileRepo::getThumbProxyUrl is configured.
     *
    Severity: Minor
    Found in includes/filerepo/ThumbnailEntryPoint.php - About 6 hrs to fix

      Method generateThumbnail has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function generateThumbnail( File $file, array $params, $thumbName, $thumbPath ) {
              $attemptFailureEpoch = $this->getConfig( MainConfigNames::AttemptFailureEpoch );
      
              $cache = ObjectCache::getLocalClusterInstance();
              $key = $cache->makeKey(
      Severity: Major
      Found in includes/filerepo/ThumbnailEntryPoint.php - About 2 hrs to fix

        Method thumbError has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function thumbError( $status, $msgHtml, $msgText = null, $context = [] ) {
                $showHostnames = $this->getConfig( MainConfigNames::ShowHostnames );
        
                HeaderCallback::warnIfHeadersSent();
        
        
        Severity: Minor
        Found in includes/filerepo/ThumbnailEntryPoint.php - About 1 hr to fix

          Function extractThumbParams has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              private function extractThumbParams( $file, $params ) {
                  if ( !isset( $params['thumbName'] ) ) {
                      throw new InvalidArgumentException( "No thumbnail name passed to extractThumbParams" );
                  }
          
          
          Severity: Minor
          Found in includes/filerepo/ThumbnailEntryPoint.php - About 55 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 generateThumbnail has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function generateThumbnail( File $file, array $params, $thumbName, $thumbPath ) {
                  $attemptFailureEpoch = $this->getConfig( MainConfigNames::AttemptFailureEpoch );
          
                  $cache = ObjectCache::getLocalClusterInstance();
                  $key = $cache->makeKey(
          Severity: Minor
          Found in includes/filerepo/ThumbnailEntryPoint.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

          Function thumbError has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function thumbError( $status, $msgHtml, $msgText = null, $context = [] ) {
                  $showHostnames = $this->getConfig( MainConfigNames::ShowHostnames );
          
                  HeaderCallback::warnIfHeadersSent();
          
          
          Severity: Minor
          Found in includes/filerepo/ThumbnailEntryPoint.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

          Avoid too many return statements within this method.
          Open

                      return;
          Severity: Major
          Found in includes/filerepo/ThumbnailEntryPoint.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return;
            Severity: Major
            Found in includes/filerepo/ThumbnailEntryPoint.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return;
              Severity: Major
              Found in includes/filerepo/ThumbnailEntryPoint.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return;
                Severity: Major
                Found in includes/filerepo/ThumbnailEntryPoint.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return;
                  Severity: Major
                  Found in includes/filerepo/ThumbnailEntryPoint.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                            return [ $thumb, $errorHtml ];
                    Severity: Major
                    Found in includes/filerepo/ThumbnailEntryPoint.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return;
                      Severity: Major
                      Found in includes/filerepo/ThumbnailEntryPoint.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                    return;
                        Severity: Major
                        Found in includes/filerepo/ThumbnailEntryPoint.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                      return;
                          Severity: Major
                          Found in includes/filerepo/ThumbnailEntryPoint.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                        return;
                            Severity: Major
                            Found in includes/filerepo/ThumbnailEntryPoint.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                              return;
                              Severity: Major
                              Found in includes/filerepo/ThumbnailEntryPoint.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                            return;
                                Severity: Major
                                Found in includes/filerepo/ThumbnailEntryPoint.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                  return;
                                  Severity: Major
                                  Found in includes/filerepo/ThumbnailEntryPoint.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                return;
                                    Severity: Major
                                    Found in includes/filerepo/ThumbnailEntryPoint.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                  return;
                                      Severity: Major
                                      Found in includes/filerepo/ThumbnailEntryPoint.php - About 30 mins to fix

                                        There are no issues that match your filters.

                                        Category
                                        Status