ImpressCMS/impresscms

View on GitHub
upgrade/index.php

Summary

Maintainability
A
1 hr
Test Coverage

Function getDirList has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
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') {
Severity: Minor
Found in upgrade/index.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

Avoid assigning values to variables in if clauses and the like (line '39', column '26').
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') {
Severity: Minor
Found in upgrade/index.php by phpmd

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

    include_once "./language/".$xoopsConfig['language']."/upgrade.php";
Severity: Minor
Found in upgrade/index.php by phan

Variable $xoopsConfig is undeclared
Open

if (file_exists("./language/".$xoopsConfig['language']."/upgrade.php")) {
Severity: Minor
Found in upgrade/index.php by phan

Variable $xoopsConfig is undeclared
Open

    $language = $xoopsConfig['language'];
Severity: Minor
Found in upgrade/index.php by phan

Space after opening parenthesis of function call prohibited
Open

error_reporting( E_ALL );
Severity: Minor
Found in upgrade/index.php by phpcodesniffer

Expected 0 spaces before closing bracket; 1 found
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] );
Severity: Minor
Found in upgrade/index.php by phpcodesniffer

Expected 0 spaces before closing bracket; 1 found
Open

if (!defined( 'ICMS_ROOT_PATH' )) {
Severity: Minor
Found in upgrade/index.php by phpcodesniffer

Space after opening parenthesis of function call prohibited
Open

            array_unshift( $_SESSION['xoops_upgrade'], $next );
Severity: Minor
Found in upgrade/index.php by phpcodesniffer

Expected 0 spaces before closing bracket; 1 found
Open

    if (empty( $op )) {
Severity: Minor
Found in upgrade/index.php by phpcodesniffer

Expected 0 spaces before closing bracket; 1 found
Open

error_reporting( E_ALL );
Severity: Minor
Found in upgrade/index.php by phpcodesniffer

Space after opening parenthesis of function call prohibited
Open

    if (empty( $_SESSION['xoops_upgrade'] )) {
Severity: Minor
Found in upgrade/index.php by phpcodesniffer

Space after opening parenthesis of function call prohibited
Open

    if (empty( $op )) {
Severity: Minor
Found in upgrade/index.php by phpcodesniffer

Space after opening parenthesis of function call prohibited
Open

        printf( '<h2>' . _PERFORMING_UPGRADE . '</h2>', $next );
Severity: Minor
Found in upgrade/index.php by phpcodesniffer

Space after opening parenthesis of function call prohibited
Open

    die( 'Bad installation: please add this folder to the ImpressCMS install you want to upgrade');
Severity: Minor
Found in upgrade/index.php by phpcodesniffer

Space after opening parenthesis of function call prohibited
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] );
Severity: Minor
Found in upgrade/index.php by phpcodesniffer

Space after opening parenthesis of function call prohibited
Open

if (!defined( 'ICMS_ROOT_PATH' )) {
Severity: Minor
Found in upgrade/index.php by phpcodesniffer

Expected 0 spaces before closing bracket; 1 found
Open

                if (is_dir( "$dirname/$file" )) {
Severity: Minor
Found in upgrade/index.php by phpcodesniffer

Expected 0 spaces before closing bracket; 1 found
Open

            if (substr( $file, 0, 1 ) != '.'  && strtolower($file) != 'cvs') {
Severity: Minor
Found in upgrade/index.php by phpcodesniffer

Expected 1 newline at end of file; 0 found
Open

?>
Severity: Minor
Found in upgrade/index.php by phpcodesniffer

Expected 0 spaces before closing bracket; 1 found
Open

    if (empty( $_SESSION['xoops_upgrade'] )) {
Severity: Minor
Found in upgrade/index.php by phpcodesniffer

Space after opening parenthesis of function call prohibited
Open

        $next = array_shift( $_SESSION['xoops_upgrade'] );
Severity: Minor
Found in upgrade/index.php by phpcodesniffer

Expected 0 spaces before closing bracket; 1 found
Open

        $next = array_shift( $_SESSION['xoops_upgrade'] );
Severity: Minor
Found in upgrade/index.php by phpcodesniffer

Expected 0 spaces before closing bracket; 1 found
Open

            array_unshift( $_SESSION['xoops_upgrade'], $next );
Severity: Minor
Found in upgrade/index.php by phpcodesniffer

Expected 0 spaces before closing bracket; 1 found
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] );
Severity: Minor
Found in upgrade/index.php by phpcodesniffer

A closing tag is not permitted at the end of a PHP file
Open

?>
Severity: Minor
Found in upgrade/index.php by phpcodesniffer

Space after opening parenthesis of function call prohibited
Open

            if (substr( $file, 0, 1 ) != '.'  && strtolower($file) != 'cvs') {
Severity: Minor
Found in upgrade/index.php by phpcodesniffer

Space after opening parenthesis of function call prohibited
Open

                if (is_dir( "$dirname/$file" )) {
Severity: Minor
Found in upgrade/index.php by phpcodesniffer

Expected 0 spaces before closing bracket; 1 found
Open

        printf( '<h2>' . _PERFORMING_UPGRADE . '</h2>', $next );
Severity: Minor
Found in upgrade/index.php by phpcodesniffer

There are no issues that match your filters.

Category
Status