YetiForceCompany/YetiForceCRM

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

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

Avoid using static access to class 'Users_Record_Model' in method 'getListViewLinks'.
Open

        $currentUserModel = Users_Record_Model::getCurrentUserModel();

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

            $links['LISTVIEWSETTING'][] = Vtiger_Link_Model::getInstanceFromValues($settingsLink);

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_Theme' in method 'getListViewLinks'.
Open

                'linkicon' => Vtiger_Theme::getImagePath('EditWorkflows.png'),

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 "LISTVIEWSETTING" 3 times.
Open

        unset($links['LISTVIEW'], $links['LISTVIEWSETTING']);

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.

Avoid unused parameters such as '$linkParams'.
Open

    public function getListViewMassActions($linkParams)

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

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

     * @param <Array> $linkParams

Saw unextractable annotation for comment '* @return <array> - Associate array of Link Type to List of Vtiger_Link_Model instances'</array>
Open

     * @return <Array> - Associate array of Link Type to List of Vtiger_Link_Model instances

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

     * @param <Array> $linkParams

Saw unextractable annotation for comment '* @return <array> - empty array'</array>
Open

     * @return <Array> - empty array

Call to undeclared method \ModComments_ListView_Model::getName
Open

                'linkurl' => 'index.php?parent=Settings&module=Workflow&sourceModule=' . $this->getName(),
Severity: Critical
Found in modules/ModComments/models/ListView.php by phan

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

class ModComments_ListView_Model extends Vtiger_ListView_Model

The class ModComments_ListView_Model is not named in CamelCase.
Open

class ModComments_ListView_Model extends Vtiger_ListView_Model
{
    /**
     * Function to get the list of listview links for 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

        return $links;

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

                'linkurl' => 'index.php?parent=Settings&module=Workflow&sourceModule=' . $this->getName(),

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

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

                'linkicon' => Vtiger_Theme::getImagePath('EditWorkflows.png'),

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

    public function getListViewMassActions($linkParams)

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

        return [];

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

     * Function to get the list of Mass actions for the module.

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

     *

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

     * @return <Array> - empty array

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

        $currentUserModel = Users_Record_Model::getCurrentUserModel();

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

     *

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

        if ($currentUserModel->isAdminUser()) {

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

            $links['LISTVIEWSETTING'][] = Vtiger_Link_Model::getInstanceFromValues($settingsLink);

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

            $settingsLink = [

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

                'linktype' => 'LISTVIEWSETTING',

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

     * Function to get the list of listview links for the module.

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

     * @return <Array> - Associate array of Link Type to List of Vtiger_Link_Model instances

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

        $links = parent::getListViewLinks($linkParams);

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

        unset($links['LISTVIEW'], $links['LISTVIEWSETTING']);

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

            ];

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

     *

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

    /**

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

    public function getListViewLinks($linkParams)

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

class ModComments_ListView_Model extends Vtiger_ListView_Model

There are no issues that match your filters.

Category
Status