Method process
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function process(App\Request $request)
{
$this->preProcess($request);
$moduleName = $request->getModule();
$srcModule = $request->getByType('srcModule', 'Alnum');
Function process
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function process(App\Request $request)
{
$this->preProcess($request);
$moduleName = $request->getModule();
$srcModule = $request->getByType('srcModule', 'Alnum');
- 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
Avoid using static access to class 'ModTracker_Record_Model' in method 'process'. Open
$unreviewedChanges[$userId] = current(ModTracker_Record_Model::getUnreviewed($srcRecordId, $userId));
- 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 'App\Config' in method 'process'. Open
if (App\Config::module('ModTracker', 'UNREVIEWED_COUNT')) {
- 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
The method process uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$watchdog = \App\Privilege::isPermitted($srcModule, 'WatchingModule');
}
- 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 process uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$srcRecordId = 0;
}
- 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 'Vtiger_Module_Model' in method 'process'. Open
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
- 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 '\App\Privilege' in method 'process'. Open
$watchdog = \App\Privilege::isPermitted($srcModule, 'WatchingRecords');
- 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 '\App\Privilege' in method 'process'. Open
$watchdog = \App\Privilege::isPermitted($srcModule, 'WatchingModule');
- 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 local variables such as '$permission'. Open
foreach ($userPermission as $userId => $permission) {
- Read upRead up
- Exclude checks
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
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('USERS_PERMISSION', $userPermission);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('ACTIONS', $actions);
- Exclude checks
Call to undeclared method \Vtiger_Module_Model::getUsersPermission
Open
$userPermission = $moduleModel->getUsersPermission();
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('UNREVIEWED_CHANGES', $unreviewedChanges);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('SRC_RECORD_ID', $srcRecordId);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('WATCHDOG', $watchdog);
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class PermissionInspector_UserListModal_View extends Vtiger_BasicModal_View
- Exclude checks
The class PermissionInspector_UserListModal_View is not named in CamelCase. Open
class PermissionInspector_UserListModal_View extends Vtiger_BasicModal_View
{
/** {@inheritdoc} */
public function getSize(App\Request $request)
{
- 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
$moduleName = $request->getModule();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return array_merge(parent::getModalScripts($request), $this->checkAndConvertJsScripts([
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getModalCss(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 'modal-lg c-modal--fit-lg';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$srcRecordId = $request->getInteger('srcRecord');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'~libraries/datatables.net-bs4/js/dataTables.bootstrap4.js',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->preProcess($request);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return array_merge(parent::getModalCss($request), $this->checkAndConvertCssStyles([
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($srcRecordId) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$srcRecordId = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$unreviewedChanges[$userId] = current(ModTracker_Record_Model::getUnreviewed($srcRecordId, $userId));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'~libraries/datatables.net-responsive-bs4/js/responsive.bootstrap4.js'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel->set('sourceModule', $srcModule);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'~libraries/datatables.net-responsive/js/dataTables.responsive.js',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($request->has('srcRecord')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (App\Config::module('ModTracker', 'UNREVIEWED_COUNT')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('WATCHDOG', $watchdog);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function process(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$unreviewedChanges = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('USERS_PERMISSION', $userPermission);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel->set('actions', $actions);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getModalScripts(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
]));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
$unreviewedChanges[$userId] = current(ModTracker_Record_Model::getUnreviewed($srcRecordId, $userId));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('ACTIONS', $actions);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->postProcess($request);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
]));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'~libraries/datatables.net-responsive-bs4/css/responsive.bootstrap4.css'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getSize(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$watchdog = \App\Privilege::isPermitted($srcModule, 'WatchingModule');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'~libraries/datatables.net/js/jquery.dataTables.js',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'~libraries/datatables.net-bs4/css/dataTables.bootstrap4.css',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$srcModule = $request->getByType('srcModule', 'Alnum');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$watchdog = \App\Privilege::isPermitted($srcModule, 'WatchingRecords');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel->set('sourceRecord', $srcRecordId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$actions = ['DetailView', 'CreateView', 'EditView', 'Delete'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($userPermission as $userId => $permission) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$userPermission = $moduleModel->getUsersPermission();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('UNREVIEWED_CHANGES', $unreviewedChanges);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer = $this->getViewer($request);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('SRC_RECORD_ID', $srcRecordId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->view('UserListModal.tpl', $moduleName);
- Exclude checks
Class name "PermissionInspector_UserListModal_View" is not in camel caps format Open
class PermissionInspector_UserListModal_View extends Vtiger_BasicModal_View
- Exclude checks