wikimedia/mediawiki-core

View on GitHub
includes/installer/Installer.php

Summary

Maintainability
F
1 wk
Test Coverage

File Installer.php has 1112 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Base code for MediaWiki installer.
 *
 * DO NOT PATCH THIS FILE IF YOU NEED TO CHANGE INSTALLER BEHAVIOR IN YOUR PACKAGE!
Severity: Major
Found in includes/installer/Installer.php - About 2 days to fix

    Installer has 67 functions (exceeds 20 allowed). Consider refactoring.
    Open

    abstract class Installer {
    
        /**
         * URL to mediawiki-announce list summary page
         */
    Severity: Major
    Found in includes/installer/Installer.php - About 1 day to fix

      Function readExtension has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          private function readExtension( $fullJsonFile, $extDeps = [], $skinDeps = [] ) {
              $load = [
                  $fullJsonFile => 1
              ];
              if ( $extDeps ) {
      Severity: Minor
      Found in includes/installer/Installer.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 readExtension has 63 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function readExtension( $fullJsonFile, $extDeps = [], $skinDeps = [] ) {
              $load = [
                  $fullJsonFile => 1
              ];
              if ( $extDeps ) {
      Severity: Major
      Found in includes/installer/Installer.php - About 2 hrs to fix

        Function dirIsExecutable has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            public function dirIsExecutable( $dir, $url ) {
                $scriptTypes = [
                    'php' => [
                        "<?php echo 'exec';",
                        "#!/var/env php\n<?php echo 'exec';",
        Severity: Minor
        Found in includes/installer/Installer.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 resetMediaWikiServices has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function resetMediaWikiServices(
                ?Config $installerConfig = null,
                $serviceOverrides = [],
                bool $disableStorage = false
            ) {
        Severity: Minor
        Found in includes/installer/Installer.php - About 1 hr to fix

          Method getInstallSteps has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function getInstallSteps( DatabaseInstaller $installer ) {
                  $coreInstallSteps = [
                      [ 'name' => 'database', 'callback' => [ $installer, 'setupDatabase' ] ],
                      [ 'name' => 'tables', 'callback' => [ $installer, 'createTables' ] ],
                      [ 'name' => 'tables-manual', 'callback' => [ $installer, 'createManualTables' ] ],
          Severity: Minor
          Found in includes/installer/Installer.php - About 1 hr to fix

            Method getExtensionInfo has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function getExtensionInfo( $type, $parentRelPath, $name ) {
                    if ( $this->getVar( 'IP' ) === null ) {
                        throw new RuntimeException( 'Cannot find extensions since the IP variable is not yet set' );
                    }
                    if ( $type !== 'extension' && $type !== 'skin' ) {
            Severity: Minor
            Found in includes/installer/Installer.php - About 1 hr to fix

              Method subscribeToMediaWikiAnnounce has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function subscribeToMediaWikiAnnounce() {
                      $status = Status::newGood();
                      $http = MediaWikiServices::getInstance()->getHttpRequestFactory();
                      if ( !$http->canMakeRequests() ) {
                          $status->warning( 'config-install-subscribe-fail',
              Severity: Minor
              Found in includes/installer/Installer.php - About 1 hr to fix

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

                    protected function getExtensionInfo( $type, $parentRelPath, $name ) {
                        if ( $this->getVar( 'IP' ) === null ) {
                            throw new RuntimeException( 'Cannot find extensions since the IP variable is not yet set' );
                        }
                        if ( $type !== 'extension' && $type !== 'skin' ) {
                Severity: Minor
                Found in includes/installer/Installer.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 dirIsExecutable has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function dirIsExecutable( $dir, $url ) {
                        $scriptTypes = [
                            'php' => [
                                "<?php echo 'exec';",
                                "#!/var/env php\n<?php echo 'exec';",
                Severity: Minor
                Found in includes/installer/Installer.php - About 1 hr to fix

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

                      protected function createSysop() {
                          $name = $this->getVar( '_AdminName' );
                          $user = User::newFromName( $name );
                  
                          if ( !$user ) {
                  Severity: Minor
                  Found in includes/installer/Installer.php - About 1 hr to fix

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

                        protected function findExtensionsByType( $type = 'extension', $directory = 'extensions' ) {
                            if ( $this->getVar( 'IP' ) === null ) {
                                return Status::newGood( [] );
                            }
                    
                    
                    Severity: Minor
                    Found in includes/installer/Installer.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 findExtensionsByType has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function findExtensionsByType( $type = 'extension', $directory = 'extensions' ) {
                            if ( $this->getVar( 'IP' ) === null ) {
                                return Status::newGood( [] );
                            }
                    
                    
                    Severity: Minor
                    Found in includes/installer/Installer.php - About 1 hr to fix

                      Method envCheckUploadsServerResponse has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected function envCheckUploadsServerResponse() {
                              $url = $this->getVar( 'wgServer' ) . $this->getVar( 'wgScriptPath' ) . '/images/README';
                              $httpRequestFactory = MediaWikiServices::getInstance()->getHttpRequestFactory();
                              $status = null;
                      
                      
                      Severity: Minor
                      Found in includes/installer/Installer.php - About 1 hr to fix

                        Method envCheckDB has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function envCheckDB() {
                                global $wgLang;
                                /** @var string|null $dbType The user-specified database type */
                                $dbType = $this->getVar( 'wgDBtype' );
                        
                        
                        Severity: Minor
                        Found in includes/installer/Installer.php - About 1 hr to fix

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

                              protected function envCheckDB() {
                                  global $wgLang;
                                  /** @var string|null $dbType The user-specified database type */
                                  $dbType = $this->getVar( 'wgDBtype' );
                          
                          
                          Severity: Minor
                          Found in includes/installer/Installer.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 createSysop has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                              protected function createSysop() {
                                  $name = $this->getVar( '_AdminName' );
                                  $user = User::newFromName( $name );
                          
                                  if ( !$user ) {
                          Severity: Minor
                          Found in includes/installer/Installer.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 subscribeToMediaWikiAnnounce has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              private function subscribeToMediaWikiAnnounce() {
                                  $status = Status::newGood();
                                  $http = MediaWikiServices::getInstance()->getHttpRequestFactory();
                                  if ( !$http->canMakeRequests() ) {
                                      $status->warning( 'config-install-subscribe-fail',
                          Severity: Minor
                          Found in includes/installer/Installer.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 Status::newFatal( 'config-extension-dependency',
                                          basename( dirname( $fullJsonFile ) ), $e->getMessage() );
                          Severity: Major
                          Found in includes/installer/Installer.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                    return Status::newGood( $ret );
                            Severity: Major
                            Found in includes/installer/Installer.php - About 30 mins to fix

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

                                  protected function envCheckMemory() {
                                      $limit = ini_get( 'memory_limit' );
                              
                                      if ( !$limit || $limit == -1 ) {
                                          return true;
                              Severity: Minor
                              Found in includes/installer/Installer.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