YetiForceCompany/YetiForceCRM

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

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

Avoid using undefined variables such as '$links' which will lead to PHP notices.
Open

        return $links;

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Avoid using undefined variables such as '$links' which will lead to PHP notices.
Open

            $links['LISTVIEWMASSACTION'][] = Vtiger_Link_Model::getInstanceFromValues($massActionLink);

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Missing class import via use statement (line '24', column '25').
Open

        $queryGenerator = new \App\QueryGenerator($sourceModuleModel->getName());

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

            $links['LISTVIEWBASIC'][] = Vtiger_Link_Model::getInstanceFromValues($basicLink);

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_Loader' in method 'getInstance'.
Open

        $modelClassName = Vtiger_Loader::getComponentClassName('Model', 'ListView', $moduleName);

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

        $sourceModuleModel = Vtiger_Module_Model::getInstance($sourceModule);

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 'CustomView_Record_Model' in method 'getInstance'.
Open

        $cvidObj = CustomView_Record_Model::getAllFilterByModule($sourceModuleModel->getName());

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

            $links['LISTVIEWMASSACTION'][] = Vtiger_Link_Model::getInstanceFromValues($massActionLink);

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

            'linktype' => 'LISTVIEWBASIC',

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

            'linklabel' => 'LBL_RECYCLE_DELETE_ALL',

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

                'linktype' => 'LISTVIEWMASSACTION',

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

            'linktype' => 'LISTVIEWBASIC',

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

            'linkicon' => 'fas fa-trash-alt',

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.

Call to method __construct from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
Open

        $queryGenerator = new \App\QueryGenerator($sourceModuleModel->getName());
Severity: Critical
Found in modules/RecycleBin/models/ListView.php by phan

Variable $links was undeclared, but array fields are being added to it.
Open

            $links['LISTVIEWMASSACTION'][] = Vtiger_Link_Model::getInstanceFromValues($massActionLink);

Call with 1 arg(s) to \CustomView_Record_Model::getId() which only takes 0 arg(s) defined at /code/modules/CustomView/models/Record.php:162
Open

        $viewId = $cvidObj->getId('cvid');

Call to method initForCustomViewById from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
Open

        $queryGenerator->initForCustomViewById($viewId, true);
Severity: Critical
Found in modules/RecycleBin/models/ListView.php by phan

Argument 1 (module) is false but \CustomView_Record_Model::getAllFilterByModule() takes string defined at /code/modules/CustomView/models/Record.php:138
Open

        $cvidObj = CustomView_Record_Model::getAllFilterByModule($sourceModuleModel->getName());
Severity: Minor
Found in modules/RecycleBin/models/ListView.php by phan

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

class RecycleBin_ListView_Model extends Vtiger_ListView_Model

The class RecycleBin_ListView_Model is not named in CamelCase.
Open

class RecycleBin_ListView_Model extends Vtiger_ListView_Model
{
    /** {@inheritdoc} */
    public static function getInstance($moduleName, $sourceModule = 0)
    {

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

            'linklabel' => 'LBL_RECYCLE_DELETE_ALL',

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

            'linkicon' => 'fas fa-trash-alt',

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

                'linkurl' => 'javascript:RecycleBin_List_Js.massDelete()',

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

        foreach ($massActionLinks as $massActionLink) {

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

        $instance = new $modelClassName();

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

        $queryGenerator->initForCustomViewById($viewId, true);

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

        $basicLinks[] = [

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

        return $links;

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

    {

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

        if ($moduleModel->isPermitted('MassDelete')) {

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

        $cvidObj = CustomView_Record_Model::getAllFilterByModule($sourceModuleModel->getName());

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

        if ($moduleModel->isPermitted('MassActive')) {

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

                'linkurl' => 'javascript:RecycleBin_List_Js.massActivation()',

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

                'linklabel' => 'LBL_MASS_DELETE',

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

        foreach ($basicLinks as $basicLink) {

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

        $modelClassName = Vtiger_Loader::getComponentClassName('Model', 'ListView', $moduleName);

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

                'linklabel' => 'LBL_MASS_ACTIVATE',

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

        return $instance->set('entityState', 'Trash')->set('module', $sourceModuleModel)->set('query_generator', $queryGenerator);

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

     */

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

        $moduleModel = $this->getModule();

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

    public static function getInstance($moduleName, $sourceModule = 0)

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

     * Function to get Basic links.

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

        $queryGenerator = new \App\QueryGenerator($sourceModuleModel->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

     * @return array of Basic links

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

            $links['LISTVIEWMASSACTION'][] = Vtiger_Link_Model::getInstanceFromValues($massActionLink);

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

        $viewId = $cvidObj->getId('cvid');

Line exceeds 120 characters; contains 130 characters
Open

        return $instance->set('entityState', 'Trash')->set('module', $sourceModuleModel)->set('query_generator', $queryGenerator);

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

            'showLabel' => 1,

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

            ];

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

    public function getBasicLinks()

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

        $massActionLinks = [];

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

    public function getListViewLinks($linkParams)

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

        $links = ['LISTVIEWBASIC' => []];

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

    {

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

        $basicLinks = [];

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

                'linkicon' => 'fas fa-undo-alt'

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

                'linkicon' => 'fas fa-eraser'

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

    }

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

        $basicLinks = $this->getBasicLinks();

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

            $links['LISTVIEWBASIC'][] = Vtiger_Link_Model::getInstanceFromValues($basicLink);

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

        $sourceModuleModel = Vtiger_Module_Model::getInstance($sourceModule);

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

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

            'linkclass' => 'btn-light js-recycle-empty',

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

                'linktype' => 'LISTVIEWMASSACTION',

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

                'linktype' => 'LISTVIEWMASSACTION',

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 $basicLinks;

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

     *

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

            'linkhref' => false

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

    }

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

            $massActionLinks[] = [

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

        }

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

            $massActionLinks[] = [

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

        }

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

class RecycleBin_ListView_Model extends Vtiger_ListView_Model

There are no issues that match your filters.

Category
Status