Missing class import via use statement (line '69', column '14'). Open
throw new \App\Exceptions\AppException(\App\Language::translate('ERR_TREE_NOT_FOUND', $moduleName));
- 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
Missing class import via use statement (line '38', column '14'). Open
throw new \App\Exceptions\NoPermitted('LBL_NO_PERMISSIONS_TO_FIELD');
- 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
Missing class import via use statement (line '33', column '14'). Open
throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);
- 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
Avoid using static access to class 'Settings_TreesManager_Record_Model' in method 'process'. Open
$recordModel = Settings_TreesManager_Record_Model::getInstanceById($templateId);
- 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 {
$this->successBtn = '';
}
- 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 '\App\Language' in method 'process'. Open
throw new \App\Exceptions\AppException(\App\Language::translate('ERR_TREE_NOT_FOUND', $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 'Users_Privileges_Model' in method 'checkPermission'. Open
$userModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
- 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\Json' in method 'process'. Open
$viewer->assign('TREE', \App\Json::encode($recordModel->getTree($type, $request->getByType('value', 'Text'))));
- 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
Define a constant instead of duplicating this literal "multiple" 3 times. Open
if ($request->getBoolean('multiple')) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Class extends undeclared class \App\Controller\Modal
Open
class Vtiger_TreeModal_View extends \App\Controller\Modal
- Exclude checks
Call to undeclared method \Vtiger_TreeModal_View::checkAndConvertJsScripts
Open
return array_merge(parent::getModalScripts($request), $this->checkAndConvertJsScripts($jsFileNames));
- Exclude checks
Reference to undeclared class \App\Controller\Modal
Open
parent::preProcessAjax($request);
- Exclude checks
Reference to undeclared class \App\Controller\Modal
Open
return array_merge(parent::getModalCss($request), $this->checkAndConvertCssStyles([
- Exclude checks
Call to undeclared method \Vtiger_TreeModal_View::getViewer
Open
$viewer = $this->getViewer($request);
- Exclude checks
Call to deprecated function \Vtiger_Field_Model::getFieldLabel()
defined at /code/modules/Vtiger/models/Field.php:215
Open
$this->pageTitle = $this->fieldModel->getFieldLabel();
- Exclude checks
Reference to undeclared class \App\Controller\Modal
Open
return array_merge(parent::getModalScripts($request), $this->checkAndConvertJsScripts($jsFileNames));
- Exclude checks
Reference to undeclared property \Vtiger_TreeModal_View->pageTitle
Open
$this->pageTitle = $this->fieldModel->getFieldLabel();
- Exclude checks
Call to undeclared method \Vtiger_TreeModal_View::checkAndConvertCssStyles
Open
return array_merge(parent::getModalCss($request), $this->checkAndConvertCssStyles([
- Exclude checks
Call to undeclared method \Vtiger_TreeModal_View::getViewer
Open
$viewer = $this->getViewer($request);
- Exclude checks
Argument 1 (mixed)
is string
but \Users_Privileges_Model::hasModulePermission()
takes int
defined at /code/modules/Users/models/Privileges.php:101
Open
if (!$userModel->hasModulePermission($request->getModule())) {
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Vtiger_TreeModal_View extends \App\Controller\Modal
- Exclude checks
The class Vtiger_TreeModal_View is not named in CamelCase. Open
class Vtiger_TreeModal_View extends \App\Controller\Modal
{
/**
* The name of the success button.
*
- 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
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function preProcessAjax(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
if ($request->getBoolean('multiple')) {
- 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
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->fieldModel = Vtiger_Module_Model::getInstance($request->getModule())->getFieldByName($request->getByType('fieldName', 2));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
parent::preProcessAjax($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
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $successBtn = 'LBL_SELECT_OPTION';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $fieldModel;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$userModel->hasModulePermission($request->getModule())) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\NoPermitted('LBL_NO_PERMISSIONS_TO_FIELD');
- 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
Line exceeds 120 characters; contains 157 characters Open
if (!$this->fieldModel || !$this->fieldModel->isViewable() || !\in_array($this->fieldModel->getFieldDataType(), ['categoryMultipicklist', 'tree'])) {
- 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
$recordModel = Settings_TreesManager_Record_Model::getInstanceById($templateId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->successBtn = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('TREE', \App\Json::encode($recordModel->getTree($type, $request->getByType('value', 'Text'))));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$jsFileNames[] = '~layouts/resources/libraries/jstree.category.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
{
- 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
public function checkPermission(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
$templateId = (int) $this->fieldModel->getFieldParams();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$recordModel) {
- 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
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
* The name of the success button.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$this->fieldModel || !$this->fieldModel->isViewable() || !\in_array($this->fieldModel->getFieldDataType(), ['categoryMultipicklist', 'tree'])) {
- 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
return 'Modals/TreeHeader.tpl';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\AppException(\App\Language::translate('ERR_TREE_NOT_FOUND', $moduleName));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$type = 'category';
- Exclude checks
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
$jsFileNames = array_merge($jsFileNames, [
- 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
Line exceeds 120 characters; contains 137 characters Open
$this->fieldModel = Vtiger_Module_Model::getInstance($request->getModule())->getFieldByName($request->getByType('fieldName', 2));
- 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
return array_merge(parent::getModalScripts($request), $this->checkAndConvertJsScripts($jsFileNames));
- 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
* @var Vtiger_Field_Model
- 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
throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);
- 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
$this->pageTitle = $this->fieldModel->getFieldLabel();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected function preProcessTplName(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Tree in popup.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('MODULE', $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('IS_MULTIPLE', $request->getBoolean('multiple'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->view('Modals/TreeModal.tpl', $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var string
- 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
* Field model.
- 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('FIELD_INSTANCE', $this->fieldModel);
- 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
$type = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($request->getBoolean('multiple')) {
- 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
'modules.Vtiger.resources.TreeModal',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
"modules.$moduleName.resources.TreeModal",
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'~libraries/jstree-bootstrap-theme/dist/themes/proton/style.css',
- 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
$userModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
- 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
$jsFileNames = ['~libraries/jstree/dist/jstree.js'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$jsFileNames[] = '~layouts/resources/libraries/jstree.checkbox.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
/** {@inheritdoc} */
- 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
*/
- 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
* @param \App\Request $request
- 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
$moduleName = $request->getModule();
- Exclude checks
Class name "Vtiger_TreeModal_View" is not in camel caps format Open
class Vtiger_TreeModal_View extends \App\Controller\Modal
- Exclude checks