YetiForceCompany/YetiForceCRM

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

Summary

Maintainability
D
2 days
Test Coverage
F
0%

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

    public function doTask($recordModel)
    {
        if (!\App\Module::isModuleActive('Calendar')) {
            return;
        }
Severity: Minor
Found in modules/com_vtiger_workflow/tasks/VTCreateTodoTask.php - About 7 hrs 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

Method doTask has 152 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function doTask($recordModel)
    {
        if (!\App\Module::isModuleActive('Calendar')) {
            return;
        }
Severity: Major
Found in modules/com_vtiger_workflow/tasks/VTCreateTodoTask.php - About 6 hrs to fix

    The method doTask() has an NPath complexity of 2446080. The configured NPath complexity threshold is 200.
    Open

        public function doTask($recordModel)
        {
            if (!\App\Module::isModuleActive('Calendar')) {
                return;
            }

    NPathComplexity

    Since: 0.1

    The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

    Example

    class Foo {
        function bar() {
            // lots of complicated code
        }
    }

    Source https://phpmd.org/rules/codesize.html#npathcomplexity

    The method doTask() has 163 lines of code. Current threshold is set to 100. Avoid really long methods.
    Open

        public function doTask($recordModel)
        {
            if (!\App\Module::isModuleActive('Calendar')) {
                return;
            }

    The method doTask() has a Cyclomatic Complexity of 31. The configured cyclomatic complexity threshold is 10.
    Open

        public function doTask($recordModel)
        {
            if (!\App\Module::isModuleActive('Calendar')) {
                return;
            }

    CyclomaticComplexity

    Since: 0.1

    Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

    Example

    // Cyclomatic Complexity = 11
    class Foo {
    1   public function example() {
    2       if ($a == $b) {
    3           if ($a1 == $b1) {
                    fiddle();
    4           } elseif ($a2 == $b2) {
                    fiddle();
                } else {
                    fiddle();
                }
    5       } elseif ($c == $d) {
    6           while ($c == $d) {
                    fiddle();
                }
    7        } elseif ($e == $f) {
    8           for ($n = 0; $n < $h; $n++) {
                    fiddle();
                }
            } else {
                switch ($z) {
    9               case 1:
                        fiddle();
                        break;
    10              case 2:
                        fiddle();
                        break;
    11              case 3:
                        fiddle();
                        break;
                    default:
                        fiddle();
                        break;
                }
            }
        }
    }

    Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

    This function "doTask" has 162 lines, which is greater than the 150 lines authorized. Split it into smaller functions.
    Open

        public function doTask($recordModel)

    A function that grows too large tends to aggregate too many responsibilities.

    Such functions inevitably become harder to understand and therefore harder to maintain.

    Above a specific threshold, it is strongly advised to refactor into smaller functions which focus on well-defined tasks.

    Those smaller functions will not only be easier to understand, but also probably easier to test.

    Refactor this function to reduce its Cognitive Complexity from 53 to the 15 allowed.
    Open

        public function doTask($recordModel)

    Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

    See

    The class VTCreateTodoTask has a coupling between objects value of 16. Consider to reduce the number of dependencies under 13.
    Open

    class VTCreateTodoTask extends VTTask
    {
        public $executeImmediately = true;
    
        public function getFieldNames()

    CouplingBetweenObjects

    Since: 1.1.0

    A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

    Example

    class Foo {
        /**
         * @var \foo\bar\X
         */
        private $x = null;
    
        /**
         * @var \foo\bar\Y
         */
        private $y = null;
    
        /**
         * @var \foo\bar\Z
         */
        private $z = null;
    
        public function setFoo(\Foo $foo) {}
        public function setBar(\Bar $bar) {}
        public function setBaz(\Baz $baz) {}
    
        /**
         * @return \SplObjectStorage
         * @throws \OutOfRangeException
         * @throws \InvalidArgumentException
         * @throws \ErrorException
         */
        public function process(\Iterator $it) {}
    
        // ...
    }

    Source https://phpmd.org/rules/design.html#couplingbetweenobjects

    Missing class import via use statement (line '70', column '23').
    Open

                $userExists = (new App\Db\Query())->from('vtiger_users')

    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 '76', column '24').
    Open

                    $groupExist = (new App\Db\Query())->from('vtiger_groups')

    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 '43', column '18').
    Open

                $query = (new App\Db\Query())->from('vtiger_activity')

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

                $status = vtlib\Functions::getArrayFromValue($this->duplicateStatus);

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

                    $dbInsertDateTime = DateTimeField::convertToDBTimeZone($baseDateEnd . ' ' . $timeWithSec);

    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 doTask uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                $dueDateTime = date('Y-m-d H:i:s', strtotime($date_start . ' ' . $time) + $endIncrement);
                $dueDateTime = explode(' ', $dueDateTime);
                $due_date = $dueDateTime[0];
                $timeEnd = $dueDateTime[1];

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

            $newRecordModel = Vtiger_Record_Model::getCleanInstance('Calendar');

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

                $dbInsertDateTime = DateTimeField::convertToDBTimeZone($baseDateStart . ' ' . $timeWithSec);

    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 doTask uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

                } else {
                    $baseDateEnd = $recordModel->get($this->datefield_end);
                    if ('' == $baseDateEnd) {
                        $baseDateEnd = date('Y-m-d');
                    }

    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

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

                } else {
                    $groupExist = (new App\Db\Query())->from('vtiger_groups')
                        ->where(['groupid' => $this->assigned_user_id])
                        ->exists();
                    if ($groupExist) {

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

        public function doTask($recordModel)
        {
            if (!\App\Module::isModuleActive('Calendar')) {
                return;
            }

    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

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

            } else {
                $baseDateStart = $recordModel->get($this->datefield_start);
                if ('' == $baseDateStart) {
                    $baseDateStart = date('Y-m-d');
                }

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

                if ($parentRecord = \App\Record::getParentRecord($parentRecord)) {

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

            $relationModel = \Vtiger_Relation_Model::getInstance($recordModel->getModule(), $newRecordModel->getModule());

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

                    $field = \App\ModuleHierarchy::getMappingRelatedField($parentModuleName);

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

        public function doTask($recordModel)
        {
            if (!\App\Module::isModuleActive('Calendar')) {
                return;
            }

    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 using static access to class '\App\Log' in method 'doTask'.
    Open

            \App\Log::trace('Start ' . __CLASS__ . ':' . __FUNCTION__);

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

            $endIncrement = \App\Fields\Double::formatToDb($this->days_end) * 24 * 60 * 60 * ('before' == strtolower($this->direction_end) ? -1 : 1);

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

                    } elseif ($userIdFromGroup = current(\App\PrivilegeUtil::getUsersByGroup($userId))) {

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

                $field = \App\ModuleHierarchy::getMappingRelatedField($parentModuleName);

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

            \App\Log::trace('End ' . __CLASS__ . ':' . __FUNCTION__);

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

                        $timeEnd = \App\User::getUserModel(\App\User::getActiveAdminId())->getDetail('end_hour');

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

            if (!\App\Module::isModuleActive('Calendar')) {

    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 doTask uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

                    } else {
                        $timeEnd = \App\User::getUserModel(\App\User::getActiveAdminId())->getDetail('end_hour');
                    }

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

        public function doTask($recordModel)
        {
            if (!\App\Module::isModuleActive('Calendar')) {
                return;
            }

    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 using static access to class '\App\Fields\Time' in method 'doTask'.
    Open

                $timeWithSec = \App\Fields\Time::sanitizeDbFormat($this->time);

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

                    $timeWithSec = \App\Fields\Time::sanitizeDbFormat($timeEnd);

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

                    if (\App\User::isExists($userId)) {

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

            $field = \App\ModuleHierarchy::getMappingRelatedField($moduleName);

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

                $userId = \App\User::getCurrentUserId();

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

            if ($parentRecord = \App\Record::getParentRecord($recordModel->getId())) {

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

                $userId = Users::getActiveAdminUser();

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

            $textParser = \App\TextParser::getInstanceByModel($recordModel);

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

                $parentModuleName = \App\Record::getType($parentRecord);

    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 conv12to24hour uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                $hours = ((int) $arr[1]) % 12 + 12;
            }

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

                    $parentModuleName = \App\Record::getType($parentRecord);

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

                    \App\Log::warning(__CLASS__ . '::' . __METHOD__ . ': To Do was ignored because a duplicate was found.' . $this->todo);

    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 doTask uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                $time = $time[1];
            }

    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

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

                } else {
                    $timeEnd = $timeEnd[1];
                }

    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

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

                        $timeEnd = \App\User::getUserModel($userId)->getDetail('end_hour');

    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 "assigned_user_id" 4 times.
    Open

            return ['todo', 'description', 'time', 'days_start', 'days_end', 'status', 'priority', 'days', 'direction_start', 'datefield_start', 'direction_end', 'datefield_end', 'sendNotification', 'assigned_user_id', 'days', 'doNotDuplicate', 'duplicateStatus', 'updateDates'];

    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 "Y-m-d H:i:s" 3 times.
    Open

                $baseDateStart = date('Y-m-d H:i:s');

    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.

    Reference to undeclared property \VTCreateTodoTask->duplicateStatus
    Open

                $status = vtlib\Functions::getArrayFromValue($this->duplicateStatus);

    Call to method warning from undeclared class \App\Log
    Open

                    \App\Log::warning(__CLASS__ . '::' . __METHOD__ . ': To Do was ignored because a duplicate was found.' . $this->todo);

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

                    $groupExist = (new App\Db\Query())->from('vtiger_groups')

    Reference to undeclared property \VTCreateTodoTask->assigned_user_id
    Open

            if ('currentUser' === $this->assigned_user_id) {

    Reference to undeclared property \VTCreateTodoTask->assigned_user_id
    Open

            } elseif ('copyParentOwner' === $this->assigned_user_id) {

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

                $userExists = (new App\Db\Query())->from('vtiger_users')

    Reference to undeclared property \VTCreateTodoTask->todo
    Open

                    \App\Log::warning(__CLASS__ . '::' . __METHOD__ . ': To Do was ignored because a duplicate was found.' . $this->todo);

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

                $query = (new App\Db\Query())->from('vtiger_activity')

    Reference to undeclared property \VTCreateTodoTask->assigned_user_id
    Open

                    $userId = $this->assigned_user_id;

    Reference to undeclared property \VTCreateTodoTask->datefield_start
    Open

                $baseDateStart = $recordModel->get($this->datefield_start);

    Reference to undeclared property \VTCreateTodoTask->direction_start
    Open

            $date_start = strftime('%Y-%m-%d', $baseDateStart + (int) $this->days_start * 24 * 60 * 60 * ('before' == strtolower($this->direction_start) ? -1 : 1));

    Reference to undeclared property \VTCreateTodoTask->datefield_end
    Open

            if ('fromDateStart' !== $this->datefield_end) {

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

                    if (\App\User::isExists($userId)) {

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

                        $timeEnd = \App\User::getUserModel(\App\User::getActiveAdminId())->getDetail('end_hour');

    Reference to undeclared property \VTCreateTodoTask->todo
    Open

                        ['vtiger_activity.subject' => $this->todo],

    Reference to undeclared property \Vtiger_Record_Model->executeUser
    Open

                $userId = $recordModel->executeUser;

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

                        $timeEnd = \App\User::getUserModel($userIdFromGroup)->getDetail('end_hour');

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

                App\Db::getInstance()->createCommand()->insert('vtiger_activity_update_dates', [

    Argument 1 (input) is int but \str_pad() takes string
    Open

            return str_pad($hours, 2, '0', STR_PAD_LEFT) . ':' . str_pad($arr[2], 2, '0', STR_PAD_LEFT);

    Call to method trace from undeclared class \App\Log
    Open

            \App\Log::trace('Start ' . __CLASS__ . ':' . __FUNCTION__);

    Reference to undeclared property \VTCreateTodoTask->assigned_user_id
    Open

                    ->where(['id' => $this->assigned_user_id, 'status' => 'Active'])

    Reference to undeclared property \VTCreateTodoTask->assigned_user_id
    Open

                        ->where(['groupid' => $this->assigned_user_id])

    Reference to undeclared property \VTCreateTodoTask->assigned_user_id
    Open

                        $userId = $this->assigned_user_id;

    Reference to undeclared property \VTCreateTodoTask->priority
    Open

                'taskpriority' => $this->priority,

    Reference to undeclared property \VTCreateTodoTask->sendNotification
    Open

                'sendnotification' => ('' != $this->sendNotification && 'N' != $this->sendNotification),

    Reference to undeclared property \VTCreateTodoTask->days_end
    Open

            $endIncrement = \App\Fields\Double::formatToDb($this->days_end) * 24 * 60 * 60 * ('before' == strtolower($this->direction_end) ? -1 : 1);

    Reference to undeclared property \VTCreateTodoTask->assigned_user_id
    Open

            } elseif (!empty($this->assigned_user_id)) { // Added to check if the user/group is active

    Reference to undeclared property \VTCreateTodoTask->assigned_user_id
    Open

            } elseif ('triggerUser' === $this->assigned_user_id) {

    Reference to undeclared property \VTCreateTodoTask->datefield_end
    Open

                if ('wfRunTime' == $this->datefield_end) {

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

                $userId = \App\User::getCurrentUserId();

    Call to method getInstanceByModel from undeclared class \App\TextParser (Did you mean class \Tests\App\TextParser)
    Open

            $textParser = \App\TextParser::getInstanceByModel($recordModel);

    Reference to undeclared property \VTCreateTodoTask->status (Did you mean $status)
    Open

                'activitystatus' => $this->status,

    Call to method trace from undeclared class \App\Log
    Open

            \App\Log::trace('End ' . __CLASS__ . ':' . __FUNCTION__);

    Reference to undeclared property \VTCreateTodoTask->time (Did you mean $time)
    Open

                $timeWithSec = \App\Fields\Time::sanitizeDbFormat($this->time);

    Reference to undeclared property \VTCreateTodoTask->days_start
    Open

            $date_start = strftime('%Y-%m-%d', $baseDateStart + (int) $this->days_start * 24 * 60 * 60 * ('before' == strtolower($this->direction_start) ? -1 : 1));

    Reference to undeclared property \VTCreateTodoTask->datefield_end
    Open

                    $baseDateEnd = $recordModel->get($this->datefield_end);

    Reference to undeclared property \VTCreateTodoTask->direction_end
    Open

            $endIncrement = \App\Fields\Double::formatToDb($this->days_end) * 24 * 60 * 60 * ('before' == strtolower($this->direction_end) ? -1 : 1);

    Reference to undeclared property \VTCreateTodoTask->description
    Open

                'description' => $textParser->setContent($this->description)->parse()->getContent(),

    Reference to undeclared property \VTCreateTodoTask->doNotDuplicate
    Open

            if ('true' == $this->doNotDuplicate) {

    Reference to undeclared property \VTCreateTodoTask->datefield_start
    Open

            if ('wfRunTime' == $this->datefield_start) {

    Reference to undeclared property \VTCreateTodoTask->id
    Open

                    'task_id' => $this->id,

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

                        $timeEnd = \App\User::getUserModel($userId)->getDetail('end_hour');

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

                        $timeEnd = \App\User::getUserModel(\App\User::getActiveAdminId())->getDetail('end_hour');

    Reference to undeclared property \VTCreateTodoTask->updateDates
    Open

            if ('true' == $this->updateDates) {

    Reference to undeclared property \VTCreateTodoTask->todo
    Open

                'subject' => $textParser->setContent($this->todo)->parse()->getContent(),

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

            if ('currentUser' === $this->assigned_user_id) {
                $userId = \App\User::getCurrentUserId();
            } elseif ('triggerUser' === $this->assigned_user_id) {
                $userId = $recordModel->executeUser;
            } elseif ('copyParentOwner' === $this->assigned_user_id) {
    Severity: Major
    Found in modules/com_vtiger_workflow/tasks/VTCreateTodoTask.php and 1 other location - About 4 hrs to fix
    modules/com_vtiger_workflow/tasks/VTCreateEventTask.php on lines 44..64

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 178.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

        public static function conv12to24hour($timeStr)
        {
            $arr = [];
            preg_match('/(\d{1,2}):(\d{1,2})(am|pm)/', $timeStr, $arr);
            if ('am' == $arr[3]) {
    Severity: Major
    Found in modules/com_vtiger_workflow/tasks/VTCreateTodoTask.php and 1 other location - About 2 hrs to fix
    modules/com_vtiger_workflow/tasks/VTCreateEventTask.php on lines 139..149

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 139.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

            if ($parentRecord = \App\Record::getParentRecord($recordModel->getId())) {
                $parentModuleName = \App\Record::getType($parentRecord);
                $field = \App\ModuleHierarchy::getMappingRelatedField($parentModuleName);
                if ($field) {
                    $fields[$field] = $parentRecord;
    Severity: Major
    Found in modules/com_vtiger_workflow/tasks/VTCreateTodoTask.php and 1 other location - About 1 hr to fix
    modules/com_vtiger_workflow/tasks/VTCreateEventTask.php on lines 84..97

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 105.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

    class VTCreateTodoTask 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 11.
    Open

    <?php

    Line exceeds 120 characters; contains 275 characters
    Open

            return ['todo', 'description', 'time', 'days_start', 'days_end', 'status', 'priority', 'days', 'direction_start', 'datefield_start', 'direction_end', 'datefield_end', 'sendNotification', 'assigned_user_id', 'days', 'doNotDuplicate', 'duplicateStatus', 'updateDates'];

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

            if (null === $userId) {

    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

                $status = vtlib\Functions::getArrayFromValue($this->duplicateStatus);

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

                if ($query->count() > 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

            $time = explode(' ', $baseDateStart);

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

                $time = $time[1];

    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

                    return;

    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 (\count($time) < 2) {

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

                        $timeEnd = \App\User::getUserModel(\App\User::getActiveAdminId())->getDetail('end_hour');

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

                'taskpriority' => $this->priority,

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

            } elseif ('triggerUser' === $this->assigned_user_id) {

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

                    $groupExist = (new App\Db\Query())->from('vtiger_groups')

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

                        ->where(['groupid' => $this->assigned_user_id])

    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

            $baseDateStart = strtotime($match[0]);

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

                    if (\App\User::isExists($userId)) {

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

                preg_match('/\d\d\d\d-\d\d-\d\d/', $baseDateEnd, $match);

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

        {

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

                $userId = $recordModel->executeUser;

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

            } elseif ('copyParentOwner' === $this->assigned_user_id) {

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

                        $baseDateEnd = date('Y-m-d');

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

            }

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

                'subject' => $textParser->setContent($this->todo)->parse()->getContent(),

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

                $userId = $recordModel->get('assigned_user_id');

    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

                $due_date = strftime('%Y-%m-%d ', $baseDateEnd + $endIncrement);

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

            $textParser = \App\TextParser::getInstanceByModel($recordModel);

    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 function doTask($recordModel)

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

                $userId = Users::getActiveAdminUser();

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

                        'and',

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

            }

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

                    $baseDateEnd = $recordModel->get($this->datefield_end);

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

                        $timeEnd = \App\User::getUserModel($userIdFromGroup)->getDetail('end_hour');

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

                    $timeEnd = $timeEnd[1];

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

                'description' => $textParser->setContent($this->description)->parse()->getContent(),

    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 ('currentUser' === $this->assigned_user_id) {

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

                $dueDateTime = date('Y-m-d H:i:s', strtotime($date_start . ' ' . $time) + $endIncrement);

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

                $due_date = $dueDateTime[0];

    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

                        ['or', ['vtiger_activity.link' => $entityId], ['vtiger_activity.process' => $entityId]],

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

                    \App\Log::warning(__CLASS__ . '::' . __METHOD__ . ': To Do was ignored because a duplicate was found.' . $this->todo);

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

                    ->exists();

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

                $baseDateStart = $recordModel->get($this->datefield_start);

    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

                    $timeWithSec = \App\Fields\Time::sanitizeDbFormat($timeEnd);

    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

            $userId = $recordModel->get('assigned_user_id');

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

                    ->where([

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

                        ['vtiger_activity.subject' => $this->todo],

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

                    ]);

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

                $userId = \App\User::getCurrentUserId();

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

                if ($userExists) {

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

                if ('' == $baseDateStart) {

    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

                if ('wfRunTime' == $this->datefield_end) {

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

            $fields = [

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

            if ('true' == $this->doNotDuplicate) {

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

                        ['vtiger_crmentity.deleted' => 0],

    Line exceeds 120 characters; contains 134 characters
    Open

                    \App\Log::warning(__CLASS__ . '::' . __METHOD__ . ': To Do was ignored because a duplicate was found.' . $this->todo);

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

                    ->where(['id' => $this->assigned_user_id, 'status' => 'Active'])

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

                    $userId = $this->assigned_user_id;

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

                    }

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

            preg_match('/\d\d\d\d-\d\d-\d\d/', $baseDateStart, $match);

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

                        $timeEnd = \App\User::getUserModel($userId)->getDetail('end_hour');

    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

            if (!\App\Module::isModuleActive('Calendar')) {

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

            \App\Log::trace('Start ' . __CLASS__ . ':' . __FUNCTION__);

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

                    ->innerJoin('vtiger_crmentity', 'vtiger_crmentity.crmid = vtiger_activity.activityid')

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

                if (\count($status) > 0) {

    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

                $dbInsertDateTime = DateTimeField::convertToDBTimeZone($baseDateStart . ' ' . $timeWithSec);

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

                $time = $dbInsertDateTime->format('H:i:s');

    Line exceeds 120 characters; contains 145 characters
    Open

            $endIncrement = \App\Fields\Double::formatToDb($this->days_end) * 24 * 60 * 60 * ('before' == strtolower($this->direction_end) ? -1 : 1);

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

                $timeEnd = explode(' ', $baseDateEnd);

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

                    $dbInsertDateTime = DateTimeField::convertToDBTimeZone($baseDateEnd . ' ' . $timeWithSec);

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

         * @param Vtiger_Record_Model $recordModel

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

            }

    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

                $query = (new App\Db\Query())->from('vtiger_activity')

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

                $baseDateEnd = strtotime($match[0]);

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

                $dueDateTime = explode(' ', $dueDateTime);

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

                $timeEnd = $dueDateTime[1];

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

            return ['todo', 'description', 'time', 'days_start', 'days_end', 'status', 'priority', 'days', 'direction_start', 'datefield_start', 'direction_end', 'datefield_end', 'sendNotification', 'assigned_user_id', 'days', 'doNotDuplicate', 'duplicateStatus', 'updateDates'];

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

                        $userId = $this->assigned_user_id;

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

            $date_start = strftime('%Y-%m-%d', $baseDateStart + (int) $this->days_start * 24 * 60 * 60 * ('before' == strtolower($this->direction_start) ? -1 : 1));

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

            if ('fromDateStart' !== $this->datefield_end) {

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

                    $timeEnd = $dbInsertDateTime->format('H:i:s');

    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

                    'parent' => $recordModel->getId(),

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

            $field = \App\ModuleHierarchy::getMappingRelatedField($moduleName);

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

            \App\Log::trace('End ' . __CLASS__ . ':' . __FUNCTION__);

    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

                $baseDateStart = date('Y-m-d H:i:s');

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

                $timeWithSec = \App\Fields\Time::sanitizeDbFormat($this->time);

    Line exceeds 120 characters; contains 160 characters
    Open

            $date_start = strftime('%Y-%m-%d', $baseDateStart + (int) $this->days_start * 24 * 60 * 60 * ('before' == strtolower($this->direction_start) ? -1 : 1));

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

                    $baseDateEnd = date('Y-m-d H:i:s');

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

                    } elseif ($userIdFromGroup = current(\App\PrivilegeUtil::getUsersByGroup($userId))) {

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

                'activitystatus' => $this->status,

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

            $newRecordModel->setData($fields);

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

                App\Db::getInstance()->createCommand()->insert('vtiger_activity_update_dates', [

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

                ])->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

        /**

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

            } elseif (!empty($this->assigned_user_id)) { // Added to check if the user/group is active

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

                        ->exists();

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

                    if ($groupExist) {

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

            if ('wfRunTime' == $this->datefield_start) {

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

            $endIncrement = \App\Fields\Double::formatToDb($this->days_end) * 24 * 60 * 60 * ('before' == strtolower($this->direction_end) ? -1 : 1);

    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

                    }

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

                $parentModuleName = \App\Record::getType($parentRecord);

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

                $field = \App\ModuleHierarchy::getMappingRelatedField($parentModuleName);

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

                }

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

            $newRecordModel->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

            preg_match('/(\d{1,2}):(\d{1,2})(am|pm)/', $timeStr, $arr);

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

            return ['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

                    }

    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

                return;

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

                        ['vtiger_activity.activitytype' => 'Task'],

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

                    $query->andWhere(['not in', 'vtiger_activity.status', $status]);

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

                }

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

                $userExists = (new App\Db\Query())->from('vtiger_users')

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

                    $baseDateStart = date('Y-m-d');

    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

                    if ('' == $baseDateEnd) {

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

                if (\count($timeEnd) < 2) {

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

                'activitytype' => 'Task',

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

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

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

                $relationModel->addRelation($recordModel->getId(), $newRecordModel->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

                'due_date' => $due_date,

    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 str_pad($hours, 2, '0', STR_PAD_LEFT) . ':' . str_pad($arr[2], 2, '0', STR_PAD_LEFT);

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

                'assigned_user_id' => $userId,

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

            }

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

            $newRecordModel = Vtiger_Record_Model::getCleanInstance('Calendar');

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

            if ($relationModel) {

    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

                'time_end' => $timeEnd,

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

                'visibility' => 'Private',

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

                    $fields[$field] = $parentRecord;

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

                if ($parentRecord = \App\Record::getParentRecord($parentRecord)) {

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

                'time_start' => $time,

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

            if ($field) {

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

        public static function conv12to24hour($timeStr)

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

        public function getTimeFieldList()

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

                    $parentModuleName = \App\Record::getType($parentRecord);

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

                    $field = \App\ModuleHierarchy::getMappingRelatedField($parentModuleName);

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

                        $fields[$field] = $parentRecord;

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

            if ('true' == $this->updateDates) {

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

            $relationModel = \Vtiger_Relation_Model::getInstance($recordModel->getModule(), $newRecordModel->getModule());

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

                    'activityid' => $newRecordModel->getId(),

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

            if ('am' == $arr[3]) {

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

        }

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

                'sendnotification' => ('' != $this->sendNotification && 'N' != $this->sendNotification),

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

            }

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

                    'task_id' => $this->id,

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

            }

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

                $fields[$field] = $recordModel->getId();

    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

                $hours = ((int) $arr[1]) % 12 + 12;

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

                'date_start' => $date_start,

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

            if ($parentRecord = \App\Record::getParentRecord($recordModel->getId())) {

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

                if ($field) {

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

                    if ($field) {

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

                $hours = ((int) $arr[1]) % 12;

    The variable $date_start is not named in camelCase.
    Open

        public function doTask($recordModel)
        {
            if (!\App\Module::isModuleActive('Calendar')) {
                return;
            }

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $date_start is not named in camelCase.
    Open

        public function doTask($recordModel)
        {
            if (!\App\Module::isModuleActive('Calendar')) {
                return;
            }

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $due_date is not named in camelCase.
    Open

        public function doTask($recordModel)
        {
            if (!\App\Module::isModuleActive('Calendar')) {
                return;
            }

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $due_date is not named in camelCase.
    Open

        public function doTask($recordModel)
        {
            if (!\App\Module::isModuleActive('Calendar')) {
                return;
            }

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $date_start is not named in camelCase.
    Open

        public function doTask($recordModel)
        {
            if (!\App\Module::isModuleActive('Calendar')) {
                return;
            }

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $due_date is not named in camelCase.
    Open

        public function doTask($recordModel)
        {
            if (!\App\Module::isModuleActive('Calendar')) {
                return;
            }

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    There are no issues that match your filters.

    Category
    Status