YetiForceCompany/YetiForceCRM

View on GitHub
modules/Notification/textparsers/Notifications.php

Summary

Maintainability
A
1 hr
Test Coverage
F
0%

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

    public function process()
    {
        $html = '';
        $scheduleData = \Vtiger_Watchdog_Model::getWatchingModulesSchedule($this->textParser->getParam('userId'), true);
        if (!$scheduleData) {
Severity: Minor
Found in modules/Notification/textparsers/Notifications.php - About 1 hr to fix

    Function process has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function process()
        {
            $html = '';
            $scheduleData = \Vtiger_Watchdog_Model::getWatchingModulesSchedule($this->textParser->getParam('userId'), true);
            if (!$scheduleData) {
    Severity: Minor
    Found in modules/Notification/textparsers/Notifications.php - About 45 mins 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

    Avoid using static access to class '\Notification_Module_Model' in method 'process'.
    Open

            $entries = \Notification_Module_Model::getEmailSendEntries($this->textParser->getParam('userId'), $modules, $this->textParser->getParam('startDate'), $this->textParser->getParam('endDate'));

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

            $notificationInstance = \Notification_Module_Model::getInstance('Notification');

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

            $scheduleData = \Vtiger_Watchdog_Model::getWatchingModulesSchedule($this->textParser->getParam('userId'), true);

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

                            $pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getMessage());

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

                            $pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getTitle());

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

                $html = \App\Language::translate('LBL_NO_NOTIFICATIONS', 'Notification');

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

                return \App\Language::translate('LBL_NO_NOTIFICATIONS', 'Notification');

    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

    syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ',' or ')'
    Open

                            $pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getTitle());

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

    class Notification_Notifications_TextParser extends \App\TextParser\Base

    The class Notification_Notifications_TextParser is not named in CamelCase.
    Open

    class Notification_Notifications_TextParser extends \App\TextParser\Base
    {
        /** @var string Class name */
        public $name = 'LBL_NOTIFICATIONS';
    
    

    CamelCaseClassName

    Since: 0.2

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

    Example

    class class_name {
    }

    Source

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

                            $pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getMessage());

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

                            $pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getTitle());

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

                            $pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getTitle());

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

                            $pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getMessage());

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

         */

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

            $entries = \Notification_Module_Model::getEmailSendEntries($this->textParser->getParam('userId'), $modules, $this->textParser->getParam('startDate'), $this->textParser->getParam('endDate'));

    Line exceeds 120 characters; contains 198 characters
    Open

            $entries = \Notification_Module_Model::getEmailSendEntries($this->textParser->getParam('userId'), $modules, $this->textParser->getParam('startDate'), $this->textParser->getParam('endDate'));

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

            $modules = $scheduleData['modules'];

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

                        $title = preg_replace_callback(

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

        /**

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

            $scheduleData = \Vtiger_Watchdog_Model::getWatchingModulesSchedule($this->textParser->getParam('userId'), true);

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

                    $html .= "<hr><strong>$type</strong><ul>";

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

                        $massage = preg_replace_callback(

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

        }

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

                            $pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getTitle());

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

        {

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

            $pattern = "/(?<=href=(\"|'))[^\"']+(?=(\"|'))/";

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

        public $name = 'LBL_NOTIFICATIONS';

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

                        $html .= "<li>$title<br />$massage</li>";

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

                    $html .= '</ul><br />';

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

         * @return string

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

            }

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

            $notificationInstance = \Notification_Module_Model::getInstance('Notification');

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

            foreach ($notificationInstance->getTypes() as $typeId => $type) {

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

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

            }

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

        /** @var mixed Parser type */

    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 $type = 'mail';

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

         * Process.

    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

                return \App\Language::translate('LBL_NO_NOTIFICATIONS', 'Notification');

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

    Line exceeds 120 characters; contains 123 characters
    Open

                            $pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getTitle());

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

                            $pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getMessage());

    Line exceeds 120 characters; contains 125 characters
    Open

                            $pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getMessage());

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

                $html = \App\Language::translate('LBL_NO_NOTIFICATIONS', 'Notification');

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

            $html = '';

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

                if (isset($entries[$typeId])) {

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

            if (empty($html)) {

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

        /** @var string Class name */

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

         *

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

                    foreach ($entries[$typeId] as $notification) {

    Multi-line function call not indented correctly; expected 20 spaces but found 24
    Open

                            $pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getTitle());

    Closing parenthesis of a multi-line function call must be on a line by itself
    Open

                            $pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getTitle());

    Multi-line function call not indented correctly; expected 20 spaces but found 24
    Open

                            $pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getMessage());

    Closing parenthesis of a multi-line function call must be on a line by itself
    Open

                            $pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getMessage());

    Space before opening parenthesis of function call prohibited
    Open

                            $pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getTitle());

    Space before opening parenthesis of function call prohibited
    Open

                            $pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getMessage());

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

    class Notification_Notifications_TextParser extends \App\TextParser\Base

    There are no issues that match your filters.

    Category
    Status