YetiForceCompany/YetiForceCRM

View on GitHub
modules/com_vtiger_workflow/tasks/VTSendNotificationTask.php

Summary

Maintainability
A
35 mins
Test Coverage
F
0%

Function doTask has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function doTask($recordModel)
    {
        if (is_numeric($this->template) && $this->template) {
            $entityId = $recordModel->getId();
            $resultInvitees = (new \App\Db\Query())->from('u_#__activity_invitation')->where(['activityid' => $entityId])->createCommand()->query();
Severity: Minor
Found in modules/com_vtiger_workflow/tasks/VTSendNotificationTask.php - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Missing class import via use statement (line '43', column '27').
Open

            $resultInvitees = (new \App\Db\Query())->from('u_#__activity_invitation')->where(['activityid' => $entityId])->createCommand()->query();

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\User' in method 'doTask'.
Open

                $userModel = App\User::getUserModel($recordinfo['inviteeid']);

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\Mailer' in method 'doTask'.
Open

                    \App\Mailer::sendFromTemplate([
                        'template' => $this->template,
                        'moduleName' => $recordModel->getModuleName(),
                        'recordId' => $entityId,
                        'to' => $userModel->getDetail('email1'),

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

Call to undeclared method \App\Db\Query::from
Open

            $resultInvitees = (new \App\Db\Query())->from('u_#__activity_invitation')->where(['activityid' => $entityId])->createCommand()->query();

Reference to undeclared property \VTSendNotificationTask->template
Open

                        'template' => $this->template,

Call to method getUserModel from undeclared class \App\User (Did you mean class \Tests\App\User)
Open

                $userModel = App\User::getUserModel($recordinfo['inviteeid']);

Reference to undeclared property \VTSendNotificationTask->copy_email
Open

                        'cc' => $this->copy_email,

Reference to undeclared property \VTSendNotificationTask->template
Open

        if (is_numeric($this->template) && $this->template) {

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

class VTSendNotificationTask extends VTTask

A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 15 and the first side effect is on line 10.
Open

<?php

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

    public function doTask($recordModel)

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

                    \App\Mailer::sendFromTemplate([

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

                        'cc' => $this->copy_email,

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

                if ('Active' === $userModel->getDetail('status')) {

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

                        'to_email_mod' => 'Users',

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

     * Execute task.

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

     */

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

            $entityId = $recordModel->getId();

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 $executeImmediately = 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

        if (is_numeric($this->template) && $this->template) {

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

                        'recordId' => $entityId,

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

        }

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 Vtiger_Record_Model $recordModel

Line exceeds 120 characters; contains 148 characters
Open

            $resultInvitees = (new \App\Db\Query())->from('u_#__activity_invitation')->where(['activityid' => $entityId])->createCommand()->query();

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

            while ($recordinfo = $resultInvitees->read()) {

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

     * Sending email takes more time, this should be handled via queue all the time.

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

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

    public function getFieldNames()

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 ['template'];

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

                $userModel = App\User::getUserModel($recordinfo['inviteeid']);

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

                        'template' => $this->template,

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

    }

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

                        'language' => $userModel->getDetail('language'),

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

     * @var bool

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

            $resultInvitees = (new \App\Db\Query())->from('u_#__activity_invitation')->where(['activityid' => $entityId])->createCommand()->query();

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

                        'moduleName' => $recordModel->getModuleName(),

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

                        'to' => $userModel->getDetail('email1'),

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

     * Get field names.

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

    {

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

     *

There are no issues that match your filters.

Category
Status