Function getModulesArray
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getModulesArray($full = false) {
if (!is_array($this->modules_name) || !count($this->modules_name)) {
$icms_module_handler = icms::handler('icms_module');
$installed_modules = &$icms_module_handler->getObjects();
foreach ($installed_modules as $module) {
- Read upRead up
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
The method getViewItemLink has a boolean flag argument $userSide, which is a certain sign of a Single Responsibility Principle violation. Open
public function getViewItemLink($onlyUrl = false, $withimage = true, $userSide = 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 getAdminViewItemLink has a boolean flag argument $onlyUrl, which is a certain sign of a Single Responsibility Principle violation. Open
public function getAdminViewItemLink($onlyUrl = 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 getViewItemLink has a boolean flag argument $onlyUrl, which is a certain sign of a Single Responsibility Principle violation. Open
public function getViewItemLink($onlyUrl = false, $withimage = true, $userSide = 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 getViewItemLink has a boolean flag argument $withimage, which is a certain sign of a Single Responsibility Principle violation. Open
public function getViewItemLink($onlyUrl = false, $withimage = true, $userSide = 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 getModulesArray has a boolean flag argument $full, which is a certain sign of a Single Responsibility Principle violation. Open
public function getModulesArray($full = 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 getViewItemLink uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$ret = '<a href="' . $url . '" alt="' . _PREVIEW . '" title="' . _PREVIEW . '" rel="external"><img src="' . ICMS_IMAGES_SET_URL . '/actions/viewmag.png" /></a>';
}
- 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
The method getCustomPageStatus uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$rtn = '<a href="' . ICMS_MODULES_URL . '/system/admin.php?fct=pages&op=status&page_id=' . $this->getVar('page_id') . '" title="' . _VISIBLE . '" ><img src="' . ICMS_IMAGES_SET_URL . '/actions/button_cancel.png" alt="' . _VISIBLE . '"/></a>';
}
- 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 using static access to class 'icms' in method 'getModulesArray'. Open
$icms_module_handler = icms::handler('icms_module');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'icms_core_DataFilter' in method 'getViewItemLink'. Open
$url = icms_core_DataFilter::checkVar($url, 'url', 'host');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'icms_ipf_Handler' in method '__construct'. Open
icms_ipf_Handler::__construct($db, 'pages', 'page_id', 'page_title', '', 'system');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid unused parameters such as '$onlyUrl'. Open
public function getViewItemLink($onlyUrl = false, $withimage = true, $userSide = 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
Avoid unused parameters such as '$onlyUrl'. Open
public function getAdminViewItemLink($onlyUrl = 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
Avoid unused parameters such as '$withimage'. Open
public function getViewItemLink($onlyUrl = false, $withimage = true, $userSide = 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
Avoid unused parameters such as '$userSide'. Open
public function getViewItemLink($onlyUrl = false, $withimage = true, $userSide = 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
Static call to undeclared method icms_ipf_Handler::__construct()
Open
icms_ipf_Handler::__construct($db, 'pages', 'page_id', 'page_title', '', 'system');
- Exclude checks
Call to method handler
from undeclared class \icms
Open
$icms_module_handler = icms::handler('icms_module');
- Exclude checks
Reference to undeclared constant \_PREVIEW
Open
$ret = '<a href="' . $url . '" alt="' . _PREVIEW . '" title="' . _PREVIEW . '" rel="external"><img src="' . ICMS_IMAGES_SET_URL . '/actions/viewmag.png" /></a>';
- Exclude checks
Class extends undeclared class \icms_data_page_Handler
Open
class SystemPagesHandler extends icms_data_page_Handler {
- Exclude checks
Reference to undeclared constant \_VISIBLE
Open
$rtn = '<a href="' . ICMS_MODULES_URL . '/system/admin.php?fct=pages&op=status&page_id=' . $this->getVar('page_id') . '" title="' . _VISIBLE . '" ><img src="' . ICMS_IMAGES_SET_URL . '/actions/button_ok.png" alt="' . _VISIBLE . '"/></a>';
- Exclude checks
Call to undeclared method \SystemPages::setControl
Open
$this->setControl('page_moduleid', array('itemHandler' => 'pages', 'method' => 'getModulesArray', 'module' => 'system'));
- Exclude checks
Call to method __construct
from undeclared class \icms_ipf_Handler
Open
icms_ipf_Handler::__construct($db, 'pages', 'page_id', 'page_title', '', 'system');
- Exclude checks
Call to undeclared method \SystemPages::getVar
Open
if ($this->getVar('page_status') == 1) {
- Exclude checks
Reference to undeclared constant \_VISIBLE
Open
$rtn = '<a href="' . ICMS_MODULES_URL . '/system/admin.php?fct=pages&op=status&page_id=' . $this->getVar('page_id') . '" title="' . _VISIBLE . '" ><img src="' . ICMS_IMAGES_SET_URL . '/actions/button_cancel.png" alt="' . _VISIBLE . '"/></a>';
- Exclude checks
Call to undeclared method \SystemPages::getVar
Open
$url = (substr($this->getVar('page_url', 'e'), 0, 7) == 'http://') ? $this->getVar('page_url', 'e') : ICMS_URL . '/' . $this->getVar('page_url', 'e');
- Exclude checks
Reference to undeclared property \SystemPagesHandler->table
Open
$this->table = $db->prefix('icmspage');
- Exclude checks
Class extends undeclared class \icms_data_page_Object
Open
class SystemPages extends icms_data_page_Object {
- Exclude checks
Call to undeclared method \SystemPages::getVar
Open
$rtn = '<a href="' . ICMS_MODULES_URL . '/system/admin.php?fct=pages&op=status&page_id=' . $this->getVar('page_id') . '" title="' . _VISIBLE . '" ><img src="' . ICMS_IMAGES_SET_URL . '/actions/button_ok.png" alt="' . _VISIBLE . '"/></a>';
- Exclude checks
Call to undeclared method \SystemPages::getVar
Open
return $modules[$this->getVar('page_moduleid')];
- Exclude checks
Reference to undeclared class \icms_data_page_Object
Open
parent::__construct($handler);
- Exclude checks
Call to undeclared method \SystemPages::setControl
Open
$this->setControl('page_status', 'yesno');
- Exclude checks
Call to undeclared method \SystemPages::getVar
Open
$rtn = $this->getVar('page_title');
- Exclude checks
Call to method checkVar
from undeclared class \icms_core_DataFilter
Open
$url = icms_core_DataFilter::checkVar($url, 'url', 'host');
- Exclude checks
Call to undeclared method \SystemPagesHandler::get
Open
$page = $this->get($page_id);
- Exclude checks
Call to undeclared method \SystemPages::getVar
Open
$rtn = '<a href="' . ICMS_MODULES_URL . '/system/admin.php?fct=pages&op=status&page_id=' . $this->getVar('page_id') . '" title="' . _VISIBLE . '" ><img src="' . ICMS_IMAGES_SET_URL . '/actions/button_cancel.png" alt="' . _VISIBLE . '"/></a>';
- Exclude checks
Reference to undeclared property \SystemPages->handler
Open
$modules = $this->handler->getModulesArray();
- Exclude checks
Call to undeclared method \SystemPagesHandler::insert
Open
return $this->insert($page, TRUE);
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class SystemPages extends icms_data_page_Object {
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class SystemPagesHandler extends icms_data_page_Handler {
- Exclude checks
Avoid variables with short names like $db. Configured minimum length is 3. Open
public function __construct(&$db) {
- Read upRead up
- Exclude checks
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 property $modules_name is not named in camelCase. Open
class SystemPagesHandler extends icms_data_page_Handler {
/**
*/
private $modules_name;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The parameter $page_id is not named in camelCase. Open
public function changeStatus($page_id) {
$page = $this->get($page_id);
$page->setVar('page_status', !$page->getVar('page_status'));
return $this->insert($page, TRUE);
}
- 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
Each class must be in a file by itself Open
class SystemPagesHandler extends icms_data_page_Handler {
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE" Open
return $this->insert($page, TRUE);
- Exclude checks
The variable $installed_modules is not named in camelCase. Open
public function getModulesArray($full = false) {
if (!is_array($this->modules_name) || !count($this->modules_name)) {
$icms_module_handler = icms::handler('icms_module');
$installed_modules = &$icms_module_handler->getObjects();
foreach ($installed_modules as $module) {
- 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_module_handler is not named in camelCase. Open
public function getModulesArray($full = false) {
if (!is_array($this->modules_name) || !count($this->modules_name)) {
$icms_module_handler = icms::handler('icms_module');
$installed_modules = &$icms_module_handler->getObjects();
foreach ($installed_modules as $module) {
- 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_module_handler is not named in camelCase. Open
public function getModulesArray($full = false) {
if (!is_array($this->modules_name) || !count($this->modules_name)) {
$icms_module_handler = icms::handler('icms_module');
$installed_modules = &$icms_module_handler->getObjects();
foreach ($installed_modules as $module) {
- 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 $page_id is not named in camelCase. Open
public function changeStatus($page_id) {
$page = $this->get($page_id);
$page->setVar('page_status', !$page->getVar('page_status'));
return $this->insert($page, TRUE);
}
- 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 $installed_modules is not named in camelCase. Open
public function getModulesArray($full = false) {
if (!is_array($this->modules_name) || !count($this->modules_name)) {
$icms_module_handler = icms::handler('icms_module');
$installed_modules = &$icms_module_handler->getObjects();
foreach ($installed_modules as $module) {
- 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();
}
}