wikimedia/mediawiki-core

View on GitHub
includes/ResourceLoader/ForeignResourceManager.php

Summary

Maintainability
D
2 days
Test Coverage

Function handleTypeTar has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    private function handleTypeTar( $moduleName, $destDir, array $info, string $fileType ) {
        $info += [ 'src' => null, 'integrity' => null, 'dest' => null ];
        if ( $info['src'] === null ) {
            throw new LogicException( "Module '$moduleName' must have a 'src' key." );
        }
Severity: Minor
Found in includes/ResourceLoader/ForeignResourceManager.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

File ForeignResourceManager.php has 303 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: Minor
Found in includes/ResourceLoader/ForeignResourceManager.php - About 3 hrs to fix

    Function run has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        public function run( $action, $module ) {
            $actions = [ 'update', 'verify', 'make-sri' ];
            if ( !in_array( $action, $actions ) ) {
                $this->error( "Invalid action.\n\nMust be one of " . implode( ', ', $actions ) . '.' );
                return false;
    Severity: Minor
    Found in includes/ResourceLoader/ForeignResourceManager.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 run has 66 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function run( $action, $module ) {
            $actions = [ 'update', 'verify', 'make-sri' ];
            if ( !in_array( $action, $actions ) ) {
                $this->error( "Invalid action.\n\nMust be one of " . implode( ', ', $actions ) . '.' );
                return false;
    Severity: Major
    Found in includes/ResourceLoader/ForeignResourceManager.php - About 2 hrs to fix

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

          private function handleTypeTar( $moduleName, $destDir, array $info, string $fileType ) {
              $info += [ 'src' => null, 'integrity' => null, 'dest' => null ];
              if ( $info['src'] === null ) {
                  throw new LogicException( "Module '$moduleName' must have a 'src' key." );
              }
      Severity: Major
      Found in includes/ResourceLoader/ForeignResourceManager.php - About 2 hrs to fix

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

            private function fetch( string $src, $integrity, string $moduleName ) {
                if ( $integrity !== null ) {
                    $key = $this->cacheKey( $src, $integrity, $moduleName );
                    $data = $this->cacheGet( $key );
                    if ( $data ) {
        Severity: Minor
        Found in includes/ResourceLoader/ForeignResourceManager.php - About 1 hr to fix

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

              private function cleanUp() {
                  wfRecursiveRemoveDir( $this->tmpParentDir );
          
                  // Prune the cache of files we don't recognise.
                  $knownKeys = [];
          Severity: Minor
          Found in includes/ResourceLoader/ForeignResourceManager.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 fetch has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              private function fetch( string $src, $integrity, string $moduleName ) {
                  if ( $integrity !== null ) {
                      $key = $this->cacheKey( $src, $integrity, $moduleName );
                      $data = $this->cacheGet( $key );
                      if ( $data ) {
          Severity: Minor
          Found in includes/ResourceLoader/ForeignResourceManager.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 handleTypeMultiFile has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              private function handleTypeMultiFile( $moduleName, $destDir, array $info ) {
                  if ( !isset( $info['files'] ) ) {
                      throw new LogicException( "Module '$moduleName' must have a 'files' key." );
                  }
                  foreach ( $info['files'] as $dest => $file ) {
          Severity: Minor
          Found in includes/ResourceLoader/ForeignResourceManager.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 __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  $registryFile,
                  $libDir,
                  callable $infoPrinter = null,
                  callable $errorPrinter = null,
                  callable $verbosePrinter = null
          Severity: Minor
          Found in includes/ResourceLoader/ForeignResourceManager.php - About 35 mins to fix

            There are no issues that match your filters.

            Category
            Status