upgrade/index.php
Function getDirList
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
function getDirList($dirname) {
$dirlist = array();
if (is_dir($dirname) && $handle = opendir($dirname)) {
while (false !== ($file = readdir($handle))) {
if (substr( $file, 0, 1 ) != '.' && strtolower($file) != 'cvs') {
- 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
Avoid assigning values to variables in if clauses and the like (line '39', column '26'). Open
Open
function getDirList($dirname) {
$dirlist = array();
if (is_dir($dirname) && $handle = opendir($dirname)) {
while (false !== ($file = readdir($handle))) {
if (substr( $file, 0, 1 ) != '.' && strtolower($file) != 'cvs') {
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Variable $xoopsConfig
is undeclared Open
Open
include_once "./language/".$xoopsConfig['language']."/upgrade.php";
- Exclude checks
Variable $xoopsConfig
is undeclared Open
Open
if (file_exists("./language/".$xoopsConfig['language']."/upgrade.php")) {
- Exclude checks
Variable $xoopsConfig
is undeclared Open
Open
$language = $xoopsConfig['language'];
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
error_reporting( E_ALL );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
$text = empty( $_SESSION['xoops_upgrade'] ) ? '<a id="link-next" href="index.php">' . _FINISH . '</a>' : sprintf('<a id="link-next" href="index.php?action=next">' . _APPLY_NEXT . '</a>', $_SESSION['xoops_upgrade'][0] );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
if (!defined( 'ICMS_ROOT_PATH' )) {
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
array_unshift( $_SESSION['xoops_upgrade'], $next );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
if (empty( $op )) {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
error_reporting( E_ALL );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
if (empty( $_SESSION['xoops_upgrade'] )) {
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
if (empty( $op )) {
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
printf( '<h2>' . _PERFORMING_UPGRADE . '</h2>', $next );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
die( 'Bad installation: please add this folder to the ImpressCMS install you want to upgrade');
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
$text = empty( $_SESSION['xoops_upgrade'] ) ? '<a id="link-next" href="index.php">' . _FINISH . '</a>' : sprintf('<a id="link-next" href="index.php?action=next">' . _APPLY_NEXT . '</a>', $_SESSION['xoops_upgrade'][0] );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
if (!defined( 'ICMS_ROOT_PATH' )) {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
if (is_dir( "$dirname/$file" )) {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
if (substr( $file, 0, 1 ) != '.' && strtolower($file) != 'cvs') {
- Exclude checks
Expected 1 newline at end of file; 0 found Open
Open
?>
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
if (empty( $_SESSION['xoops_upgrade'] )) {
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
$next = array_shift( $_SESSION['xoops_upgrade'] );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
$next = array_shift( $_SESSION['xoops_upgrade'] );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
array_unshift( $_SESSION['xoops_upgrade'], $next );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
$text = empty( $_SESSION['xoops_upgrade'] ) ? '<a id="link-next" href="index.php">' . _FINISH . '</a>' : sprintf('<a id="link-next" href="index.php?action=next">' . _APPLY_NEXT . '</a>', $_SESSION['xoops_upgrade'][0] );
- Exclude checks
A closing tag is not permitted at the end of a PHP file Open
Open
?>
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
if (substr( $file, 0, 1 ) != '.' && strtolower($file) != 'cvs') {
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
if (is_dir( "$dirname/$file" )) {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
printf( '<h2>' . _PERFORMING_UPGRADE . '</h2>', $next );
- Exclude checks