ImpressCMS/impresscms

View on GitHub
htdocs/modules/system/admin/userrank/main.php

Summary

Maintainability
A
0 mins
Test Coverage

The method edituserrank has a boolean flag argument $clone, which is a certain sign of a Single Responsibility Principle violation.
Open

function edituserrank($showmenu = FALSE, $rank_id = 0, $clone = FALSE) {

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

The method edituserrank has a boolean flag argument $showmenu, which is a certain sign of a Single Responsibility Principle violation.
Open

function edituserrank($showmenu = FALSE, $rank_id = 0, $clone = FALSE) {

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

The method edituserrank uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

    } else {
        $userrankObj->setVar("rank_id", 0);
        $sform = $userrankObj->getForm(_CO_ICMS_USERRANKS_CREATE, "adduserrank");
        $sform->assign($icmsAdminTpl);
        $icmsAdminTpl->assign("icms_userrank_title", _CO_ICMS_USERRANKS_CREATE_INFO);

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Avoid unused parameters such as '$showmenu'.
Open

function edituserrank($showmenu = FALSE, $rank_id = 0, $clone = FALSE) {

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

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

Call to method addColumn from undeclared class \icms_ipf_view_Table
Open

        $objectTable->addColumn(new icms_ipf_view_Column("rank_title", _GLOBAL_LEFT, FALSE, "getRankTitle"));

Reference to static property user from undeclared class \icms
Open

if (!is_object(icms::$user) || !is_object($icmsModule) || !icms::$user->isAdmin($icmsModule->getVar("mid"))) {

Call to method __construct from undeclared class \icms_ipf_view_Column
Open

        $objectTable->addColumn(new icms_ipf_view_Column("rank_title", _GLOBAL_LEFT, FALSE, "getRankTitle"));

Variable $rank_id is undeclared
Open

        edituserrank(TRUE, $rank_id, TRUE);

Call to method checkVarArray from undeclared class \icms_core_DataFilter
Open

    $clean_GET = icms_core_DataFilter::checkVarArray($_GET, $filter_get, FALSE);

Call to method addColumn from undeclared class \icms_ipf_view_Table
Open

        $objectTable->addColumn(new icms_ipf_view_Column("rank_min"));

Variable $icmsAdminTpl is undeclared
Open

        $icmsAdminTpl->display('db:system_adm_userrank.html');

Call to method __construct from undeclared class \icms_ipf_Controller
Open

        $controller = new icms_ipf_Controller($icms_userrank_handler);

Call to method storeFromDefaultForm from undeclared class \icms_ipf_Controller
Open

        $controller->storeFromDefaultForm(_CO_ICMS_USERRANKS_CREATED, _CO_ICMS_USERRANKS_MODIFIED);

Call to method checkVarArray from undeclared class \icms_core_DataFilter
Open

    $clean_POST = icms_core_DataFilter::checkVarArray($_POST, $filter_post, FALSE);

Variable $rank_id is undeclared
Open

        edituserrank(TRUE, $rank_id);

Call to method addIntroButton from undeclared class \icms_ipf_view_Table
Open

        $objectTable->addIntroButton("adduserrank", "admin.php?fct=userrank&op=mod", _CO_ICMS_USERRANKS_CREATE);

Variable $icmsModule is undeclared
Open

if (!is_object(icms::$user) || !is_object($icmsModule) || !icms::$user->isAdmin($icmsModule->getVar("mid"))) {

Call to method __construct from undeclared class \icms_ipf_view_Column
Open

        $objectTable->addColumn(new icms_ipf_view_Column("rank_min"));

Call to method __construct from undeclared class \icms_ipf_Controller
Open

        $controller = new icms_ipf_Controller($icms_userrank_handler);

Call to method addColumn from undeclared class \icms_ipf_view_Table
Open

        $objectTable->addColumn(new icms_ipf_view_Column("rank_max"));

Variable $icmsAdminTpl is undeclared
Open

        $icmsAdminTpl->assign("icms_userrank_title", _CO_ICMS_USERRANKS_DSC);

Call to method __construct from undeclared class \icms_ipf_view_Table
Open

        $objectTable = new icms_ipf_view_Table($icms_userrank_handler);

Call to method __construct from undeclared class \icms_ipf_view_Column
Open

        $objectTable->addColumn(new icms_ipf_view_Column("rank_max"));

Call to method addQuickSearch from undeclared class \icms_ipf_view_Table
Open

        $objectTable->addQuickSearch(array("rank_title"));

Call to method handleObjectDeletion from undeclared class \icms_ipf_Controller
Open

        $controller->handleObjectDeletion();

Call to method addCustomAction from undeclared class \icms_ipf_view_Table
Open

        $objectTable->addCustomAction("getCloneLink");

Variable $icmsAdminTpl is undeclared
Open

        $icmsAdminTpl->assign("icms_userrank_table", $objectTable->fetch());

Variable $icmsAdminTpl is undeclared
Open

        $icmsAdminTpl->assign("icms_userrank_explain", TRUE);

Call to method addColumn from undeclared class \icms_ipf_view_Table
Open

        $objectTable->addColumn(new icms_ipf_view_Column("rank_image", "center", 200, "getRankPicture", FALSE, FALSE, FALSE));

Call to method __construct from undeclared class \icms_ipf_view_Column
Open

        $objectTable->addColumn(new icms_ipf_view_Column("rank_image", "center", 200, "getRankPicture", FALSE, FALSE, FALSE));

Call to method fetch from undeclared class \icms_ipf_view_Table
Open

        $icmsAdminTpl->assign("icms_userrank_table", $objectTable->fetch());

Avoid excessively long variable names like $icms_userrank_handler. Keep variable name length under 20.
Open

    global $icms_userrank_handler, $icmsAdminTpl, $rank_id;

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

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

The parameter $rank_id is not named in camelCase.
Open

function edituserrank($showmenu = FALSE, $rank_id = 0, $clone = FALSE) {
    global $icms_userrank_handler, $icmsAdminTpl, $rank_id;

    icms_cp_header();
    $userrankObj = $icms_userrank_handler->get($rank_id);

CamelCaseParameterName

Since: 0.2

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

Example

class ClassName {
    public function doSomething($user_name) {
    }
}

Source

TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE"
Open

    $clean_GET = icms_core_DataFilter::checkVarArray($_GET, $filter_get, FALSE);

TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE"
Open

        edituserrank(TRUE, $rank_id);

TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE"
Open

function edituserrank($showmenu = FALSE, $rank_id = 0, $clone = FALSE) {

TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE"
Open

function edituserrank($showmenu = FALSE, $rank_id = 0, $clone = FALSE) {

TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE"
Open

        $icmsAdminTpl->assign("icms_userrank_explain", TRUE);

TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE"
Open

    $clean_POST = icms_core_DataFilter::checkVarArray($_POST, $filter_post, FALSE);

TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE"
Open

        $objectTable->addColumn(new icms_ipf_view_Column("rank_title", _GLOBAL_LEFT, FALSE, "getRankTitle"));

TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE"
Open

        edituserrank(TRUE, $rank_id, TRUE);

TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE"
Open

        $objectTable->addColumn(new icms_ipf_view_Column("rank_image", "center", 200, "getRankPicture", FALSE, FALSE, FALSE));

TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE"
Open

        $objectTable->addColumn(new icms_ipf_view_Column("rank_image", "center", 200, "getRankPicture", FALSE, FALSE, FALSE));

TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE"
Open

        $objectTable->addColumn(new icms_ipf_view_Column("rank_image", "center", 200, "getRankPicture", FALSE, FALSE, FALSE));

TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE"
Open

        edituserrank(TRUE, $rank_id, TRUE);

Inline control structures are not allowed
Open

    if (isset($_GET['filter_post'])) unset($_GET['filter_post']);

The variable $icms_userrank_handler is not named in camelCase.
Open

function edituserrank($showmenu = FALSE, $rank_id = 0, $clone = FALSE) {
    global $icms_userrank_handler, $icmsAdminTpl, $rank_id;

    icms_cp_header();
    $userrankObj = $icms_userrank_handler->get($rank_id);

CamelCaseVariableName

Since: 0.2

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

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $icms_userrank_handler is not named in camelCase.
Open

function edituserrank($showmenu = FALSE, $rank_id = 0, $clone = FALSE) {
    global $icms_userrank_handler, $icmsAdminTpl, $rank_id;

    icms_cp_header();
    $userrankObj = $icms_userrank_handler->get($rank_id);

CamelCaseVariableName

Since: 0.2

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

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $rank_id is not named in camelCase.
Open

function edituserrank($showmenu = FALSE, $rank_id = 0, $clone = FALSE) {
    global $icms_userrank_handler, $icmsAdminTpl, $rank_id;

    icms_cp_header();
    $userrankObj = $icms_userrank_handler->get($rank_id);

CamelCaseVariableName

Since: 0.2

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

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $rank_id is not named in camelCase.
Open

function edituserrank($showmenu = FALSE, $rank_id = 0, $clone = FALSE) {
    global $icms_userrank_handler, $icmsAdminTpl, $rank_id;

    icms_cp_header();
    $userrankObj = $icms_userrank_handler->get($rank_id);

CamelCaseVariableName

Since: 0.2

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

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

There are no issues that match your filters.

Category
Status