YetiForceCompany/YetiForceCRM

View on GitHub
modules/ModTracker/helpers/Updates.php

Summary

Maintainability
B
4 hrs
Test Coverage
F
0%

Method getSummary has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function getSummary(array $modules, array $actions, array $dateRange, ?int $owner, ?int $historyOwner): array
    {
        $updates = $usedActions = [];
        $query = (new \App\Db\Query())
            ->select(['vtiger_modtracker_basic.module'])
Severity: Minor
Found in modules/ModTracker/helpers/Updates.php - About 1 hr to fix

    Method getQueryGenerator has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function getQueryGenerator(string $moduleName, array $actions, array $dateRange, ?int $owner, ?int $historyOwner, ?Vtiger_Paging_Model $pagingModel = null): App\QueryGenerator
        {
            $queryGenerator = (new \App\QueryGenerator($moduleName))
                ->setFields([])
                ->addJoin([
    Severity: Minor
    Found in modules/ModTracker/helpers/Updates.php - About 1 hr to fix

      Method getQueryGenerator has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public static function getQueryGenerator(string $moduleName, array $actions, array $dateRange, ?int $owner, ?int $historyOwner, ?Vtiger_Paging_Model $pagingModel = null): App\QueryGenerator
      Severity: Minor
      Found in modules/ModTracker/helpers/Updates.php - About 45 mins to fix

        Method getUpdates has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public static function getUpdates(string $moduleName, array $actions, array $dateRange, ?int $owner, ?int $historyOwner, Vtiger_Paging_Model $pagingModel): array
        Severity: Minor
        Found in modules/ModTracker/helpers/Updates.php - About 45 mins to fix

          Method getSummary has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public static function getSummary(array $modules, array $actions, array $dateRange, ?int $owner, ?int $historyOwner): array
          Severity: Minor
          Found in modules/ModTracker/helpers/Updates.php - About 35 mins to fix

            Missing class import via use statement (line '58', column '89').
            Open

                        $queryGenerator->setCustomColumn(['vtiger_modtracker_basic.status', 'counter' => new \yii\db\Expression('COUNT(*)')])->setCustomGroup(['vtiger_modtracker_basic.status']);

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

                                ['vtiger_crmentity.crmid' => (new \App\Db\Query())->select(['crmid'])->from('u_#__crmentity_showners')->where(['userid' => $owner])]

            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 '31', column '17').
            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 '134', column '23').
            Open

                        $recordModel = new ModTracker_Record_Model();

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

                    $queryGenerator = (new \App\QueryGenerator($moduleName))

            MissingImport

            Since: 2.7.0

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

            Example

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

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

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

                            ['vtiger_modtracker_basic.status' => $actions],

            Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

            On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

            Noncompliant Code Example

            With the default threshold of 3:

            function run() {
              prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
              execute('action1');
              release('action1');
            }
            

            Compliant Solution

            ACTION_1 = 'action1';
            
            function run() {
              prepare(ACTION_1);
              execute(ACTION_1);
              release(ACTION_1);
            }
            

            Exceptions

            To prevent generating some false-positives, literals having less than 5 characters are excluded.

            Call to method setCustomColumn from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $queryGenerator->setCustomColumn('vtiger_modtracker_basic.*');
            Severity: Critical
            Found in modules/ModTracker/helpers/Updates.php by phan

            Call to method setCustomColumn from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                        $queryGenerator->setCustomColumn(['vtiger_modtracker_basic.status', 'counter' => new \yii\db\Expression('COUNT(*)')])->setCustomGroup(['vtiger_modtracker_basic.status']);
            Severity: Critical
            Found in modules/ModTracker/helpers/Updates.php by phan

            Call to method createQuery from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $dataReader = $queryGenerator->createQuery()->orderBy(['vtiger_modtracker_basic.id' => SORT_DESC])->createCommand()->query();
            Severity: Critical
            Found in modules/ModTracker/helpers/Updates.php by phan

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

                                ['vtiger_crmentity.crmid' => (new \App\Db\Query())->select(['crmid'])->from('u_#__crmentity_showners')->where(['userid' => $owner])]
            Severity: Critical
            Found in modules/ModTracker/helpers/Updates.php by phan

            Return type of getQueryGenerator() is undeclared type \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                public static function getQueryGenerator(string $moduleName, array $actions, array $dateRange, ?int $owner, ?int $historyOwner, ?Vtiger_Paging_Model $pagingModel = null): App\QueryGenerator
            Severity: Minor
            Found in modules/ModTracker/helpers/Updates.php by phan

            Call to method createQuery from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                        $result = $queryGenerator->createQuery()->createCommand()->queryAllByGroup(0);
            Severity: Critical
            Found in modules/ModTracker/helpers/Updates.php by phan

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

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

            Call to method __construct from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $queryGenerator = (new \App\QueryGenerator($moduleName))
            Severity: Critical
            Found in modules/ModTracker/helpers/Updates.php by phan

            Call to method __construct from undeclared class \yii\db\Expression
            Open

                        $queryGenerator->setCustomColumn(['vtiger_modtracker_basic.status', 'counter' => new \yii\db\Expression('COUNT(*)')])->setCustomGroup(['vtiger_modtracker_basic.status']);
            Severity: Critical
            Found in modules/ModTracker/helpers/Updates.php by phan

            Call to method setFields from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $queryGenerator = (new \App\QueryGenerator($moduleName))
            Severity: Critical
            Found in modules/ModTracker/helpers/Updates.php by phan

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

            class ModTracker_Updates_Helper

            The class ModTracker_Updates_Helper is not named in CamelCase.
            Open

            class ModTracker_Updates_Helper
            {
                /**
                 * Gets summary.
                 *

            CamelCaseClassName

            Since: 0.2

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

            Example

            class class_name {
            }

            Source

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

                /**

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

                        $queryGenerator->addCondition('assigned_user_id', $owner, 'e', false);

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

                 *  Gets updates.

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

                    return $updates;

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

                 * @param Vtiger_Paging_Model|null $pagingModel

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

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

                    if ($owner) {

            Line exceeds 120 characters; contains 122 characters
            Open

                    $queryGenerator = self::getQueryGenerator($moduleName, $actions, $dateRange, $owner, $historyOwner, $pagingModel);

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

                 *

            Line exceeds 120 characters; contains 127 characters
            Open

                public static function getSummary(array $modules, array $actions, array $dateRange, ?int $owner, ?int $historyOwner): array

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

                 * Gets QueryGenerator object.

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

                        ->addNativeCondition([

            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 int|null                 $historyOwner

            Line exceeds 120 characters; contains 193 characters
            Open

                public static function getQueryGenerator(string $moduleName, array $actions, array $dateRange, ?int $owner, ?int $historyOwner, ?Vtiger_Paging_Model $pagingModel = null): App\QueryGenerator

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

                            'vtiger_crmentity.crmid = vtiger_modtracker_basic.crmid'

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

                            $dateRange[0] . ' 00:00:00', $dateRange[1] . ' 23:59:59'

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

                 * @param array               $actions

            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

                                'between',

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

                        $moduleName = $row['module'];

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

                        $result = $queryGenerator->createQuery()->createCommand()->queryAllByGroup(0);

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

                            $updates[$moduleName] = $result;

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

                 * @param string                   $moduleName

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

                public static function getQueryGenerator(string $moduleName, array $actions, array $dateRange, ?int $owner, ?int $historyOwner, ?Vtiger_Paging_Model $pagingModel = null): App\QueryGenerator

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

                        ->addJoin([

            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

                 * @param array               $dateRange

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

                    $updates = [];

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

                    $queryGenerator->setCustomColumn('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.changedon',

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

                    if ($owner) {

            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

                 * @param string              $moduleName

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

                 * @param int|null            $owner

            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

                 * Gets summary.

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

                 * @param array    $modules

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

                        ]);

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

                        $queryGenerator->setCustomColumn(['vtiger_modtracker_basic.status', 'counter' => new \yii\db\Expression('COUNT(*)')])->setCustomGroup(['vtiger_modtracker_basic.status']);

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

                public static function getUpdates(string $moduleName, array $actions, array $dateRange, ?int $owner, ?int $historyOwner, Vtiger_Paging_Model $pagingModel): array

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

            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

                 * @param array                    $actions

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

                 *

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

                        ->setFields([])

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

                        ->addNativeCondition(['vtiger_modtracker_basic.status' => $actions])

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

                            'between',

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

                        if ($queryGenerator->getModuleField('shownerid')) {

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

                            $queryGenerator->addCondition('shownerid', $owner, 'e', false);

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

                    $queryGenerator = self::getQueryGenerator($moduleName, $actions, $dateRange, $owner, $historyOwner, $pagingModel);

            Line exceeds 120 characters; contains 133 characters
            Open

                    $dataReader = $queryGenerator->createQuery()->orderBy(['vtiger_modtracker_basic.id' => SORT_DESC])->createCommand()->query();

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

                 *

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

                 * @return array

            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.module' => $modules],

            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_crmentity.smownerid' => $owner],

            Line exceeds 120 characters; contains 152 characters
            Open

                                ['vtiger_crmentity.crmid' => (new \App\Db\Query())->select(['crmid'])->from('u_#__crmentity_showners')->where(['userid' => $owner])]

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

                    $query->distinct(true);

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

                        if ($result) {

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

                 * @param int|null                 $owner

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

                            '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

                        if (\count($updates) === $pagingModel->getPageLimit()) {

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

                 * @param array    $dateRange

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

                                $dateRange[0] . ' 00:00:00', $dateRange[1] . ' 23:59:59'

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

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

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

                        }

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

                    if ($historyOwner) {

            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 array

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

                 */

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

                        $recordModel = new ModTracker_Record_Model();

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

                 * @param array    $actions

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

                    $updates = $usedActions = [];

            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

                            ['vtiger_modtracker_basic.status' => $actions],

            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

                            'vtiger_modtracker_basic.changedon',

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

                        $queryGenerator->addNativeCondition(['vtiger_modtracker_basic.whodid' => $historyOwner]);

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

                 * @param int|null            $historyOwner

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

                        $recordModel->setData($row)->setParent($row['crmid'], $moduleName);

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

                        $query->innerJoin('vtiger_crmentity', 'vtiger_modtracker_basic.crmid=vtiger_crmentity.crmid')

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

                            ->andWhere(['or',

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

                        $queryGenerator = self::getQueryGenerator($moduleName, $actions, $dateRange, $owner, $historyOwner);

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

                    $queryGenerator = (new \App\QueryGenerator($moduleName))

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

                        ])->setStateCondition('All');

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

                        $queryGenerator->setLimit($pagingModel->getPageLimit() + 1)->setOffset($pagingModel->getStartIndex());

            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 = $queryGenerator->createQuery()->orderBy(['vtiger_modtracker_basic.id' => SORT_DESC])->createCommand()->query();

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

                            $pagingModel->set('nextPageExists', 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

                            $usedActions = array_unique(array_merge($usedActions, array_keys($result)));

            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 $queryGenerator;

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

                                ['vtiger_crmentity.crmid' => (new \App\Db\Query())->select(['crmid'])->from('u_#__crmentity_showners')->where(['userid' => $owner])]

            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 int|null $owner

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

                 * @param int|null $historyOwner

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

                        ->where(['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

                 * @return App\QueryGenerator

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

                            'INNER JOIN',

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

                 * @param Vtiger_Paging_Model $pagingModel

            Line exceeds 120 characters; contains 165 characters
            Open

                public static function getUpdates(string $moduleName, array $actions, array $dateRange, ?int $owner, ?int $historyOwner, Vtiger_Paging_Model $pagingModel): array

            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

                        $updates[$recordModel->getId()] = $recordModel;

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

                public static function getSummary(array $modules, array $actions, array $dateRange, ?int $owner, ?int $historyOwner): array

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

                        ->select(['vtiger_modtracker_basic.module'])

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

                            [

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

                        $query->andWhere(['vtiger_modtracker_basic.whodid' => $historyOwner]);

            Line exceeds 120 characters; contains 182 characters
            Open

                        $queryGenerator->setCustomColumn(['vtiger_modtracker_basic.status', 'counter' => new \yii\db\Expression('COUNT(*)')])->setCustomGroup(['vtiger_modtracker_basic.status']);

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

                    return [$updates, $usedActions];

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

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

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

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

            class ModTracker_Updates_Helper

            There are no issues that match your filters.

            Category
            Status