Method showSlaPolicyView
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function showSlaPolicyView(App\Request $request)
{
$moduleName = $request->getModule();
$relatedModuleName = $request->getByType('target', \App\Purifier::ALNUM);
$rows = \App\Utils\ServiceContracts::getSlaPolicyForServiceContracts($request->getInteger('record'), \App\Module::getModuleId($relatedModuleName));
Missing class import via use statement (line '32', column '15'). Open
throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 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 'Users_Privileges_Model' in method 'checkPermission'. Open
$userPrivilegesModel = 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\Utils\ServiceContracts' in method 'showSlaPolicyView'. Open
$rows = \App\Utils\ServiceContracts::getSlaPolicyForServiceContracts($request->getInteger('record'), \App\Module::getModuleId($relatedModuleName));
- 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\Module' in method 'showSlaPolicyView'. Open
$rows = \App\Utils\ServiceContracts::getSlaPolicyForServiceContracts($request->getInteger('record'), \App\Module::getModuleId($relatedModuleName));
- 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 'showSlaPolicyView'. Open
$recordStructureModulesField[$relatedModuleName][$referenceField->getFieldName()] = Vtiger_RecordStructure_Model::getInstanceForModule(Vtiger_Module_Model::getInstance($relatedModuleName))->getStructure();
- 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 'showSlaPolicyView'. Open
$moduleModel = Vtiger_Module_Model::getInstance($relatedModuleName);
- 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\Utils\ServiceContracts' in method 'showSlaPolicyView'. Open
$viewer->assign('ALL_BUSINESS_HOURS', \App\Utils\ServiceContracts::getAllBusinessHours());
- 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
Reference to undeclared class \Vtiger_Detail_View
Open
parent::__construct();
- Exclude checks
Reference to undeclared class \Vtiger_Detail_View
Open
parent::checkPermission($request);
- Exclude checks
Reference to undeclared property \ServiceContracts_Detail_View->record
Open
$viewer->assign('RECORD', $this->record->getRecord());
- Exclude checks
Call to undeclared method \ServiceContracts_Detail_View::getViewer
Open
$viewer = $this->getViewer($request);
- Exclude checks
Reference to undeclared property \ServiceContracts_Detail_View->record
Open
if (!$userPrivilegesModel->hasModuleActionPermission($this->record->getModuleName(), 'ServiceContractsSla') || !$userPrivilegesModel->hasModulePermission($request->getByType('target', \App\Purifier::ALNUM))) {
- Exclude checks
Call to undeclared method \ServiceContracts_Detail_View::checkAndConvertJsScripts
Open
$this->checkAndConvertJsScripts([
- Exclude checks
Call to deprecated function \Vtiger_Field_Model::getFieldName()
defined at /code/modules/Vtiger/models/Field.php:203
Open
$recordStructureModulesField[$relatedModuleName][$referenceField->getFieldName()] = Vtiger_RecordStructure_Model::getInstanceForModule(Vtiger_Module_Model::getInstance($relatedModuleName))->getStructure();
- Exclude checks
Class extends undeclared class \Vtiger_Detail_View
Open
class ServiceContracts_Detail_View extends Vtiger_Detail_View
- Exclude checks
Reference to undeclared class \Vtiger_Detail_View
Open
parent::getFooterScripts($request),
- Exclude checks
Call to undeclared method \ServiceContracts_Detail_View::exposeMethod
Open
$this->exposeMethod('showSlaPolicyView');
- Exclude checks
Avoid excessively long variable names like $recordStructureModulesField. Keep variable name length under 20. Open
$recordStructureModulesField = [];
- 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 ServiceContracts_Detail_View extends Vtiger_Detail_View
- Exclude checks
The class ServiceContracts_Detail_View is not named in CamelCase. Open
class ServiceContracts_Detail_View extends Vtiger_Detail_View
{
/** {@inheritdoc} */
public function __construct()
{
- 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
$viewer->assign('SLA_POLICY_ROWS', $rows);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($moduleModel->getFieldsByReference() as $referenceField) {
- 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 function __construct()
- 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
}
- 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
public function showSlaPolicyView(App\Request $request)
- 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
$viewer->assign('RECORD', $this->record->getRecord());
- 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
* @throws \App\Exceptions\IllegalValue
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Line exceeds 120 characters; contains 155 characters Open
$rows = \App\Utils\ServiceContracts::getSlaPolicyForServiceContracts($request->getInteger('record'), \App\Module::getModuleId($relatedModuleName));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$policyType = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('VIEW', $request->getByType('view'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return array_merge(
- 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 string
- 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
return $viewer->view('SlaPolicy.tpl', $moduleName, true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('RECORD_STRUCTURE_RELATED_MODULES', $recordStructureModulesField);
- 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
parent::checkPermission($request);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$rows = \App\Utils\ServiceContracts::getSlaPolicyForServiceContracts($request->getInteger('record'), \App\Module::getModuleId($relatedModuleName));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
parent::getFooterScripts($request),
- 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
}
- Exclude checks
Line exceeds 120 characters; contains 221 characters Open
if (!$userPrivilegesModel->hasModuleActionPermission($this->record->getModuleName(), 'ServiceContractsSla') || !$userPrivilegesModel->hasModulePermission($request->getByType('target', \App\Purifier::ALNUM))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordStructureModulesField[$relatedModuleName][$referenceField->getFieldName()] = Vtiger_RecordStructure_Model::getInstanceForModule(Vtiger_Module_Model::getInstance($relatedModuleName))->getStructure();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);
- 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('SOURCE_MODULE', $relatedModuleName);
- 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->exposeMethod('showSlaPolicyView');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('showSlaPolicyView' === $request->getMode()) {
- 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
* Show SLA Policy.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($rows[0])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('POLICY_TYPE', $policyType);
- 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
if (!$userPrivilegesModel->hasModuleActionPermission($this->record->getModuleName(), 'ServiceContractsSla') || !$userPrivilegesModel->hasModulePermission($request->getByType('target', \App\Purifier::ALNUM))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordStructureModulesField = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel = Vtiger_Module_Model::getInstance($relatedModuleName);
- 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
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$policyType = (int) $rows[0]['policy_type'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($referenceField->getReferenceList() as $relatedModuleName) {
- 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
$relatedModuleName = $request->getByType('target', \App\Purifier::ALNUM);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getFooterScripts(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->checkAndConvertJsScripts([
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$userPrivilegesModel = 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
$viewer->assign('ALL_BUSINESS_HOURS', \App\Utils\ServiceContracts::getAllBusinessHours());
- Exclude checks
Line exceeds 120 characters; contains 221 characters Open
$recordStructureModulesField[$relatedModuleName][$referenceField->getFieldName()] = Vtiger_RecordStructure_Model::getInstanceForModule(Vtiger_Module_Model::getInstance($relatedModuleName))->getStructure();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('RECORD_STRUCTURE', Vtiger_RecordStructure_Model::getInstanceForModule($moduleModel)->getStructure());
- 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('TARGET_MODULE', $relatedModuleName);
- Exclude checks
Line exceeds 120 characters; contains 126 characters Open
$viewer->assign('RECORD_STRUCTURE', Vtiger_RecordStructure_Model::getInstanceForModule($moduleModel)->getStructure());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'modules.ServiceContracts.resources.InRelation',
- Exclude checks
Class name "ServiceContracts_Detail_View" is not in camel caps format Open
class ServiceContracts_Detail_View extends Vtiger_Detail_View
- Exclude checks