YetiForceCompany/YetiForceCRM

View on GitHub
modules/Vtiger/handlers/AutoAssign.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%

Avoid using static access to class '\App\AutoAssign' in method 'entityBeforeSave'.
Open

        if ($recordModel->isNew() && ($autoAssignModel = \App\AutoAssign::getAutoAssignForRecord($recordModel, \App\AutoAssign::MODE_HANDLER)) && ($assignedUserId = $autoAssignModel->getOwner())) {

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 '26', column '33').
Open

    public function entityBeforeSave(App\EventHandler $eventHandler): void
    {
        $recordModel = $eventHandler->getRecordModel();
        if ($recordModel->isNew() && ($autoAssignModel = \App\AutoAssign::getAutoAssignForRecord($recordModel, \App\AutoAssign::MODE_HANDLER)) && ($assignedUserId = $autoAssignModel->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

Avoid assigning values to variables in if clauses and the like (line '26', column '142').
Open

    public function entityBeforeSave(App\EventHandler $eventHandler): void
    {
        $recordModel = $eventHandler->getRecordModel();
        if ($recordModel->isNew() && ($autoAssignModel = \App\AutoAssign::getAutoAssignForRecord($recordModel, \App\AutoAssign::MODE_HANDLER)) && ($assignedUserId = $autoAssignModel->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

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

class Vtiger_AutoAssign_Handler

The class Vtiger_AutoAssign_Handler is not named in CamelCase.
Open

class Vtiger_AutoAssign_Handler
{
    /**
     * EntityBeforeSave function.
     *

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 for alignment; tabs are not allowed
Open

    }

Spaces must be used for alignment; tabs are not allowed
Open

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

Spaces must be used for alignment; tabs are not allowed
Open

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

Spaces must be used for alignment; tabs are not allowed
Open

    /**

Spaces must be used for alignment; tabs are not allowed
Open

        if ($recordModel->isNew() && ($autoAssignModel = \App\AutoAssign::getAutoAssignForRecord($recordModel, \App\AutoAssign::MODE_HANDLER)) && ($assignedUserId = $autoAssignModel->getOwner())) {

Spaces must be used for alignment; tabs are not allowed
Open

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

Spaces must be used for alignment; tabs are not allowed
Open

     * @param App\EventHandler $eventHandler

Spaces must be used for alignment; tabs are not allowed
Open

    {

Spaces must be used for alignment; tabs are not allowed
Open

     */

Spaces must be used for alignment; tabs are not allowed
Open

        }

Spaces must be used for alignment; tabs are not allowed
Open

     *

Spaces must be used for alignment; tabs are not allowed
Open

     * EntityBeforeSave function.

Spaces must be used for alignment; tabs are not allowed
Open

 * @package        Handler

Spaces must be used for alignment; tabs are not allowed
Open

            $autoAssignModel->postProcess($assignedUserId);

Spaces must be used for alignment; tabs are not allowed
Open

    public function entityBeforeSave(App\EventHandler $eventHandler): void

Spaces must be used for alignment; tabs are not allowed
Open

        $recordModel = $eventHandler->getRecordModel();

Line exceeds 120 characters; contains 125 characters
Open

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

Line exceeds 120 characters; contains 197 characters
Open

        if ($recordModel->isNew() && ($autoAssignModel = \App\AutoAssign::getAutoAssignForRecord($recordModel, \App\AutoAssign::MODE_HANDLER)) && ($assignedUserId = $autoAssignModel->getOwner())) {

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

class Vtiger_AutoAssign_Handler

There are no issues that match your filters.

Category
Status