YetiForceCompany/YetiForceCRM

View on GitHub
modules/Vtiger/widgets/EmailList.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

Avoid using static access to class 'Vtiger_Module_Model' in method 'getWidget'.
Open

        $model = Vtiger_Module_Model::getInstance('OSSMailView');
Severity: Minor
Found in modules/Vtiger/widgets/EmailList.php by phpmd

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\Relation' in method 'isPermitted'.
Open

        return parent::isPermitted() && \App\Relation::getRelationId($this->moduleModel->getName(), 'OSSMailView');
Severity: Minor
Found in modules/Vtiger/widgets/EmailList.php by phpmd

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

    public $dbParams = ['relatedmodule' => 'OSSMailView'];
Severity: Critical
Found in modules/Vtiger/widgets/EmailList.php by sonar-php

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.

Suspicious type false of a variable or expression used to build a string. (Expected type to be able to cast to a string)
Open

        return 'module=OSSMailView&view=Widget&smodule=' . $this->Module . '&srecord=' . $this->Record . '&mode=showEmailsList&type=All&mailFilter=All&limit=' . $this->Data['limit'];
Severity: Minor
Found in modules/Vtiger/widgets/EmailList.php by phan

Reference to undeclared property \Vtiger_EmailList_Widget->Data
Open

        return 'module=OSSMailView&view=Widget&smodule=' . $this->Module . '&srecord=' . $this->Record . '&mode=showEmailsList&type=All&mailFilter=All&limit=' . $this->Data['limit'];
Severity: Minor
Found in modules/Vtiger/widgets/EmailList.php by phan

Call to method getName on non-class type false
Open

        return parent::isPermitted() && \App\Relation::getRelationId($this->moduleModel->getName(), 'OSSMailView');
Severity: Critical
Found in modules/Vtiger/widgets/EmailList.php by phan

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

class Vtiger_EmailList_Widget extends Vtiger_Basic_Widget

The class Vtiger_EmailList_Widget is not named in CamelCase.
Open

class Vtiger_EmailList_Widget extends Vtiger_Basic_Widget
{
    /**
     * Params.
     *
Severity: Minor
Found in modules/Vtiger/widgets/EmailList.php by phpmd

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

     * @return string

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

        return 'module=OSSMailView&view=Widget&smodule=' . $this->Module . '&srecord=' . $this->Record . '&mode=showEmailsList&type=All&mailFilter=All&limit=' . $this->Data['limit'];

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

    /** {@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

     * Params.

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

            $this->Config['tpl'] = 'EmailList.tpl';

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

        $widget = [];

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

        $model = Vtiger_Module_Model::getInstance('OSSMailView');

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

        return parent::isPermitted() && \App\Relation::getRelationId($this->moduleModel->getName(), 'OSSMailView');

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

        if ($model->isPermitted('DetailView')) {

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

        return 'EmailListConfig';

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

    public function getWidget()

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

        return $widget;

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

    public $dbParams = ['relatedmodule' => 'OSSMailView'];

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

    public function isPermitted(): bool

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

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

     * @var string[]

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

    }

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

    public function getConfigTplName()

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

    {

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

            $widget = $this->Config;

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

     * Return url.

Line exceeds 120 characters; contains 182 characters
Open

        return 'module=OSSMailView&view=Widget&smodule=' . $this->Module . '&srecord=' . $this->Record . '&mode=showEmailsList&type=All&mailFilter=All&limit=' . $this->Data['limit'];

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

            $this->Config['url'] = $this->getUrl();

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

class Vtiger_EmailList_Widget extends Vtiger_Basic_Widget

There are no issues that match your filters.

Category
Status