YetiForceCompany/YetiForceCRM

View on GitHub
modules/com_vtiger_workflow/VTTaskQueue.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%

Missing class import via use statement (line '53', column '17').
Open

        $query = (new \App\Db\Query())->select(['task_id', 'entity_id', 'task_contents'])->from('com_vtiger_workflowtask_queue')->andWhere(['<', 'do_after', $time]);

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

Missing class import via use statement (line '34', column '17').
Open

        $query = (new \App\Db\Query())->from('com_vtiger_workflowtask_queue')->where($data);

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

Define a constant instead of duplicating this literal "task_contents" 3 times.
Open

            'task_contents' => $taskContents,

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.

Define a constant instead of duplicating this literal "task_id" 3 times.
Open

            'task_id' => $taskId,

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.

Define a constant instead of duplicating this literal "com_vtiger_workflowtask_queue" 4 times.
Open

        $query = (new \App\Db\Query())->from('com_vtiger_workflowtask_queue')->where($data);

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.

Define a constant instead of duplicating this literal "entity_id" 3 times.
Open

            'entity_id' => $entityId,

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.

Define a constant instead of duplicating this literal "do_after" 3 times.
Open

            'do_after' => $when,

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.

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

        $query = (new \App\Db\Query())->from('com_vtiger_workflowtask_queue')->where($data);

Call to undeclared method \App\Db::createCommand
Open

            \App\Db::getInstance()->createCommand()->insert('com_vtiger_workflowtask_queue', $data)->execute();

Call to undeclared method \App\Db::createCommand
Open

        \App\Db::getInstance()->createCommand()->delete('com_vtiger_workflowtask_queue', ['<', 'do_after', $time])->execute();

Returning type array<int>|array{}</int> but getReadyTasks() is declared to return \A
Open

        return $arr;

Return type of getReadyTasks() is undeclared type \A
Open

    public function getReadyTasks()

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

        $query = (new \App\Db\Query())->select(['task_id', 'entity_id', 'task_contents'])->from('com_vtiger_workflowtask_queue')->andWhere(['<', 'do_after', $time]);

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

class VTTaskQueue

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

            'task_id' => $taskId,

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 $taskId The id of the task to queue

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

        }

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

     *        an optional value with a default value of 0

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

    }

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

        $dataReader = $query->createCommand()->query();

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

     *

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

        $query = (new \App\Db\Query())->from('com_vtiger_workflowtask_queue')->where($data);

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

        return $arr;

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

    public function queueTask($taskId, $entityId, $when = 0, $taskContents = '')

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 mixed $taskContents

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

            'do_after' => $when,

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

        while ($row = $dataReader->read()) {

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

     * Queue a task for execution.

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

            \App\Db::getInstance()->createCommand()->insert('com_vtiger_workflowtask_queue', $data)->execute();

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

    public function getReadyTasks()

Line exceeds 120 characters; contains 165 characters
Open

        $query = (new \App\Db\Query())->select(['task_id', 'entity_id', 'task_contents'])->from('com_vtiger_workflowtask_queue')->andWhere(['<', 'do_after', $time]);

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

        \App\Db::getInstance()->createCommand()->delete('com_vtiger_workflowtask_queue', ['<', 'do_after', $time])->execute();

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

            'task_contents' => $taskContents,

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

     *

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

        $time = time();

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

     * Get a list of taskId/entityId pairs ready for execution.

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

        $arr = [];

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

            $arr[] = [$row['task_id'], $row['entity_id'], $row['task_contents']];

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

            'entity_id' => $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

        }

Line exceeds 120 characters; contains 126 characters
Open

        \App\Db::getInstance()->createCommand()->delete('com_vtiger_workflowtask_queue', ['<', 'do_after', $time])->execute();

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

     * @param $when The time after which the task should be executed. This is

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

        $data = [

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

     * @return A list of pairs of the form array(taskId, entityId)

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

     * @param $entityId The id of the crm entity the task is assiciated with

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

     * The method fetches task id/entity id where the when timestamp

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

     * is less than the current time when the method was called.

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

        $query = (new \App\Db\Query())->select(['task_id', 'entity_id', 'task_contents'])->from('com_vtiger_workflowtask_queue')->andWhere(['<', 'do_after', $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

        if (!$query->exists()) {

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

    {

There are no issues that match your filters.

Category
Status