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) {
- Read upRead up
- Exclude checks
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) {
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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) {
- Read upRead up
- Exclude checks
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"));
- Exclude checks
Reference to static property user
from undeclared class \icms
Open
if (!is_object(icms::$user) || !is_object($icmsModule) || !icms::$user->isAdmin($icmsModule->getVar("mid"))) {
- Exclude checks
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"));
- Exclude checks
Variable $rank_id
is undeclared Open
edituserrank(TRUE, $rank_id, TRUE);
- Exclude checks
Call to method checkVarArray
from undeclared class \icms_core_DataFilter
Open
$clean_GET = icms_core_DataFilter::checkVarArray($_GET, $filter_get, FALSE);
- Exclude checks
Call to method addColumn
from undeclared class \icms_ipf_view_Table
Open
$objectTable->addColumn(new icms_ipf_view_Column("rank_min"));
- Exclude checks
Variable $icmsAdminTpl
is undeclared Open
$icmsAdminTpl->display('db:system_adm_userrank.html');
- Exclude checks
Call to method __construct
from undeclared class \icms_ipf_Controller
Open
$controller = new icms_ipf_Controller($icms_userrank_handler);
- Exclude checks
Call to method storeFromDefaultForm
from undeclared class \icms_ipf_Controller
Open
$controller->storeFromDefaultForm(_CO_ICMS_USERRANKS_CREATED, _CO_ICMS_USERRANKS_MODIFIED);
- Exclude checks
Call to method checkVarArray
from undeclared class \icms_core_DataFilter
Open
$clean_POST = icms_core_DataFilter::checkVarArray($_POST, $filter_post, FALSE);
- Exclude checks
Variable $rank_id
is undeclared Open
edituserrank(TRUE, $rank_id);
- Exclude checks
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);
- Exclude checks
Variable $icmsModule
is undeclared Open
if (!is_object(icms::$user) || !is_object($icmsModule) || !icms::$user->isAdmin($icmsModule->getVar("mid"))) {
- Exclude checks
Call to method __construct
from undeclared class \icms_ipf_view_Column
Open
$objectTable->addColumn(new icms_ipf_view_Column("rank_min"));
- Exclude checks
Call to method __construct
from undeclared class \icms_ipf_Controller
Open
$controller = new icms_ipf_Controller($icms_userrank_handler);
- Exclude checks
Call to method addColumn
from undeclared class \icms_ipf_view_Table
Open
$objectTable->addColumn(new icms_ipf_view_Column("rank_max"));
- Exclude checks
Variable $icmsAdminTpl
is undeclared Open
$icmsAdminTpl->assign("icms_userrank_title", _CO_ICMS_USERRANKS_DSC);
- Exclude checks
Call to method __construct
from undeclared class \icms_ipf_view_Table
Open
$objectTable = new icms_ipf_view_Table($icms_userrank_handler);
- Exclude checks
Call to method __construct
from undeclared class \icms_ipf_view_Column
Open
$objectTable->addColumn(new icms_ipf_view_Column("rank_max"));
- Exclude checks
Call to method addQuickSearch
from undeclared class \icms_ipf_view_Table
Open
$objectTable->addQuickSearch(array("rank_title"));
- Exclude checks
Call to method handleObjectDeletion
from undeclared class \icms_ipf_Controller
Open
$controller->handleObjectDeletion();
- Exclude checks
Call to method addCustomAction
from undeclared class \icms_ipf_view_Table
Open
$objectTable->addCustomAction("getCloneLink");
- Exclude checks
Variable $icmsAdminTpl
is undeclared Open
$icmsAdminTpl->assign("icms_userrank_table", $objectTable->fetch());
- Exclude checks
Variable $icmsAdminTpl
is undeclared Open
$icmsAdminTpl->assign("icms_userrank_explain", TRUE);
- Exclude checks
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));
- Exclude checks
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));
- Exclude checks
Call to method fetch
from undeclared class \icms_ipf_view_Table
Open
$icmsAdminTpl->assign("icms_userrank_table", $objectTable->fetch());
- Exclude checks
Avoid excessively long variable names like $icms_userrank_handler. Keep variable name length under 20. Open
global $icms_userrank_handler, $icmsAdminTpl, $rank_id;
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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);
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE" Open
edituserrank(TRUE, $rank_id);
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE" Open
function edituserrank($showmenu = FALSE, $rank_id = 0, $clone = FALSE) {
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE" Open
function edituserrank($showmenu = FALSE, $rank_id = 0, $clone = FALSE) {
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE" Open
$icmsAdminTpl->assign("icms_userrank_explain", TRUE);
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE" Open
$clean_POST = icms_core_DataFilter::checkVarArray($_POST, $filter_post, FALSE);
- Exclude checks
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"));
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE" Open
edituserrank(TRUE, $rank_id, TRUE);
- Exclude checks
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));
- Exclude checks
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));
- Exclude checks
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));
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE" Open
edituserrank(TRUE, $rank_id, TRUE);
- Exclude checks
Inline control structures are not allowed Open
if (isset($_GET['filter_post'])) unset($_GET['filter_post']);
- Exclude checks
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);
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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();
}
}