ImpressCMS/impresscms

View on GitHub
upgrade/upd-2.0.17-to-2.0.18/index.php

Summary

Maintainability
A
0 mins
Test Coverage

query accesses the super-global variable $GLOBALS.
Open

    function query($sql) {
        //echo "<li>" . $sql . "</li>";
        $db = $GLOBALS['xoopsDB'];
        if (!($ret = $db->queryF($sql))) {
            echo "<li style='font-weight: bold; color: red;'>" . $db->error() . "</li>";

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

apply_alter_tables accesses the super-global variable $GLOBALS.
Open

    function apply_alter_tables() {
        $db = $GLOBALS['xoopsDB'];
        $this->fields = array(
                        "config" => array(
                                        "conf_title" => "varchar(255) NOT NULL default ''",

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

check_config_type accesses the super-global variable $GLOBALS.
Open

    function check_config_type() {
        $db = $GLOBALS['xoopsDB'];
        $sql = "SHOW COLUMNS FROM " . $db->prefix("config") . " LIKE 'conf_title'";
        $result = $db->queryF( $sql );
        while ($row = $db->fetchArray($result)) {

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

Avoid unused local variables such as '$ret'.
Open

        if (!($ret = $db->queryF($sql))) {

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

Reference to undeclared property \upgrade_2018->fields
Open

        $this->fields = array(
Severity: Minor
Found in upgrade/upd-2.0.17-to-2.0.18/index.php by phan

Reference to undeclared property \upgrade_2018->fields
Open

                                        foreach ($this->fields as $table => $data) {
Severity: Minor
Found in upgrade/upd-2.0.17-to-2.0.18/index.php by phan

Avoid assigning values to variables in if clauses and the like (line '30', column '9').
Open

    function query($sql) {
        //echo "<li>" . $sql . "</li>";
        $db = $GLOBALS['xoopsDB'];
        if (!($ret = $db->queryF($sql))) {
            echo "<li style='font-weight: bold; color: red;'>" . $db->error() . "</li>";

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

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class upgrade_2018 {

Avoid variables with short names like $db. Configured minimum length is 3.
Open

        $db = $GLOBALS['xoopsDB'];

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

Avoid variables with short names like $db. Configured minimum length is 3.
Open

        $db = $GLOBALS['xoopsDB'];

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

Avoid variables with short names like $db. Configured minimum length is 3.
Open

        $db = $GLOBALS['xoopsDB'];

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

The class upgrade_2018 is not named in CamelCase.
Open

class upgrade_2018 {

    var $usedFiles = array( );

    function isApplied() {

CamelCaseClassName

Since: 0.2

It is considered best practice to use the CamelCase notation to name classes.

Example

class class_name {
}

Source

Method name "upgrade_2018::check_config_type" is not in camel caps format
Open

    function check_config_type() {

Tabs must be used to indent lines; spaces are not allowed
Open

                                        foreach ($this->fields as $table => $data) {

Visibility must be declared on method "apply"
Open

    function apply() {

Method name "upgrade_2018::apply_alter_tables" is not in camel caps format
Open

    function apply_alter_tables() {

Tabs must be used to indent lines; spaces are not allowed
Open

                                        ),

Tabs must be used to indent lines; spaces are not allowed
Open

                                        );

Tabs must be used to indent lines; spaces are not allowed
Open

                                                $sql = "ALTER TABLE " . $db->prefix($table) . " CHANGE `$field` `$field` $property";

Visibility must be declared on property "$usedFiles"
Open

    var $usedFiles = array( );

Visibility must be declared on method "isApplied"
Open

    function isApplied() {

Visibility must be declared on method "apply_alter_tables"
Open

    function apply_alter_tables() {

Tabs must be used to indent lines; spaces are not allowed
Open

                                        "conf_desc"  => "varchar(255) NOT NULL default ''"

Visibility must be declared on method "check_config_type"
Open

    function check_config_type() {

Tabs must be used to indent lines; spaces are not allowed
Open

                                            foreach ($data as $field => $property) {

Tabs must be used to indent lines; spaces are not allowed
Open

                                                $this->query( $sql );

Tabs must be used to indent lines; spaces are not allowed
Open

                                        "conf_title" => "varchar(255) NOT NULL default ''",

Tabs must be used to indent lines; spaces are not allowed
Open

                        "configcategory" => array( "confcat_name"  => "varchar(255) NOT NULL default ''" ),

Visibility must be declared on method "query"
Open

    function query($sql) {

The var keyword must not be used to declare a property
Open

    var $usedFiles = array( );

Tabs must be used to indent lines; spaces are not allowed
Open

                        "config" => array(

Tabs must be used to indent lines; spaces are not allowed
Open

                                            }

Tabs must be used to indent lines; spaces are not allowed
Open

                                        }

Tabs must be used to indent lines; spaces are not allowed
Open

                                        return true;

Line indented incorrectly; expected 3 tabs, found 11
Open

                                            foreach ($data as $field => $property) {

Expected 0 spaces before closing bracket; 1 found
Open

                                                $this->query( $sql );

Expected 0 spaces before closing bracket; 1 found
Open

        $result = $db->queryF( $sql );

Line indented incorrectly; expected 2 tabs, found 10
Open

                                        }

Space after opening parenthesis of function call prohibited
Open

                                                $this->query( $sql );

Space after opening parenthesis of function call prohibited
Open

        $result = $db->queryF( $sql );

Line indented incorrectly; expected 2 tabs, found 10
Open

                                        foreach ($this->fields as $table => $data) {

Expected 0 spaces before closing bracket; 1 found
Open

            if (strtolower( trim($row["Type"]) ) == "varchar(255)") {

Line indented incorrectly; expected 3 tabs, found 11
Open

                                            }

Space after opening parenthesis of function call prohibited
Open

            if (strtolower( trim($row["Type"]) ) == "varchar(255)") {

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

?>

Class name "upgrade_2018" is not in camel caps format
Open

class upgrade_2018 {

The method apply_alter_tables is not named in camelCase.
Open

    function apply_alter_tables() {
        $db = $GLOBALS['xoopsDB'];
        $this->fields = array(
                        "config" => array(
                                        "conf_title" => "varchar(255) NOT NULL default ''",

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method check_config_type is not named in camelCase.
Open

    function check_config_type() {
        $db = $GLOBALS['xoopsDB'];
        $sql = "SHOW COLUMNS FROM " . $db->prefix("config") . " LIKE 'conf_title'";
        $result = $db->queryF( $sql );
        while ($row = $db->fetchArray($result)) {

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

Unexpected spaces found.
Open

                                                $this->query( $sql );

Unexpected spaces found.
Open

                                        ),

Unexpected spaces found.
Open

                        "configcategory" => array( "confcat_name"  => "varchar(255) NOT NULL default ''" ),

Unexpected spaces found.
Open

                                                $sql = "ALTER TABLE " . $db->prefix($table) . " CHANGE `$field` `$field` $property";

Unexpected spaces found.
Open

                                            }

Unexpected spaces found.
Open

                        "config" => array(

Unexpected spaces found.
Open

                                        "conf_title" => "varchar(255) NOT NULL default ''",

Unexpected spaces found.
Open

                                        foreach ($this->fields as $table => $data) {

Unexpected spaces found.
Open

                                            foreach ($data as $field => $property) {

Unexpected spaces found.
Open

                                        return true;

Unexpected spaces found.
Open

                                        }

Unexpected spaces found.
Open

                                        );

Unexpected spaces found.
Open

                                        "conf_desc"  => "varchar(255) NOT NULL default ''"

There are no issues that match your filters.

Category
Status