Method getLinks
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getLinks(): array
{
$relatedLinks = parent::getLinks();
if ($this->getParentRecordModel()->isReadOnly()) {
return $relatedLinks;
Avoid using static access to class 'App\Mail' in method 'getLinks'. Open
if (\in_array($relatedModuleName, ['Accounts', 'Leads', 'Vendors', 'Contacts', 'Partners', 'Competition']) && $relatedModuleModel->isPermitted('MassComposeEmail') && App\Config::main('isActiveSendingMails') && App\Mail::getDefaultSmtp()) {
- 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_Link_Model' in method 'getLinks'. Open
$emailLink = Vtiger_Link_Model::getInstanceFromValues([
'linktype' => 'LISTVIEWBASIC',
'linklabel' => \App\Language::translate('LBL_SEND_EMAIL', $relatedModuleName),
'linkurl' => 'javascript:Campaigns_RelatedList_Js.triggerSendEmail();',
'linkicon' => 'fas fa-envelope',
- 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_Link_Model' in method 'getLinks'. Open
$relatedLinks['RELATEDLIST_MASSACTIONS'][] = Vtiger_Link_Model::getInstanceFromValues([
'linktype' => 'RELATEDLIST_MASSACTIONS',
'linklabel' => 'LBL_REMOVE_RELATION',
'linkicon' => 'fas fa-unlink',
'linkclass' => 'btn-sm btn-secondary',
- 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\Language' in method 'getLinks'. Open
'linklabel' => \App\Language::translate('LBL_SEND_EMAIL', $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\Config' in method 'getLinks'. Open
if (\in_array($relatedModuleName, ['Accounts', 'Leads', 'Vendors', 'Contacts', 'Partners', 'Competition']) && $relatedModuleModel->isPermitted('MassComposeEmail') && App\Config::main('isActiveSendingMails') && App\Mail::getDefaultSmtp()) {
- 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
Suspicious type false
of a variable or expression used to build a string. (Expected type to be able to cast to a string) Open
'linkurl' => "javascript:Vtiger_RelatedList_Js.triggerMassAction('index.php?module=Campaigns&action=RelationAjax&mode=massDeleteRelation&src_record={$id}&relatedModule={$relatedModuleName}')"
- Exclude checks
Argument 2 (moduleName)
is false
but \App\Language::translate()
takes string
defined at /code/app/Language.php:161
Open
'linklabel' => \App\Language::translate('LBL_SEND_EMAIL', $relatedModuleName),
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Campaigns_RelationListView_Model extends Vtiger_RelationListView_Model
- Exclude checks
Avoid variables with short names like $id. Configured minimum length is 3. Open
$id = $this->getParentRecordModel()->getId();
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
The class Campaigns_RelationListView_Model is not named in CamelCase. Open
class Campaigns_RelationListView_Model extends Vtiger_RelationListView_Model
{
/** {@inheritdoc} */
public function getLinks(): array
{
- 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
$emailLink->set('_sendEmail', true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkurl' => "javascript:Vtiger_RelatedList_Js.triggerMassAction('index.php?module=Campaigns&action=RelationAjax&mode=massDeleteRelation&src_record={$id}&relatedModule={$relatedModuleName}')"
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\in_array($relatedModuleName, ['Accounts', 'Leads', 'Vendors', 'Contacts', 'Partners', 'Competition']) && $relatedModuleModel->isPermitted('MassComposeEmail') && App\Config::main('isActiveSendingMails') && App\Mail::getDefaultSmtp()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relatedLinks['LISTVIEWBASIC'][] = $emailLink;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->getRelationModel()->privilegeToDelete()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linktype' => 'RELATEDLIST_MASSACTIONS',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $relatedLinks;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getLinks(): array
- 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
$relatedModuleModel = $this->getRelationModel()->getRelationModuleModel();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relatedModuleName = $relatedModuleModel->getName();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linktype' => 'LISTVIEWBASIC',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkicon' => 'fas fa-envelope',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linklabel' => 'LBL_REMOVE_RELATION',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkurl' => 'javascript:Campaigns_RelatedList_Js.triggerSendEmail();',
- 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
$relatedLinks = parent::getLinks();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->getParentRecordModel()->isReadOnly()) {
- 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
'linklabel' => \App\Language::translate('LBL_SEND_EMAIL', $relatedModuleName),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $relatedLinks;
- Exclude checks
Line exceeds 120 characters; contains 247 characters Open
if (\in_array($relatedModuleName, ['Accounts', 'Leads', 'Vendors', 'Contacts', 'Partners', 'Competition']) && $relatedModuleModel->isPermitted('MassComposeEmail') && App\Config::main('isActiveSendingMails') && App\Mail::getDefaultSmtp()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkicon' => 'fas fa-unlink',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$id = $this->getParentRecordModel()->getId();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$emailLink = Vtiger_Link_Model::getInstanceFromValues([
- 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
$relatedLinks['RELATEDLIST_MASSACTIONS'][] = Vtiger_Link_Model::getInstanceFromValues([
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkclass' => 'btn-sm btn-secondary',
- Exclude checks
Line exceeds 120 characters; contains 207 characters Open
'linkurl' => "javascript:Vtiger_RelatedList_Js.triggerMassAction('index.php?module=Campaigns&action=RelationAjax&mode=massDeleteRelation&src_record={$id}&relatedModule={$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
]);
- Exclude checks
Class name "Campaigns_RelationListView_Model" is not in camel caps format Open
class Campaigns_RelationListView_Model extends Vtiger_RelationListView_Model
- Exclude checks