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.
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 ();
- Read upRead up
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')) {
- Read upRead up
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;
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 ();
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');
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')) {
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')) {
- Read upRead up
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) {
- Read upRead up
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');
- Read upRead up
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) {
- Read upRead up
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()) {
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 {
- Read upRead up
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 */
- Read upRead up
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"