modxcms/revolution

View on GitHub
setup/includes/modinstall.class.php

Summary

Maintainability
F
3 days
Test Coverage

File modinstall.class.php has 402 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/*
 * This file is part of MODX Revolution.
 *
 * Copyright (c) MODX, LLC. All Rights Reserved.
Severity: Minor
Found in setup/includes/modinstall.class.php - About 5 hrs to fix

    Function getConnection has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getConnection($mode = 0) {
            if ($this->settings && empty($mode)) $mode = (int)$this->settings->get('installmode');
            if (empty($mode)) $mode = modInstall::MODE_NEW;
            if ($mode === modInstall::MODE_UPGRADE_REVO) {
                $errors = array ();
    Severity: Minor
    Found in setup/includes/modinstall.class.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 installPackage has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        public function installPackage($pkg, array $attributes = array ()) {
            $errors = array ();
    
            /* instantiate the modX class */
            if (@ require_once (MODX_CORE_PATH . 'model/modx/modx.class.php')) {
    Severity: Minor
    Found in setup/includes/modinstall.class.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

    modInstall has 24 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class modInstall {
        const MODE_NEW = 0;
        const MODE_UPGRADE_REVO = 1;
        const MODE_UPGRADE_EVO = 2;
        const MODE_UPGRADE_REVO_ADVANCED = 3;
    Severity: Minor
    Found in setup/includes/modinstall.class.php - About 2 hrs to fix

      Method getConnection has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getConnection($mode = 0) {
              if ($this->settings && empty($mode)) $mode = (int)$this->settings->get('installmode');
              if (empty($mode)) $mode = modInstall::MODE_NEW;
              if ($mode === modInstall::MODE_UPGRADE_REVO) {
                  $errors = array ();
      Severity: Minor
      Found in setup/includes/modinstall.class.php - About 1 hr to fix

        Method cleanup has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function cleanup(array $options = array ()) {
                $errors = array();
                $modx = $this->_modx($errors);
                if (empty($modx) || !($modx instanceof modX)) {
                    $errors['modx_class'] = $this->lexicon('modx_err_instantiate');
        Severity: Minor
        Found in setup/includes/modinstall.class.php - About 1 hr to fix

          Method installPackage has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function installPackage($pkg, array $attributes = array ()) {
                  $errors = array ();
          
                  /* instantiate the modX class */
                  if (@ require_once (MODX_CORE_PATH . 'model/modx/modx.class.php')) {
          Severity: Minor
          Found in setup/includes/modinstall.class.php - About 1 hr to fix

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

                private function _modx(array & $errors) {
                    $modx = null;
            
                    /* to validate installation, instantiate the modX class and run a few tests */
                    if (include_once (MODX_CORE_PATH . 'model/modx/modx.class.php')) {
            Severity: Minor
            Found in setup/includes/modinstall.class.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 lock has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public function lock() {
                    $errors = array();
            
                    $modx = $this->_modx($errors);
                    if ($modx) {
            Severity: Minor
            Found in setup/includes/modinstall.class.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 cleanup has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public function cleanup(array $options = array ()) {
                    $errors = array();
                    $modx = $this->_modx($errors);
                    if (empty($modx) || !($modx instanceof modX)) {
                        $errors['modx_class'] = $this->lexicon('modx_err_instantiate');
            Severity: Minor
            Found in setup/includes/modinstall.class.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 removeSetupDirectory has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public function removeSetupDirectory(array $options = array()) {
                    $errors = array();
            
                    $modx = $this->_modx($errors);
                    if ($modx) {
            Severity: Minor
            Found in setup/includes/modinstall.class.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 _connect has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public function _connect($dsn, $user = '', $password = '', $prefix = '', array $options = array()) {
            Severity: Minor
            Found in setup/includes/modinstall.class.php - About 35 mins to fix

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

                  public function getInstallMode() {
                      $mode = modInstall::MODE_NEW;
                      if (isset ($_POST['installmode'])) {
                          $mode = intval($_POST['installmode']);
                      } else {
              Severity: Minor
              Found in setup/includes/modinstall.class.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

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

                  public function is_writable2($path) {
                      $written = false;
                      if (!is_string($path)) return false;
              
                      /* if is file get parent dir */
              Severity: Minor
              Found in setup/includes/modinstall.class.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