wikimedia/mediawiki-core

View on GitHub
includes/ResourceLoader/ResourceLoader.php

Summary

Maintainability
F
1 wk
Test Coverage

File ResourceLoader.php has 1247 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
Severity: Major
Found in includes/ResourceLoader/ResourceLoader.php - About 3 days to fix

    ResourceLoader has 71 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class ResourceLoader implements LoggerAwareInterface {
        /** @var int */
        public const CACHE_VERSION = 9;
        /** @var string JavaScript / CSS pragma to disable minification. * */
        public const FILTER_NOMIN = '/*@nomin*/';
    Severity: Major
    Found in includes/ResourceLoader/ResourceLoader.php - About 1 day to fix

      Function makeModuleResponse has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

          public function makeModuleResponse( Context $context,
              array $modules, array $missing = []
          ) {
              if ( $modules === [] && $missing === [] ) {
                  return <<<MESSAGE
      Severity: Minor
      Found in includes/ResourceLoader/ResourceLoader.php - About 4 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

      Function respond has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

          public function respond( Context $context ) {
              // Buffer output to catch warnings. Normally we'd use ob_clean() on the
              // top-level output buffer to clear warnings, but that breaks when ob_gzhandler
              // is used: ob_clean() will clear the GZIP header in that case and it won't come
              // back for subsequent output, resulting in invalid GZIP. So we have to wrap
      Severity: Minor
      Found in includes/ResourceLoader/ResourceLoader.php - About 4 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 respond has 78 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function respond( Context $context ) {
              // Buffer output to catch warnings. Normally we'd use ob_clean() on the
              // top-level output buffer to clear warnings, but that breaks when ob_gzhandler
              // is used: ob_clean() will clear the GZIP header in that case and it won't come
              // back for subsequent output, resulting in invalid GZIP. So we have to wrap
      Severity: Major
      Found in includes/ResourceLoader/ResourceLoader.php - About 3 hrs to fix

        Method getOneModuleResponse has 70 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function getOneModuleResponse( Context $context, $name, Module $module ) {
                $only = $context->getOnly();
                // Important: Do not cache minifications of embedded modules
                // This is especially for the private 'user.options' module,
                // which varies on every pageview and would explode the cache (T84960)
        Severity: Major
        Found in includes/ResourceLoader/ResourceLoader.php - About 2 hrs to fix

          Method makeModuleResponse has 63 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function makeModuleResponse( Context $context,
                  array $modules, array $missing = []
              ) {
                  if ( $modules === [] && $missing === [] ) {
                      return <<<MESSAGE
          Severity: Major
          Found in includes/ResourceLoader/ResourceLoader.php - About 2 hrs to fix

            Function getLessCompiler has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getLessCompiler( array $vars = [], array $importDirs = [] ) {
                    global $IP;
                    // When called from the installer, it is possible that a required PHP extension
                    // is missing (at least for now; see T49564). If this is the case, throw an
                    // exception (caught by the installer) to prevent a fatal error later on.
            Severity: Minor
            Found in includes/ResourceLoader/ResourceLoader.php - About 2 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 addOneModuleResponse has 57 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function addOneModuleResponse(
                    Context $context, MinifierState $minifier, $name, Module $module, &$headers
                ) {
                    $only = $context->getOnly();
                    $debug = (bool)$context->getDebug();
            Severity: Major
            Found in includes/ResourceLoader/ResourceLoader.php - About 2 hrs to fix

              Function saveModuleDependenciesInternal has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function saveModuleDependenciesInternal( $moduleName, $variant, $paths, $priorPaths ) {
                      $hasPendingUpdate = (bool)$this->depStoreUpdateBuffer;
                      $entity = "$moduleName|$variant";
              
                      if ( array_diff( $paths, $priorPaths ) || array_diff( $priorPaths, $paths ) ) {
              Severity: Minor
              Found in includes/ResourceLoader/ResourceLoader.php - About 2 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 getLessCompiler has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getLessCompiler( array $vars = [], array $importDirs = [] ) {
                      global $IP;
                      // When called from the installer, it is possible that a required PHP extension
                      // is missing (at least for now; see T49564). If this is the case, throw an
                      // exception (caught by the installer) to prevent a fatal error later on.
              Severity: Minor
              Found in includes/ResourceLoader/ResourceLoader.php - About 1 hr to fix

                Method getSiteConfigSettings has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function getSiteConfigSettings(
                        Context $context, Config $conf
                    ): array {
                        $services = MediaWikiServices::getInstance();
                        // Namespace related preparation
                Severity: Minor
                Found in includes/ResourceLoader/ResourceLoader.php - About 1 hr to fix

                  Function sendResponseHeaders has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function sendResponseHeaders(
                          Context $context, $etag, $errors, array $extra = []
                      ): void {
                          HeaderCallback::warnIfHeadersSent();
                  
                  
                  Severity: Minor
                  Found in includes/ResourceLoader/ResourceLoader.php - About 1 hr 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 addOneModuleResponse has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function addOneModuleResponse(
                          Context $context, MinifierState $minifier, $name, Module $module, &$headers
                      ) {
                          $only = $context->getOnly();
                          $debug = (bool)$context->getDebug();
                  Severity: Minor
                  Found in includes/ResourceLoader/ResourceLoader.php - About 1 hr 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 addImplementScript has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function addImplementScript( MinifierState $minifier,
                          $moduleName, $version, $scripts, $styles, $messages, $templates, $deprecationWarning
                      ) {
                          $implementKey = "$moduleName@$version";
                          // Plain functions are used instead of arrow functions to avoid
                  Severity: Minor
                  Found in includes/ResourceLoader/ResourceLoader.php - About 1 hr 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 sendResponseHeaders has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function sendResponseHeaders(
                          Context $context, $etag, $errors, array $extra = []
                      ): void {
                          HeaderCallback::warnIfHeadersSent();
                  
                  
                  Severity: Minor
                  Found in includes/ResourceLoader/ResourceLoader.php - About 1 hr to fix

                    Method addImplementScript has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function addImplementScript( MinifierState $minifier,
                            $moduleName, $version, $scripts, $styles, $messages, $templates, $deprecationWarning
                        ) {
                            $implementKey = "$moduleName@$version";
                            // Plain functions are used instead of arrow functions to avoid
                    Severity: Minor
                    Found in includes/ResourceLoader/ResourceLoader.php - About 1 hr to fix

                      Function makeCombinedStyles has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public static function makeCombinedStyles( array $stylePairs ) {
                              $out = [];
                              foreach ( $stylePairs as $media => $styles ) {
                                  // FileModule::getStyle can return the styles as a string or an
                                  // array of strings. This is to allow separation in the front-end.
                      Severity: Minor
                      Found in includes/ResourceLoader/ResourceLoader.php - About 1 hr 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 saveModuleDependenciesInternal has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function saveModuleDependenciesInternal( $moduleName, $variant, $paths, $priorPaths ) {
                              $hasPendingUpdate = (bool)$this->depStoreUpdateBuffer;
                              $entity = "$moduleName|$variant";
                      
                              if ( array_diff( $paths, $priorPaths ) || array_diff( $priorPaths, $paths ) ) {
                      Severity: Minor
                      Found in includes/ResourceLoader/ResourceLoader.php - About 1 hr to fix

                        Method preloadModuleInfo has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function preloadModuleInfo( array $moduleNames, Context $context ) {
                                // Load all tracked indirect file dependencies for the modules
                                $vary = Module::getVary( $context );
                                $entitiesByModule = [];
                                foreach ( $moduleNames as $moduleName ) {
                        Severity: Minor
                        Found in includes/ResourceLoader/ResourceLoader.php - About 1 hr to fix

                          Method makeLoaderQuery has 10 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              public static function makeLoaderQuery( array $modules, $lang, $skin, $user = null,
                                  $version = null, $debug = Context::DEBUG_OFF, $only = null,
                                  $printable = false, $handheld = null, array $extraQuery = []
                          Severity: Major
                          Found in includes/ResourceLoader/ResourceLoader.php - About 1 hr to fix

                            Function makeLoaderRegisterScript has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public static function makeLoaderRegisterScript(
                                    Context $context, array $modules
                                ) {
                                    // Optimisation: Transform dependency names into indexes when possible
                                    // to produce smaller output. They are expanded by mw.loader.register on
                            Severity: Minor
                            Found in includes/ResourceLoader/ResourceLoader.php - About 1 hr 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 filter has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public static function filter( $filter, $data, array $options = [] ) {
                                    if ( strpos( $data, self::FILTER_NOMIN ) !== false ) {
                                        return $data;
                                    }
                            
                            
                            Severity: Minor
                            Found in includes/ResourceLoader/ResourceLoader.php - About 1 hr to fix

                              Method makeLoaderQuery has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public static function makeLoaderQuery( array $modules, $lang, $skin, $user = null,
                                      $version = null, $debug = Context::DEBUG_OFF, $only = null,
                                      $printable = false, $handheld = null, array $extraQuery = []
                                  ) {
                                      $query = [
                              Severity: Minor
                              Found in includes/ResourceLoader/ResourceLoader.php - About 1 hr to fix

                                Function getOneModuleResponse has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    private function getOneModuleResponse( Context $context, $name, Module $module ) {
                                        $only = $context->getOnly();
                                        // Important: Do not cache minifications of embedded modules
                                        // This is especially for the private 'user.options' module,
                                        // which varies on every pageview and would explode the cache (T84960)
                                Severity: Minor
                                Found in includes/ResourceLoader/ResourceLoader.php - About 1 hr 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 addImplementScript has 8 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                    private function addImplementScript( MinifierState $minifier,
                                        $moduleName, $version, $scripts, $styles, $messages, $templates, $deprecationWarning
                                Severity: Major
                                Found in includes/ResourceLoader/ResourceLoader.php - About 1 hr to fix

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

                                      public static function expandModuleNames( $modules ) {
                                          $retval = [];
                                          $exploded = explode( '|', $modules );
                                          foreach ( $exploded as $group ) {
                                              if ( strpos( $group, ',' ) === false ) {
                                  Severity: Minor
                                  Found in includes/ResourceLoader/ResourceLoader.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 trimArray has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      private static function trimArray( array &$array ): void {
                                          $i = count( $array );
                                          while ( $i-- ) {
                                              if ( $array[$i] === null
                                                  || $array[$i] === []
                                  Severity: Minor
                                  Found in includes/ResourceLoader/ResourceLoader.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 preloadModuleInfo has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      public function preloadModuleInfo( array $moduleNames, Context $context ) {
                                          // Load all tracked indirect file dependencies for the modules
                                          $vary = Module::getVary( $context );
                                          $entitiesByModule = [];
                                          foreach ( $moduleNames as $moduleName ) {
                                  Severity: Minor
                                  Found in includes/ResourceLoader/ResourceLoader.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 addSource has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      public function addSource( $sources, $loadUrl = null ) {
                                          if ( !is_array( $sources ) ) {
                                              $sources = [ $sources => $loadUrl ];
                                          }
                                          foreach ( $sources as $id => $source ) {
                                  Severity: Minor
                                  Found in includes/ResourceLoader/ResourceLoader.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 makeLoaderQuery has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      public static function makeLoaderQuery( array $modules, $lang, $skin, $user = null,
                                          $version = null, $debug = Context::DEBUG_OFF, $only = null,
                                          $printable = false, $handheld = null, array $extraQuery = []
                                      ) {
                                          $query = [
                                  Severity: Minor
                                  Found in includes/ResourceLoader/ResourceLoader.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 addFileContent has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      private function addFileContent( MinifierState $minifier,
                                          $moduleName, $sourceType, $sourceIndex, array $file
                                      ) {
                                          $isScript = ( $file['type'] ?? 'script' ) === 'script';
                                          /** @var FilePath|null $filePath */
                                  Severity: Minor
                                  Found in includes/ResourceLoader/ResourceLoader.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

                                  Consider simplifying this complex logical expression.
                                  Open

                                              if ( $array[$i] === null
                                                  || $array[$i] === []
                                                  || ( $array[$i] instanceof HtmlJsCode && $array[$i]->value === '{}' )
                                                  || ( $array[$i] instanceof stdClass && self::isEmptyObject( $array[$i] ) )
                                              ) {
                                  Severity: Major
                                  Found in includes/ResourceLoader/ResourceLoader.php - About 40 mins to fix

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

                                        private function addFileContent( MinifierState $minifier,
                                            $moduleName, $sourceType, $sourceIndex, array $file
                                    Severity: Minor
                                    Found in includes/ResourceLoader/ResourceLoader.php - About 35 mins to fix

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

                                              Context $context, MinifierState $minifier, $name, Module $module, &$headers
                                      Severity: Minor
                                      Found in includes/ResourceLoader/ResourceLoader.php - About 35 mins to fix

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

                                            public function register( $name, array $info = null ) {
                                                // Allow multiple modules to be registered in one call
                                                $registrations = is_array( $name ) ? $name : [ $name => $info ];
                                                foreach ( $registrations as $name => $info ) {
                                                    // Warn on duplicate registrations
                                        Severity: Minor
                                        Found in includes/ResourceLoader/ResourceLoader.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 [ $response, $offset ];
                                        Severity: Major
                                        Found in includes/ResourceLoader/ResourceLoader.php - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                          return [ $minifier->getMinifiedOutput(), null ];
                                          Severity: Major
                                          Found in includes/ResourceLoader/ResourceLoader.php - About 30 mins to fix

                                            Function getModule has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                            Open

                                                public function getModule( $name ) {
                                                    if ( !isset( $this->modules[$name] ) ) {
                                                        if ( !isset( $this->moduleInfos[$name] ) ) {
                                                            // No such module
                                                            return null;
                                            Severity: Minor
                                            Found in includes/ResourceLoader/ResourceLoader.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

                                            Function getCombinedVersion has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                            Open

                                                public function getCombinedVersion( Context $context, array $moduleNames ) {
                                                    if ( !$moduleNames ) {
                                                        return '';
                                                    }
                                                    $hashes = [];
                                            Severity: Minor
                                            Found in includes/ResourceLoader/ResourceLoader.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