wikimedia/mediawiki-core

View on GitHub
maintenance/convertExtensionToRegistration.php

Summary

Maintainability
D
2 days
Test Coverage

Function execute has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        // Extensions will do stuff like $wgResourceModules += array(...) which is a
        // fatal unless an array is already set. So set an empty value.
        // And use the weird $__settings name to avoid any conflicts
        // with real poorly named settings.
Severity: Minor
Found in maintenance/convertExtensionToRegistration.php - About 5 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 execute has 88 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function execute() {
        // Extensions will do stuff like $wgResourceModules += array(...) which is a
        // fatal unless an array is already set. So set an empty value.
        // And use the weird $__settings name to avoid any conflicts
        // with real poorly named settings.
Severity: Major
Found in maintenance/convertExtensionToRegistration.php - About 3 hrs to fix

    Function handleResourceModules has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function handleResourceModules( $realName, $value ) {
            $defaults = [];
            $remote = $this->hasOption( 'skin' ) ? 'remoteSkinPath' : 'remoteExtPath';
            foreach ( $value as $name => $data ) {
                if ( isset( $data['localBasePath'] ) ) {
    Severity: Minor
    Found in maintenance/convertExtensionToRegistration.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

    File convertExtensionToRegistration.php has 279 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    use Wikimedia\Composer\ComposerJson;
    
    require_once __DIR__ . '/Maintenance.php';
    Severity: Minor
    Found in maintenance/convertExtensionToRegistration.php - About 2 hrs to fix

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

          public function handleHooks( $realName, $value ) {
              foreach ( $value as $hookName => &$handlers ) {
                  if ( $hookName === 'UnitTestsList' ) {
                      $this->output( "Note: the UnitTestsList hook is no longer necessary as " .
                          "long as your tests are located in the \"tests/phpunit/\" directory. " .
      Severity: Minor
      Found in maintenance/convertExtensionToRegistration.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 handleResourceModules has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function handleResourceModules( $realName, $value ) {
              $defaults = [];
              $remote = $this->hasOption( 'skin' ) ? 'remoteSkinPath' : 'remoteExtPath';
              foreach ( $value as $name => $data ) {
                  if ( isset( $data['localBasePath'] ) ) {
      Severity: Minor
      Found in maintenance/convertExtensionToRegistration.php - About 1 hr to fix

        There are no issues that match your filters.

        Category
        Status