YetiForceCompany/YetiForceCRM

View on GitHub
modules/Campaigns/models/RelationListView.php

Summary

Maintainability
A
1 hr
Test Coverage
F
0%

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;
Severity: Minor
Found in modules/Campaigns/models/RelationListView.php - About 1 hr to fix

    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()) {

    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',

    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',

    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),

    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()) {

    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}')"

    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),

    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

    Avoid variables with short names like $id. Configured minimum length is 3.
    Open

            $id = $this->getParentRecordModel()->getId();

    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
        {

    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);

    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}')"

    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()) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $relatedLinks['LISTVIEWBASIC'][] = $emailLink;

    Spaces must be used to indent lines; tabs are not allowed
    Open

            if ($this->getRelationModel()->privilegeToDelete()) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    'linktype' => 'RELATEDLIST_MASSACTIONS',

    Spaces must be used to indent lines; tabs are not allowed
    Open

            return $relatedLinks;

    Spaces must be used to indent lines; tabs are not allowed
    Open

        public function getLinks(): array

    Spaces must be used to indent lines; tabs are not allowed
    Open

        {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $relatedModuleModel = $this->getRelationModel()->getRelationModuleModel();

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $relatedModuleName = $relatedModuleModel->getName();

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    'linktype' => 'LISTVIEWBASIC',

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    'linkicon' => 'fas fa-envelope',

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    'linklabel' => 'LBL_REMOVE_RELATION',

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    'linkurl' => 'javascript:Campaigns_RelatedList_Js.triggerSendEmail();',

    Spaces must be used to indent lines; tabs are not allowed
    Open

                ]);

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $relatedLinks = parent::getLinks();

    Spaces must be used to indent lines; tabs are not allowed
    Open

            if ($this->getParentRecordModel()->isReadOnly()) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    'linklabel' => \App\Language::translate('LBL_SEND_EMAIL', $relatedModuleName),

    Spaces must be used to indent lines; tabs are not allowed
    Open

                return $relatedLinks;

    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()) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    'linkicon' => 'fas fa-unlink',

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $id = $this->getParentRecordModel()->getId();

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $emailLink = Vtiger_Link_Model::getInstanceFromValues([

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

        /** {@inheritdoc} */

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $relatedLinks['RELATEDLIST_MASSACTIONS'][] = Vtiger_Link_Model::getInstanceFromValues([

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    'linkclass' => 'btn-sm btn-secondary',

    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}')"

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

                ]);

    Class name "Campaigns_RelationListView_Model" is not in camel caps format
    Open

    class Campaigns_RelationListView_Model extends Vtiger_RelationListView_Model

    There are no issues that match your filters.

    Category
    Status