YetiForceCompany/YetiForceCRM

View on GitHub
modules/Vtiger/views/RecordActivity.php

Summary

Maintainability
A
1 hr
Test Coverage
F
0%

Method process has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function process(App\Request $request)
    {
        $moduleName = $this->record->getModuleName();
        $dateTime = $request->getByType('dateTime', 'dateTimeInUserFormat');
        $dateTime = \App\Fields\DateTime::formatToDb($dateTime);
Severity: Minor
Found in modules/Vtiger/views/RecordActivity.php - About 1 hr to fix

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

    class Vtiger_RecordActivity_View extends Vtiger_Index_View
    {
        /**
         * Record model instance.
         *

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

                throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);

    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 '54', 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 '39', column '23').
    Open

            $currentTime = (new \DateTimeField(date('Y-m-d H:i:s')))->getDisplayFullDateTimeValue();

    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 '45', 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 '65', column '19').
    Open

            $response = new Vtiger_Response();

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

        public function checkPermission(App\Request $request)
        {
            if ($request->isEmpty('record', true) || !\App\Config::performance('recordActivityNotifier', false) || !($this->record = Vtiger_Record_Model::getInstanceById($request->getInteger('record'), $request->getModule()))->isViewable() || !$this->record->getModule()->isTrackingEnabled() || !$this->record->getModule()->isPermitted('RecordActivityNotifier')) {
                throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);
            }

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

            $response->setResult(['title' => \App\Language::translate('LBL_ATTENTION'), 'dateTime' => $currentTime, 'text' => $content]);

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

            if ($request->isEmpty('record', true) || !\App\Config::performance('recordActivityNotifier', false) || !($this->record = Vtiger_Record_Model::getInstanceById($request->getInteger('record'), $request->getModule()))->isViewable() || !$this->record->getModule()->isTrackingEnabled() || !$this->record->getModule()->isPermitted('RecordActivityNotifier')) {

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

                ->andWhere(['<>', 'vtiger_modtracker_basic.whodid', \App\User::getCurrentUserRealId()])

    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_Record_Model' in method 'checkPermission'.
    Open

            if ($request->isEmpty('record', true) || !\App\Config::performance('recordActivityNotifier', false) || !($this->record = Vtiger_Record_Model::getInstanceById($request->getInteger('record'), $request->getModule()))->isViewable() || !$this->record->getModule()->isTrackingEnabled() || !$this->record->getModule()->isPermitted('RecordActivityNotifier')) {

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

            $dateTime = \App\Fields\DateTime::formatToDb($dateTime);

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

            $actions = ModTracker::getAllActionsTypes();

    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

    Call to undeclared method \Vtiger_Viewer::assign
    Open

                $viewer->assign('UPDATES', $updates);
    Severity: Critical
    Found in modules/Vtiger/views/RecordActivity.php by phan

    Argument 1 (value) is string but \DateTimeField::__construct() takes \type defined at /code/include/fields/DateTimeField.php:31
    Open

            $currentTime = (new \DateTimeField(date('Y-m-d H:i:s')))->getDisplayFullDateTimeValue();

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

            $query = (new \App\Db\Query())
    Severity: Critical
    Found in modules/Vtiger/views/RecordActivity.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

                $viewer->assign('SOURCE_MODULE_NAME', 'ModTracker');
    Severity: Critical
    Found in modules/Vtiger/views/RecordActivity.php by phan

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

                ->andWhere(['<>', 'vtiger_modtracker_basic.whodid', \App\User::getCurrentUserRealId()])
    Severity: Critical
    Found in modules/Vtiger/views/RecordActivity.php by phan

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

    class Vtiger_RecordActivity_View extends Vtiger_Index_View

    The class Vtiger_RecordActivity_View is not named in CamelCase.
    Open

    class Vtiger_RecordActivity_View extends Vtiger_Index_View
    {
        /**
         * Record model instance.
         *

    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

        public function process(App\Request $request)

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

            }

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

            $response->setEmitType(\Vtiger_Response::$EMIT_JSON);

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

         * Record model instance.

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

            if ($request->isEmpty('record', true) || !\App\Config::performance('recordActivityNotifier', false) || !($this->record = Vtiger_Record_Model::getInstanceById($request->getInteger('record'), $request->getModule()))->isViewable() || !$this->record->getModule()->isTrackingEnabled() || !$this->record->getModule()->isPermitted('RecordActivityNotifier')) {

    Line exceeds 120 characters; contains 360 characters
    Open

            if ($request->isEmpty('record', true) || !\App\Config::performance('recordActivityNotifier', false) || !($this->record = Vtiger_Record_Model::getInstanceById($request->getInteger('record'), $request->getModule()))->isViewable() || !$this->record->getModule()->isTrackingEnabled() || !$this->record->getModule()->isPermitted('RecordActivityNotifier')) {

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

            $dateTime = $request->getByType('dateTime', 'dateTimeInUserFormat');

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

            $content = '';

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

                ->orderBy(['vtiger_modtracker_basic.id' => SORT_ASC])->limit(5);

    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

        public function isSessionExtend(App\Request $request)

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

        public function checkPermission(App\Request $request)

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

            $currentTime = (new \DateTimeField(date('Y-m-d H:i:s')))->getDisplayFullDateTimeValue();

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

            $response->setResult(['title' => \App\Language::translate('LBL_ATTENTION'), 'dateTime' => $currentTime, 'text' => $content]);

    Line exceeds 120 characters; contains 133 characters
    Open

            $response->setResult(['title' => \App\Language::translate('LBL_ATTENTION'), 'dateTime' => $currentTime, 'text' => $content]);

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

         */

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

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

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

            $response = new Vtiger_Response();

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

                throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);

    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

            $response->emit();

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

        }

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

        protected $record;

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

        }

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

            $dateTime = \App\Fields\DateTime::formatToDb($dateTime);

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

            unset($actions[ModTracker::$SHOW_HIDDEN_DATA]);

    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

                $content = $viewer->view('RecordActivityContent.tpl', 'ModTracker', 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

            $moduleName = $this->record->getModuleName();

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

         *

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

                $viewer->assign('SOURCE_MODULE_NAME', 'ModTracker');

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

            return false;

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

         * @var Vtiger_Record_Model

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

                ->andWhere(['<>', 'vtiger_modtracker_basic.whodid', \App\User::getCurrentUserRealId()])

    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

            if ($updates) {

    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

                ->where(['vtiger_modtracker_basic.crmid' => $this->record->getId()])

    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

            }

    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

                ->andWhere(['>=', 'vtiger_modtracker_basic.changedon', $dateTime])

    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

                $viewer = $this->getViewer($request);

    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

        /** {@inheritdoc} */

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

                ->andWhere(['vtiger_modtracker_basic.status' => array_keys($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

            $actions = ModTracker::getAllActionsTypes();

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

                $viewer->assign('UPDATES', $updates);

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

        /** {@inheritdoc} */

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

    class Vtiger_RecordActivity_View extends Vtiger_Index_View

    There are no issues that match your filters.

    Category
    Status