YetiForceCompany/YetiForceCRM

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

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

Avoid using static access to class '\Vtiger_Record_Model' in method 'doTask'.
Open

            $cloneRecordModel = \Vtiger_Record_Model::getCleanInstance($recordModel->getModuleName());

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

        $autoAssignInstance = \App\AutoAssign::getInstanceById((int) $this->template);

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 assigning values to variables in if clauses and the like (line '34', column '157').
Open

    public function doTask($recordModel)
    {
        $autoAssignInstance = \App\AutoAssign::getInstanceById((int) $this->template);
        if ($autoAssignInstance && $autoAssignInstance->isActive(\App\AutoAssign::MODE_WORKFLOW) && $autoAssignInstance->checkConditionForRecord($recordModel) && $assignedUserId = $autoAssignInstance->getOwner()) {
            $fieldModel = $recordModel->getField('assigned_user_id');

IfStatementAssignment

Since: 2.7.0

Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

Example

class Foo
{
    public function bar($flag)
    {
        if ($foo = 'bar') { // possible typo
            // ...
        }
        if ($baz = 0) { // always false
            // ...
        }
    }
}

Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

Reference to undeclared property \VTAutoAssign->template
Open

        $autoAssignInstance = \App\AutoAssign::getInstanceById((int) $this->template);

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

class VTAutoAssign 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 11 and the first side effect is on line 9.
Open

<?php

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

     *

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

            $fieldModel = $recordModel->getField('assigned_user_id');

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

            $cloneRecordModel->ext = $recordModel->ext;

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

     */

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

    }

Line exceeds 120 characters; contains 214 characters
Open

        if ($autoAssignInstance && $autoAssignInstance->isActive(\App\AutoAssign::MODE_WORKFLOW) && $autoAssignInstance->checkConditionForRecord($recordModel) && $assignedUserId = $autoAssignInstance->getOwner()) {

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

            $cloneRecordModel->isNew = false;

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

            $cloneRecordModel->save();

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

    {

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

            $cloneRecordModel = \Vtiger_Record_Model::getCleanInstance($recordModel->getModuleName());

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

    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

            $cloneRecordModel->setData($recordModel->getData());

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

        if ($autoAssignInstance && $autoAssignInstance->isActive(\App\AutoAssign::MODE_WORKFLOW) && $autoAssignInstance->checkConditionForRecord($recordModel) && $assignedUserId = $autoAssignInstance->getOwner()) {

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

     * @param Vtiger_Record_Model $recordModel

Line exceeds 120 characters; contains 130 characters
Open

            $cloneRecordModel->setDataForSave([$fieldModel->getTableName() => [$fieldModel->getColumnName() => $assignedUserId]]);

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

            $cloneRecordModel->set($fieldModel->getName(), $assignedUserId);

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

        $autoAssignInstance = \App\AutoAssign::getInstanceById((int) $this->template);

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

            $cloneRecordModel->setHandlerExceptions(['disableHandlerClasses' => ['Vtiger_Workflow_Handler']]);

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

            $cloneRecordModel->setDataForSave([$fieldModel->getTableName() => [$fieldModel->getColumnName() => $assignedUserId]]);

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

        return ['template'];

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

        }

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

            $autoAssignInstance->postProcess($assignedUserId);

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

                $recordModel->set($fieldName, $cloneRecordModel->get($fieldName));

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 (array_keys($cloneRecordModel->getPreviousValue()) as $fieldName) {

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

            }

There are no issues that match your filters.

Category
Status