YetiForceCompany/YetiForceCRM

View on GitHub
modules/Notification/models/ListView.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%

Avoid using static access to class 'Users_Privileges_Model' in method 'getHederLinks'.
Open

        $userPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();

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 'getHederLinks'.
Open

        $links = Vtiger_Link_Model::getAllByType($this->getModule()->getId(), ['LIST_VIEW_HEADER'], $linkParams);

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 'getHederLinks'.
Open

            $links['LIST_VIEW_HEADER'][] = Vtiger_Link_Model::getInstanceFromValues($headerLink);

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 "LIST_VIEW_HEADER" 4 times.
Open

        $links = Vtiger_Link_Model::getAllByType($this->getModule()->getId(), ['LIST_VIEW_HEADER'], $linkParams);

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 "Notification" 4 times.
Open

        if ($userPrivilegesModel->hasModulePermission('Notification') && $userPrivilegesModel->hasModuleActionPermission('Notification', 'CreateView')) {

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.

Argument 1 (mixed) is 'Notification' but \Users_Privileges_Model::hasModulePermission() takes int defined at /code/modules/Users/models/Privileges.php:101
Open

        if ($userPrivilegesModel->hasModulePermission('Notification') && $userPrivilegesModel->hasModuleActionPermission('Notification', 'CreateView')) {

Saw unextractable annotation for comment '* @return <array> List of Vtiger_Link_Model instances'</array>
Open

     * @return <Array> List of Vtiger_Link_Model instances

Saw unextractable annotation for comment '* @param <array> $linkParams'</array>
Open

     * @param <Array> $linkParams

Argument 1 (mixed) is 'Notification' but \Users_Privileges_Model::hasModulePermission() takes int defined at /code/modules/Users/models/Privileges.php:101
Open

        if ($userPrivilegesModel->hasModulePermission('Notification') && $userPrivilegesModel->hasModuleActionPermission('Notification', 'CreateView')) {

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class Notification_ListView_Model extends Vtiger_ListView_Model

The class Notification_ListView_Model is not named in CamelCase.
Open

class Notification_ListView_Model extends Vtiger_ListView_Model
{
    /**
     * Function to get the Quick Links for the List view of the module.
     *

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

    /**

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

                'linktype' => 'LIST_VIEW_HEADER',

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

                'linkicon' => 'fas fa-paper-plane',

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

    public function getHederLinks($linkParams)

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

            $headerLinks[] = [

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

        if ($userPrivilegesModel->hasModulePermission('Notification') && $userPrivilegesModel->hasModuleActionPermission('Notification', 'CreateView')) {

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

                'linkhint' => 'LBL_SEND_NOTIFICATION',

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

     */

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

        $links = Vtiger_Link_Model::getAllByType($this->getModule()->getId(), ['LIST_VIEW_HEADER'], $linkParams);

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

                'linkhint' => 'LBL_NOTIFICATION_SETTINGS',

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

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

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

        }

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

                'linkurl' => 'index.php?module=Notification&view=NotificationConfig',

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

        $headerLinks = [];

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

                'linktype' => 'LIST_VIEW_HEADER',

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

    {

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

        if ($userPrivilegesModel->hasModulePermission('Notification') && $userPrivilegesModel->hasModuleActionPermission('Notification', 'CreateView')) {

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

        return $links;

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

        foreach ($headerLinks as $headerLink) {

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

        $userPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();

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

                'modalView' => true,

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

     * @return <Array> List of Vtiger_Link_Model instances

Line exceeds 120 characters; contains 153 characters
Open

        if ($userPrivilegesModel->hasModulePermission('Notification') && $userPrivilegesModel->hasModuleActionPermission('Notification', 'CreateView')) {

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

        }

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

     *

Line exceeds 120 characters; contains 153 characters
Open

        if ($userPrivilegesModel->hasModulePermission('Notification') && $userPrivilegesModel->hasModuleActionPermission('Notification', 'CreateView')) {

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

                'linkurl' => 'javascript:Vtiger_Index_Js.sendNotification(this)',

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

            $links['LIST_VIEW_HEADER'][] = Vtiger_Link_Model::getInstanceFromValues($headerLink);

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

            ];

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

            $headerLinks[] = [

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

    }

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

     * Function to get the Quick Links for the List view of the module.

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

     * @param <Array> $linkParams

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

        }

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

class Notification_ListView_Model extends Vtiger_ListView_Model

There are no issues that match your filters.

Category
Status