modules/Settings/ModTracker/models/Module.php
Missing class import via use statement (line '14', column '17'). Open
Open
$query = (new \App\Db\Query())->select(['vtiger_tab.name', 'vtiger_tab.tabid', 'vtiger_modtracker_tabs.visible'])
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method getModTrackerModules has a boolean flag argument $active, which is a certain sign of a Single Responsibility Principle violation. Open
Open
public function getModTrackerModules($active = 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 changeActiveStatus uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
Open
} else {
CRMEntity::getInstance('ModTracker')->disableTrackingForModule($tabid);
}
- 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
Call to undeclared method \CRMEntity::enableTrackingForModule
Open
Open
CRMEntity::getInstance('ModTracker')->enableTrackingForModule($tabid);
- Exclude checks
Call to undeclared method \CRMEntity::disableTrackingForModule
Open
Open
CRMEntity::getInstance('ModTracker')->disableTrackingForModule($tabid);
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
Open
$query = (new \App\Db\Query())->select(['vtiger_tab.name', 'vtiger_tab.tabid', 'vtiger_modtracker_tabs.visible'])
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
Open
class Settings_ModTracker_Module_Model extends Settings_Vtiger_Module_Model
- Exclude checks
The class Settings_ModTracker_Module_Model is not named in CamelCase. Open
Open
class Settings_ModTracker_Module_Model extends Settings_Vtiger_Module_Model
{
public function getModTrackerModules($active = false)
{
$restrictedModules = ['Integration', 'Dashboard'];
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function getModTrackerModules($active = false)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
->leftJoin('vtiger_modtracker_tabs', 'vtiger_tab.tabid = vtiger_modtracker_tabs.tabid')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$modules[] = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'active' => 1 == $row['visible'] ? true : false,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if ($active) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
while ($row = $dataReader->read()) {
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
Open
$query = (new \App\Db\Query())->select(['vtiger_tab.name', 'vtiger_tab.tabid', 'vtiger_modtracker_tabs.visible'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$dataReader = $query->createCommand()->query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return $modules;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'id' => $row['tabid'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
->andWhere(['NOT IN', 'vtiger_tab.name', $restrictedModules]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'module' => $row['name'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
CRMEntity::getInstance('ModTracker')->enableTrackingForModule($tabid);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
CRMEntity::getInstance('ModTracker')->disableTrackingForModule($tabid);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$dataReader->close();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if ($status) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function changeActiveStatus($tabid, $status)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$query->andWhere(['tiger_modtracker_tabs.visible' => 1]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$restrictedModules = ['Integration', 'Dashboard'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
->where(['vtiger_tab.presence' => [0, 2], 'vtiger_tab.isentitytype' => 1])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$query = (new \App\Db\Query())->select(['vtiger_tab.name', 'vtiger_tab.tabid', 'vtiger_modtracker_tabs.visible'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
->from('vtiger_tab')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$modules = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Class name "Settings_ModTracker_Module_Model" is not in camel caps format Open
Open
class Settings_ModTracker_Module_Model extends Settings_Vtiger_Module_Model
- Exclude checks