YetiForceCompany/YetiForceCRM

View on GitHub
modules/ModTracker/crons/ReviewChanges.php

Summary

Maintainability
B
4 hrs
Test Coverage
F
9%

Function reviewChanges has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    public function reviewChanges()
    {
        $db = \App\Db::getInstance();
        $recordsList = $this->getRecords();
        if (!empty($recordsList)) {
Severity: Minor
Found in modules/ModTracker/crons/ReviewChanges.php - About 3 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 reviewChanges has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function reviewChanges()
    {
        $db = \App\Db::getInstance();
        $recordsList = $this->getRecords();
        if (!empty($recordsList)) {
Severity: Minor
Found in modules/ModTracker/crons/ReviewChanges.php - About 1 hr to fix

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

        public function reviewChanges()

    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

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

            $query = (new \App\Db\Query())->from('u_#__reviewed_queue');

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

            $id = (new \App\Db\Query())

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

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

    Missing class import via use statement (line '120', column '19').
    Open

                    $query = (new \App\Db\Query())

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

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

    Missing class import via use statement (line '99', column '19').
    Open

                $request = new \App\Request($data, false);

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

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

    Avoid using static access to class '\App\Db' in method 'addPartToDBRecursive'.
    Open

            $db = \App\Db::getInstance();

    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_Mass_Action' in method 'getRecords'.
    Open

                $this->recordList = Vtiger_Mass_Action::getRecordsListFromRequest($request);

    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 'ModTracker_Record_Model' in method 'reviewChanges'.
    Open

                                ModTracker_Record_Model::unsetReviewed($crmId, $userId, $row['id']);

    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\Db' in method 'process'.
    Open

            $db = \App\Db::getInstance();

    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\Db' in method 'finish'.
    Open

            $db = \App\Db::getInstance();

    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\Json' in method 'addPartToDBRecursive'.
    Open

            $data = \App\Json::encode(['selected_ids' => $list]);

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

            } else {
                $this->recordList = $this->get('selected_ids');
            }

    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\Json' in method 'init'.
    Open

                    $value = \App\Json::decode($row['data']);

    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 'getRecords'.
    Open

                $data['module'] = \App\Module::getModuleName($this->get('tabid'));

    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\Config' in method '__construct'.
    Open

            $this->limit = App\Config::module('ModTracker', 'REVIEWED_SCHEDULE_LIMIT');

    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\Db' in method 'reviewChanges'.
    Open

            $db = \App\Db::getInstance();

    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\Db' in method 'setReviewed'.
    Open

            $db = \App\Db::getInstance();

    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

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

                        ->select(['u' => 'last_reviewed_users', 'id', 'changedon'])

    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 "selected_ids" 3 times.
    Open

            if ('all' === ($this->get('selected_ids')[0] ?? '')) {

    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 "tabid" 3 times.
    Open

                $data['module'] = \App\Module::getModuleName($this->get('tabid'));

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

                        $userId = $this->get('userid');

    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 "u_#__reviewed_queue" 4 times.
    Open

            $query = (new \App\Db\Query())->from('u_#__reviewed_queue');

    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.

    Suspicious array access to \key
    Open

                $data['module'] = \App\Module::getModuleName($this->get('tabid'));

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

            return $db->createCommand()->update(
    Severity: Critical
    Found in modules/ModTracker/crons/ReviewChanges.php by phan

    Argument 1 (time) is \key but \strtotime() takes string
    Open

                        if (strtotime($row['time']) >= strtotime($this->get('changedon'))) {

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

            $db->createCommand()->delete('u_#__reviewed_queue', ['=', 'id', $this->get('id')])->execute();
    Severity: Critical
    Found in modules/ModTracker/crons/ReviewChanges.php by phan

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

            $id = (new \App\Db\Query())
    Severity: Critical
    Found in modules/ModTracker/crons/ReviewChanges.php by phan

    Return type of get() is undeclared type \key
    Open

        private function get($key)

    Argument 1 (tabId) is \key but \App\Module::getModuleName() takes int defined at /code/app/Module.php:129
    Open

                $data['module'] = \App\Module::getModuleName($this->get('tabid'));

    Suspicious array access to \key
    Open

            if ('all' === ($this->get('selected_ids')[0] ?? '')) {

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

                    $query = (new \App\Db\Query())
    Severity: Critical
    Found in modules/ModTracker/crons/ReviewChanges.php by phan

    Suspicious type \key of a variable or expression used to build a string. (Expected type to be able to cast to a string)
    Open

                        if (false !== strpos($row['u'], "#$userId#")) {

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

            $db->createCommand()->insert('u_#__reviewed_queue', [
    Severity: Critical
    Found in modules/ModTracker/crons/ReviewChanges.php by phan

    Assigning \key to property but \ModTracker_ReviewChanges_Cron->recordList is array{}|int[]
    Open

                $this->recordList = $this->get('selected_ids');

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

            $query = (new \App\Db\Query())->from('u_#__reviewed_queue');
    Severity: Critical
    Found in modules/ModTracker/crons/ReviewChanges.php by phan

    When fetching an array index from a value of type array|array{0:mixed}, found an array index of type 'data', but expected the index to be of type int
    Open

                    $value = \App\Json::decode($row['data']);

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

    class ModTracker_ReviewChanges_Cron extends \App\CronHandler

    Avoid variables with short names like $db. Configured minimum length is 3.
    Open

            $db = \App\Db::getInstance();

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#shortvariable

    Avoid variables with short names like $id. Configured minimum length is 3.
    Open

            $id = (new \App\Db\Query())

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#shortvariable

    Avoid variables with short names like $db. Configured minimum length is 3.
    Open

            $db = \App\Db::getInstance();

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#shortvariable

    The class ModTracker_ReviewChanges_Cron is not named in CamelCase.
    Open

    class ModTracker_ReviewChanges_Cron extends \App\CronHandler
    {
        const MAX_RECORDS = 200;
    
        private $limit;

    CamelCaseClassName

    Since: 0.2

    It is considered best practice to use the CamelCase notation to name classes.

    Example

    class class_name {
    }

    Source

    Avoid variables with short names like $db. Configured minimum length is 3.
    Open

            $db = \App\Db::getInstance();

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#shortvariable

    Avoid variables with short names like $id. Configured minimum length is 3.
    Open

        private function setReviewed($id, $users)

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#shortvariable

    Avoid variables with short names like $db. Configured minimum length is 3.
    Open

            $db = \App\Db::getInstance();

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#shortvariable

    Avoid variables with short names like $db. Configured minimum length is 3.
    Open

            $db = \App\Db::getInstance();

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#shortvariable

    Only one argument is allowed per line in a multi-line function call
    Open

                'vtiger_modtracker_basic', ['last_reviewed_users' => '#' . implode('#', array_filter($lastReviewedUsers)) . '#'], ['id' => $id]

    Only one argument is allowed per line in a multi-line function call
    Open

                'vtiger_modtracker_basic', ['last_reviewed_users' => '#' . implode('#', array_filter($lastReviewedUsers)) . '#'], ['id' => $id]

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

        private $counter = 0;

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

        private $recordList = [];

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

        private $valueMap = [];

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

        private $done = [];

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

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

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

            $dataReader->close();

    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 = $this->get('data');

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

                        break;

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

                        ->where(['crmid' => $crmId])

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

                        $userId = $this->get('userid');

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

                    $this->done[] = $crmId;

    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 ('data' === $key) {

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

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

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

                            break;

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

            $db = \App\Db::getInstance();

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

            $lastReviewedUsers[] = $this->get('userid');

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

        const MAX_RECORDS = 200;

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

            foreach ($row as $key => $value) {

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

                    $value = \App\Json::decode($row['data']);

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

            $this->recordList = [];

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

         * @param string $key

    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

         * Function marks forwarded records as reviewed.

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

         */

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

                        ->from('vtiger_modtracker_basic')

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

                        }

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

                'vtiger_modtracker_basic', ['last_reviewed_users' => '#' . implode('#', array_filter($lastReviewedUsers)) . '#'], ['id' => $id]

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

        private function finish()

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

        {

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

            $db->createCommand()->delete('u_#__reviewed_queue', ['=', 'id', $this->get('id')])->execute();

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

        private $end = false;

    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 init($row)

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

            $this->done = [];

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

            return $this->valueMap[$key];

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

         * @return array - List of records

    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

            $db = \App\Db::getInstance();

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

        private $limit;

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

        private $displayed;

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

                if ($this->isEnd()) {

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

                }

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

                    $this->init($value);

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

                $this->recordList = Vtiger_Mass_Action::getRecordsListFromRequest($request);

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

            return $this->recordList;

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

            $db = \App\Db::getInstance();

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

                    ++$this->counter;

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

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

         * Function to clean data in database.

    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 __construct()

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

                    break;

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

        }

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

         * Initiation of data.

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

                $this->valueMap[$key] = $value;

    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 ($changed) {

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

                $this->finish();

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

            if (\count($this->done) < \count($this->recordList)) {

    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 array $row

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

            $this->valueMap = [];

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

            if ('all' === ($this->get('selected_ids')[0] ?? '')) {

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

                $data['module'] = \App\Module::getModuleName($this->get('tabid'));

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

            $recordsList = $this->getRecords();

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

                foreach ($recordsList as $crmId) {

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

                    if ($this->counter === $this->limit) {

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

                        if (strtotime($row['time']) >= strtotime($this->get('changedon'))) {

    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->close();

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

        public function process()

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

                $this->init($row);

    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

                $request = new \App\Request($data, false);

    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

            $db = \App\Db::getInstance();

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

            $query = (new \App\Db\Query())->from('u_#__reviewed_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

         *

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

                $this->recordList = $this->get('selected_ids');

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

                    $query = (new \App\Db\Query())

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

                        ->orderBy(['changedon' => SORT_DESC, 'id' => SORT_DESC]);

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

                        if (false !== strpos($row['u'], "#$userId#")) {

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

                                ModTracker_Record_Model::unsetReviewed($crmId, $userId, $row['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

            $id = (new \App\Db\Query())

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

                'tabid' => $this->get('tabid'),

    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

            $this->limit = App\Config::module('ModTracker', 'REVIEWED_SCHEDULE_LIMIT');

    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

                $this->reviewChanges();

    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

         * Function to get records 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

                            break;

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

         * @param mixed $users

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

        private function setReviewed($id, $users)

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

            return $db->createCommand()->update(

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

            }

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

                $this->clearData();

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

         */

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

         * Clear data.

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

        public function clearData()

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

         * Get key value.

    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 key value

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

        public function reviewChanges()

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

            if (!empty($recordsList)) {

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

         * Function marks forwarded records as reviewed.

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

         * @param mixed $records

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

        {

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

        /** {@inheritdoc} */

    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

                        ->andWhere(['<>', 'status', $this->displayed])

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

         */

    Line exceeds 120 characters; contains 139 characters
    Open

                'vtiger_modtracker_basic', ['last_reviewed_users' => '#' . implode('#', array_filter($lastReviewedUsers)) . '#'], ['id' => $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

         * Function adds records to task queue that updates reviewing changes in records.

    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 isEnd()

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

            if (!\is_array($row)) {

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

         */

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

        private function getRecords()

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

                        ->select(['u' => 'last_reviewed_users', 'id', 'changedon'])

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

                            $changed = $this->setReviewed($row['id'], $row['u']);

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

                        }

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

            $db->createCommand()->insert('u_#__reviewed_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

         */

    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' => $data,

    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 $this->end;

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

         * Function to check the status cron.

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

         *

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

            $this->displayed = ModTracker_Record_Model::DISPLAYED;

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

                $row = [$row];

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

        private function get($key)

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

            }

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

                        $this->end = true;

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

                            }

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

        /**

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

            $lastReviewedUsers = explode('#', $users);

    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

                $records = array_diff($this->recordList, $this->done);

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

                $this->addPartToDBRecursive($records);

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

        }

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

        {

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

        {

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

         */

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

        {

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

        /**

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

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

    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 bool

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

                'id' => $id,

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

                'userid' => $this->get('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

            $db = \App\Db::getInstance();

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

                'time' => $this->get('time'),

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

            if (!empty($records)) {

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

        private function addPartToDBRecursive($records)

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

            $list = array_splice($records, 0, self::MAX_RECORDS);

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

                $this->addPartToDBRecursive($records);

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

            $data = \App\Json::encode(['selected_ids' => $list]);

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

                ->from('u_#__reviewed_queue')

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

                ->max('id') + 1;

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

            ])->execute();

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

    class ModTracker_ReviewChanges_Cron extends \App\CronHandler

    There are no issues that match your filters.

    Category
    Status