ImpressCMS/impresscms

View on GitHub
upgrade/upd-2.0.15-to-2.0.16/index.php

Summary

Maintainability
C
1 day
Test Coverage

apply_auth_db accesses the super-global variable $GLOBALS.
Open

    function apply_auth_db() {
        $db = $GLOBALS['xoopsDB'];

        // Insert config values
        $table = $db->prefix( 'config' );

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

query accesses the super-global variable $GLOBALS.
Open

    function query( $sql) {
        $db = $GLOBALS['xoopsDB'];
        if (! ( $ret = $db->queryF( $sql ) )) {
            echo $db->error();
        }

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_auth_db accesses the super-global variable $GLOBALS.
Open

    function check_auth_db() {
        $db = $GLOBALS['xoopsDB'];
        $value = getDbValue( $db, 'config', 'conf_id',
            "`conf_name` = 'ldap_use_TLS' AND `conf_catid` = " . XOOPS_CONF_AUTH
        );

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 assigning values to variables in if clauses and the like (line '37', column '11').
Open

    function query( $sql) {
        $db = $GLOBALS['xoopsDB'];
        if (! ( $ret = $db->queryF( $sql ) )) {
            echo $db->error();
        }

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

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 constant \XOOPS_CONF_AUTH
Open

            "`conf_name` = 'ldap_use_TLS' AND `conf_catid` = " . XOOPS_CONF_AUTH
Severity: Minor
Found in upgrade/upd-2.0.15-to-2.0.16/index.php by phan

Similar blocks of code found in 2 locations. Consider refactoring.
Open

<?php

class upgrade_2016 {

    var $usedFiles = array( );
Severity: Major
Found in upgrade/upd-2.0.15-to-2.0.16/index.php and 1 other location - About 1 day to fix
upgrade/upd-2.0.16-to-2.0.17/index.php on lines 1..65

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 253.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

class upgrade_2016 {

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_2016 is not named in CamelCase.
Open

class upgrade_2016 {

    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

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

Visibility must be declared on method "isApplied"
Open

    function isApplied() {

Space found after opening bracket of FOREACH loop
Open

        foreach ( $data as $name => $values) {

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

    var $usedFiles = array( );

Visibility must be declared on method "query"
Open

    function query( $sql) {

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

               'ldap_use_TLS'    => "'_MD_AM_LDAP_USETLS', '0', '_MD_AM_LDAP_USETLS_DESC', 'yesno', 'int', 21",

Expected 0 spaces between opening bracket and argument "$sql"; 1 found
Open

    function query( $sql) {

Visibility must be declared on method "check_file_patch"
Open

    function check_file_patch() {

Visibility must be declared on method "apply_auth_db"
Open

    function apply_auth_db() {

Visibility must be declared on property "$usedFiles"
Open

    var $usedFiles = array( );

Visibility must be declared on method "apply"
Open

    function apply() {

Visibility must be declared on method "check_auth_db"
Open

    function check_auth_db() {

Method name "upgrade_2016::apply_auth_db" is not in camel caps format
Open

    function apply_auth_db() {

Method name "upgrade_2016::check_auth_db" is not in camel caps format
Open

    function check_auth_db() {

Method name "upgrade_2016::check_file_patch" is not in camel caps format
Open

    function check_file_patch() {

Only one argument is allowed per line in a multi-line function call
Open

        $value = getDbValue( $db, 'config', 'conf_id',

Only one argument is allowed per line in a multi-line function call
Open

        $value = getDbValue( $db, 'config', 'conf_id',

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

class upgrade_2016 {

Expected 1 newline at end of file; 0 found
Open

?>

Expected 0 spaces before closing bracket; 1 found
Open

            if (!getDbValue( $db, 'config', 'conf_id', "`conf_modid`=0 AND `conf_catid`=7 AND `conf_name`='$name'" )) {

Opening parenthesis of a multi-line function call must be the last content on the line
Open

        $value = getDbValue( $db, 'config', 'conf_id',

Space after opening parenthesis of function call prohibited
Open

        $table = $db->prefix( 'config' );

Expected 0 spaces before closing bracket; 1 found
Open

        $table = $db->prefix( 'config' );

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

?>

Expected 0 spaces before closing bracket; 1 found
Open

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

Space after opening parenthesis of function call prohibited
Open

            if (!getDbValue( $db, 'config', 'conf_id', "`conf_modid`=0 AND `conf_catid`=7 AND `conf_name`='$name'" )) {

Space after opening parenthesis of function call prohibited
Open

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

Expected 0 spaces after opening bracket; 1 found
Open

        foreach ( $data as $name => $values) {

The method apply_auth_db is not named in camelCase.
Open

    function apply_auth_db() {
        $db = $GLOBALS['xoopsDB'];

        // Insert config values
        $table = $db->prefix( 'config' );

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_file_patch is not named in camelCase.
Open

    function check_file_patch() {
        /* $path = XOOPS_ROOT_PATH . '/class/auth';
         $lines = file( "$path/auth_provisionning.php");
         foreach ( $lines as $line) {
            if (strpos( $line, "ldap_provisionning_upd" ) !== false) {

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_auth_db is not named in camelCase.
Open

    function check_auth_db() {
        $db = $GLOBALS['xoopsDB'];
        $value = getDbValue( $db, 'config', 'conf_id',
            "`conf_name` = 'ldap_use_TLS' AND `conf_catid` = " . XOOPS_CONF_AUTH
        );

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

               'ldap_use_TLS'    => "'_MD_AM_LDAP_USETLS', '0', '_MD_AM_LDAP_USETLS_DESC', 'yesno', 'int', 21",

There are no issues that match your filters.

Category
Status