YetiForceCompany/YetiForceCRM

View on GitHub
modules/OSSMailView/views/Sview.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

The method preProcess has a boolean flag argument $display, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function preProcess(App\Request $request, $display = true)
Severity: Minor
Found in modules/OSSMailView/views/Sview.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

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

Missing class import via use statement (line '18', column '14').
Open

            throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);
Severity: Minor
Found in modules/OSSMailView/views/Sview.php by phpmd

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 '\App\Privilege' in method 'checkPermission'.
Open

        $recordPermission = \App\Privilege::isPermitted($moduleName, 'DetailView', $recordId);
Severity: Minor
Found in modules/OSSMailView/views/Sview.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\Utils' in method 'process'.
Open

        if (\App\Utils::isHtml($recordModel->get('content'))) {
Severity: Minor
Found in modules/OSSMailView/views/Sview.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\Layout' in method 'process'.
Open

            $viewer->assign('CONTENT', nl2br(\App\Layout::truncateHtml(\App\Purifier::purify($recordModel->get('content')), 'full')));
Severity: Minor
Found in modules/OSSMailView/views/Sview.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\Purifier' in method 'process'.
Open

            $viewer->assign('CONTENT', nl2br(\App\Layout::truncateHtml(\App\Purifier::purify($recordModel->get('content')), 'full')));
Severity: Minor
Found in modules/OSSMailView/views/Sview.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

The method process uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $viewer->assign('CONTENT', nl2br(\App\Layout::truncateHtml(\App\Purifier::purify($recordModel->get('content')), 'full')));
        }
Severity: Minor
Found in modules/OSSMailView/views/Sview.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

Avoid using static access to class 'OSSMailView_Record_Model' in method 'process'.
Open

        $recordModel = OSSMailView_Record_Model::getInstanceById($record, $moduleName);
Severity: Minor
Found in modules/OSSMailView/views/Sview.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 "content" 3 times.
Open

        if (\App\Utils::isHtml($recordModel->get('content'))) {
Severity: Critical
Found in modules/OSSMailView/views/Sview.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.

Avoid unused parameters such as '$display'.
Open

    public function preProcess(App\Request $request, $display = true)
Severity: Minor
Found in modules/OSSMailView/views/Sview.php by phpmd

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

Call to undeclared method \Vtiger_Viewer::assign
Open

            $viewer->assign('CONTENT', nl2br(\App\Layout::truncateHtml(\App\Purifier::purify($recordModel->get('content')), 'full')));
Severity: Critical
Found in modules/OSSMailView/views/Sview.php by phan

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('NOLOADLIBS', $request->getBoolean('noloadlibs'));
Severity: Critical
Found in modules/OSSMailView/views/Sview.php by phan

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('SUBJECT', $recordModel->getDisplayValue('subject'));
Severity: Critical
Found in modules/OSSMailView/views/Sview.php by phan

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('ATTACHMENTS', $recordModel->getAttachments());
Severity: Critical
Found in modules/OSSMailView/views/Sview.php by phan

Call to undeclared method \Vtiger_Viewer::assign
Open

            $viewer->assign('CONTENT', $recordModel->getDisplayValue('content', false, false, 'full'));
Severity: Critical
Found in modules/OSSMailView/views/Sview.php by phan

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('FROM', $recordModel->getDisplayValue('from_email'));
Severity: Critical
Found in modules/OSSMailView/views/Sview.php by phan

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('BCC', $recordModel->getDisplayValue('bcc_email'));
Severity: Critical
Found in modules/OSSMailView/views/Sview.php by phan

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('MODULENAME', $moduleName);
Severity: Critical
Found in modules/OSSMailView/views/Sview.php by phan

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('RECORD', $record);
Severity: Critical
Found in modules/OSSMailView/views/Sview.php by phan

Argument 4 (length) is 'full' but \OSSMailView_Record_Model::getDisplayValue() takes bool|false|int defined at /code/modules/Vtiger/models/Record.php:416
Open

            $viewer->assign('CONTENT', $recordModel->getDisplayValue('content', false, false, 'full'));
Severity: Minor
Found in modules/OSSMailView/views/Sview.php by phan

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('OWNER', $recordModel->get('assigned_user_id'));
Severity: Critical
Found in modules/OSSMailView/views/Sview.php by phan

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('CC', $recordModel->getDisplayValue('cc_email'));
Severity: Critical
Found in modules/OSSMailView/views/Sview.php by phan

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('SENT', $recordModel->get('createdtime'));
Severity: Critical
Found in modules/OSSMailView/views/Sview.php by phan

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('TO', explode(',', $recordModel->getDisplayValue('to_email')));
Severity: Critical
Found in modules/OSSMailView/views/Sview.php by phan

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

class OSSMailView_Sview_View extends Vtiger_Index_View

The class OSSMailView_Sview_View is not named in CamelCase.
Open

class OSSMailView_Sview_View extends Vtiger_Index_View
{
    public function checkPermission(App\Request $request)
    {
        $moduleName = $request->getModule();
Severity: Minor
Found in modules/OSSMailView/views/Sview.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 true;

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

    }

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

        } else {

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

        $viewer->assign('MODULENAME', $moduleName);

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

        $viewer->assign('ATTACHMENTS', $recordModel->getAttachments());

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

        }

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

        parent::preProcess($request, 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

    {

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

        $viewer->assign('CC', $recordModel->getDisplayValue('cc_email'));

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

        $viewer->assign('BCC', $recordModel->getDisplayValue('bcc_email'));

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

        $viewer->view('sview.tpl', 'OSSMailView');

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

        $viewer->assign('SUBJECT', $recordModel->getDisplayValue('subject'));

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

        $viewer->assign('RECORD', $record);

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

        }

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

        $recordModel = OSSMailView_Record_Model::getInstanceById($record, $moduleName);

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

        if (!$recordPermission) {

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

        $record = $request->getInteger('record');

Line exceeds 120 characters; contains 134 characters
Open

            $viewer->assign('CONTENT', nl2br(\App\Layout::truncateHtml(\App\Purifier::purify($recordModel->get('content')), 'full')));

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

    public function checkPermission(App\Request $request)

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 (\App\Utils::isHtml($recordModel->get('content'))) {

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

    public function preProcess(App\Request $request, $display = true)

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

    public function process(App\Request $request)

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

        $viewer->assign('FROM', $recordModel->getDisplayValue('from_email'));

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

            $viewer->assign('CONTENT', nl2br(\App\Layout::truncateHtml(\App\Purifier::purify($recordModel->get('content')), 'full')));

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

        $recordPermission = \App\Privilege::isPermitted($moduleName, 'DetailView', $recordId);

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

        $moduleName = $request->getModule();

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

        $viewer->assign('OWNER', $recordModel->get('assigned_user_id'));

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

            $viewer->assign('CONTENT', $recordModel->getDisplayValue('content', false, false, 'full'));

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

        $recordId = $request->getInteger('record');

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

        $viewer->assign('SENT', $recordModel->get('createdtime'));

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

        $moduleName = $request->getModule();

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

            throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);

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

    {

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

        $viewer->assign('TO', explode(',', $recordModel->getDisplayValue('to_email')));

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

        $viewer = $this->getViewer($request);

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

        $viewer->assign('NOLOADLIBS', $request->getBoolean('noloadlibs'));

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

class OSSMailView_Sview_View extends Vtiger_Index_View

There are no issues that match your filters.

Category
Status