Avoid using static access to class 'Vtiger_Module_Model' in method 'getPickListValueForField'. Open
$fieldModel = Settings_Picklist_Field_Model::getInstance($pickFieldName, Vtiger_Module_Model::getInstance($sourceModule));
- 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 'Vtiger_Module_Model' in method 'getPickListValueByRole'. Open
$fieldModel = Settings_Picklist_Field_Model::getInstance($pickFieldName, Vtiger_Module_Model::getInstance($sourceModule));
- 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\Fields\Picklist' in method 'getPickListValueForField'. Open
$selectedFieldAllPickListValues = App\Fields\Picklist::getValuesName($fieldModel->getName());
- 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 'Settings_Roles_Record_Model' in method 'getPickListValueForField'. Open
$viewer->assign('ROLES_LIST', Settings_Roles_Record_Model::getAll());
- 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\Fields\Picklist' in method 'getPickListValueByRole'. Open
$allPickListValues = App\Fields\Picklist::getValuesName($fieldModel->getName());
- 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 'Settings_Picklist_Field_Model' in method 'getPickListValueForField'. Open
$fieldModel = Settings_Picklist_Field_Model::getInstance($pickFieldName, Vtiger_Module_Model::getInstance($sourceModule));
- 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 'Settings_Picklist_Field_Model' in method 'getPickListValueByRole'. Open
$fieldModel = Settings_Picklist_Field_Model::getInstance($pickFieldName, Vtiger_Module_Model::getInstance($sourceModule));
- 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 "SELECTED_MODULE_NAME" 3 times. Open
$viewer->assign('SELECTED_MODULE_NAME', $sourceModule);
- 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.
Define a constant instead of duplicating this literal "source_module" 3 times. Open
$sourceModule = $request->getByType('source_module', 2);
- 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.
Define a constant instead of duplicating this literal "QUALIFIED_MODULE" 3 times. Open
$viewer->assign('QUALIFIED_MODULE', $qualifiedName);
- 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.
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('SELECTED_PICKLIST_FIELDMODEL', $fieldModel);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('QUALIFIED_MODULE', $qualifiedName);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('SELECTED_PICKLISTFIELD_ALL_VALUES', $selectedFieldAllPickListValues);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('PICKLIST_FIELDS', $pickListFields);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('ROLES_LIST', Settings_Roles_Record_Model::getAll());
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('PICKLIST_INTERDEPENDENT', $moduleModel->listModuleInterdependentPickList(array_keys($pickListFields)));
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('QUALIFIED_MODULE', $qualifiedName);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('MODULE', $moduleName);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('SELECTED_MODULE_NAME', $sourceModule);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('SELECTED_MODULE_NAME', $sourceModule);
- Exclude checks
Argument 1 (roleIdList)
is array{0:bool|mixed}
but \Settings_Picklist_Field_Model::getPicklistValuesForRole()
takes \type
defined at /code/modules/Settings/Picklist/models/Field.php:51
Open
$pickListValuesForRole = $fieldModel->getPicklistValuesForRole([$userSelectedRoleId], 'CONJUNCTION');
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('ROLE_PICKLIST_VALUES', $pickListValuesForRole);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('ALL_PICKLIST_VALUES', $allPickListValues);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('SELECTED_MODULE_NAME', $sourceModule);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('SELECTED_PICKLIST_FIELDMODEL', $fieldModel);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('QUALIFIED_MODULE', $qualifiedName);
- Exclude checks
Avoid excessively long variable names like $pickListValuesForRole. Keep variable name length under 20. Open
$pickListValuesForRole = $fieldModel->getPicklistValuesForRole([$userSelectedRoleId], 'CONJUNCTION');
- 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
Avoid excessively long variable names like $selectedFieldAllPickListValues. Keep variable name length under 20. Open
$selectedFieldAllPickListValues = [];
- 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
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Settings_Picklist_IndexAjax_View extends Settings_Vtiger_IndexAjax_View
- Exclude checks
The class Settings_Picklist_IndexAjax_View is not named in CamelCase. Open
class Settings_Picklist_IndexAjax_View extends Settings_Vtiger_IndexAjax_View
{
use \App\Controller\ExposeMethod;
/**
- 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
$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
$sourceModule = $request->getByType('source_module', \App\Purifier::ALNUM);
- 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
* Get picklist details for module.
- 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
public function getPickListDetailsForModule(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel = Settings_Picklist_Module_Model::getInstance($qualifiedName)->setSourceModule($sourceModule);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get picklist values for field.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function __construct()
- 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
$sourceModule = $request->getByType('source_module', 2);
- 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
$this->exposeMethod('getPickListValueForField');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
use \App\Controller\ExposeMethod;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$selectedFieldAllPickListValues = App\Fields\Picklist::getValuesName($fieldModel->getName());
- 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
$fieldModel = null;
- 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
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getPickListValueByRole(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel = Settings_Picklist_Field_Model::getInstance($pickFieldName, Vtiger_Module_Model::getInstance($sourceModule));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('ROLES_LIST', Settings_Roles_Record_Model::getAll());
- 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
$this->exposeMethod('getPickListDetailsForModule');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('SELECTED_PICKLIST_FIELDMODEL', $fieldModel);
- Exclude checks
Line exceeds 120 characters; contains 134 characters Open
$fieldModel = Settings_Picklist_Field_Model::getInstance($pickFieldName, Vtiger_Module_Model::getInstance($sourceModule));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$allPickListValues = App\Fields\Picklist::getValuesName($fieldModel->getName());
- 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
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('QUALIFIED_MODULE', $qualifiedName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$pickFieldName = $request->getByType('picklistName', \App\Purifier::ALNUM);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel = Settings_Picklist_Field_Model::getInstance($pickFieldName, Vtiger_Module_Model::getInstance($sourceModule));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get picklist value by role.
- 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('SELECTED_MODULE_NAME', $sourceModule);
- 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
$this->exposeMethod('getPickListValueByRole');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$pickListFields = $moduleModel->getFieldsByType(['picklist', 'multipicklist'], true);
- 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
* @param App\Request $request
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$userSelectedRoleId = $request->getByType('rolesSelected', \App\Purifier::ALNUM);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$pickListValuesForRole = $fieldModel->getPicklistValuesForRole([$userSelectedRoleId], 'CONJUNCTION');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getPickListValueForField(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
$viewer->assign('SELECTED_PICKLISTFIELD_ALL_VALUES', $selectedFieldAllPickListValues);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('ROLE_PICKLIST_VALUES', $pickListValuesForRole);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('SELECTED_PICKLIST_FIELDMODEL', $fieldModel);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('QUALIFIED_MODULE', $qualifiedName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('SELECTED_MODULE_NAME', $sourceModule);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('ALL_PICKLIST_VALUES', $allPickListValues);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Constructor.
- 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('SELECTED_MODULE_NAME', $sourceModule);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$sourceModule = $request->getByType('source_module', \App\Purifier::ALNUM);
- Exclude checks
Line exceeds 120 characters; contains 130 characters Open
$fieldModel = Settings_Picklist_Field_Model::getInstance($pickFieldName, Vtiger_Module_Model::getInstance($sourceModule));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('QUALIFIED_MODULE', $qualifiedName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('PICKLIST_FIELDS', $pickListFields);
- Exclude checks
Line exceeds 120 characters; contains 128 characters Open
$viewer->assign('PICKLIST_INTERDEPENDENT', $moduleModel->listModuleInterdependentPickList(array_keys($pickListFields)));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$qualifiedName = $request->getModule(false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($pickFieldName)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$qualifiedName = $request->getModule(false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$pickFieldName = $request->getByType('picklistName', \App\Purifier::ALNUM);
- 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('PickListValueDetail.tpl', $qualifiedName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
parent::__construct();
- 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
$qualifiedName = $request->getModule(false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('PICKLIST_INTERDEPENDENT', $moduleModel->listModuleInterdependentPickList(array_keys($pickListFields)));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->view('ModulePickListDetail.tpl', $qualifiedName);
- 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
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$selectedFieldAllPickListValues = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->view('PickListValueByRole.tpl', $qualifiedName);
- Exclude checks
Class name "Settings_Picklist_IndexAjax_View" is not in camel caps format Open
class Settings_Picklist_IndexAjax_View extends Settings_Vtiger_IndexAjax_View
- Exclude checks