wikimedia/mediawiki-core

View on GitHub
includes/media/DjVuHandler.php

Summary

Maintainability
C
1 day
Test Coverage

Method doTransform has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) {
        $djvuRenderer = MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::DjvuRenderer );
        $djvuPostProcessor = MediaWikiServices::getInstance()->getMainConfig()
            ->get( MainConfigNames::DjvuPostProcessor );
        if ( !$this->normaliseParams( $image, $params ) ) {
Severity: Major
Found in includes/media/DjVuHandler.php - About 2 hrs to fix

    DjVuHandler has 23 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class DjVuHandler extends ImageHandler {
        private const EXPENSIVE_SIZE_LIMIT = 10_485_760; // 10MiB
    
        // Constants for getHandlerState
        private const STATE_DJVU_IMAGE = 'djvuImage';
    Severity: Minor
    Found in includes/media/DjVuHandler.php - About 2 hrs to fix

      File DjVuHandler.php has 259 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      /**
       * Handler for DjVu images.
       *
       * This program is free software; you can redistribute it and/or modify
      Severity: Minor
      Found in includes/media/DjVuHandler.php - About 2 hrs to fix

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

            public function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) {
                $djvuRenderer = MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::DjvuRenderer );
                $djvuPostProcessor = MediaWikiServices::getInstance()->getMainConfig()
                    ->get( MainConfigNames::DjvuPostProcessor );
                if ( !$this->normaliseParams( $image, $params ) ) {
        Severity: Minor
        Found in includes/media/DjVuHandler.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

        Method doTransform has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) {
        Severity: Minor
        Found in includes/media/DjVuHandler.php - About 35 mins to fix

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

              protected function getDimensionInfoFromMetaTree( $metatree ) {
                  if ( !$metatree ) {
                      return false;
                  }
                  $dimsByPage = [];
          Severity: Minor
          Found in includes/media/DjVuHandler.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 new MediaTransformError( 'thumbnail_error',
                          $params['width'], $params['height'],
                          wfMessage( 'filemissing' )
                      );
          Severity: Major
          Found in includes/media/DjVuHandler.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return new ThumbnailImage( $image, $dstUrl, $dstPath, $params );
            Severity: Major
            Found in includes/media/DjVuHandler.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                          return new MediaTransformError( 'thumbnail_error', $width, $height, $err );
              Severity: Major
              Found in includes/media/DjVuHandler.php - About 30 mins to fix

                There are no issues that match your filters.

                Category
                Status