YetiForceCompany/YetiForceCRM

View on GitHub
modules/Vtiger/dashboards/Rss.php

Summary

Maintainability
A
3 hrs
Test Coverage
F
0%

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

    public function process(App\Request $request, $widget = null)
    {
        $currentUser = Users_Record_Model::getCurrentUserModel();
        $viewer = $this->getViewer($request);
        $moduleName = $request->getModule();
Severity: Minor
Found in modules/Vtiger/dashboards/Rss.php - About 2 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 process has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function process(App\Request $request, $widget = null)
    {
        $currentUser = Users_Record_Model::getCurrentUserModel();
        $viewer = $this->getViewer($request);
        $moduleName = $request->getModule();
Severity: Minor
Found in modules/Vtiger/dashboards/Rss.php - About 1 hr to fix

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

        public function process(App\Request $request, $widget = null)
    Severity: Critical
    Found in modules/Vtiger/dashboards/Rss.php by sonar-php

    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

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

                $feed = Rss_Record_Model::getRssClient($rss);
    Severity: Minor
    Found in modules/Vtiger/dashboards/Rss.php by phpmd

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

            $data = \App\Json::decode(App\Purifier::decodeHtml($data));
    Severity: Minor
    Found in modules/Vtiger/dashboards/Rss.php by phpmd

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

                        $title = App\Purifier::decodeHtml(\App\Purifier::purify(App\Purifier::decodeHtml($announcement->get_title())));
    Severity: Minor
    Found in modules/Vtiger/dashboards/Rss.php by phpmd

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

            $widget = Vtiger_Widget_Model::getInstanceWithWidgetId($widgetId, $currentUser->getId());
    Severity: Minor
    Found in modules/Vtiger/dashboards/Rss.php by phpmd

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

            } else {
                $widgetId = $request->getInteger('widgetid');
            }
    Severity: Minor
    Found in modules/Vtiger/dashboards/Rss.php by phpmd

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

                        $title = App\Purifier::decodeHtml(\App\Purifier::purify(App\Purifier::decodeHtml($announcement->get_title())));
    Severity: Minor
    Found in modules/Vtiger/dashboards/Rss.php by phpmd

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

                            'title' => \App\TextUtils::textTruncate($title, 50),
    Severity: Minor
    Found in modules/Vtiger/dashboards/Rss.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

    Source https://phpmd.org/rules/cleancode.html#staticaccess

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

            $currentUser = Users_Record_Model::getCurrentUserModel();
    Severity: Minor
    Found in modules/Vtiger/dashboards/Rss.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

    Source https://phpmd.org/rules/cleancode.html#staticaccess

    Avoid assigning values to variables in if clauses and the like (line '46', column '14').
    Open

        public function process(App\Request $request, $widget = null)
        {
            $currentUser = Users_Record_Model::getCurrentUserModel();
            $viewer = $this->getViewer($request);
            $moduleName = $request->getModule();
    Severity: Minor
    Found in modules/Vtiger/dashboards/Rss.php by phpmd

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

            $data = \App\Json::decode(App\Purifier::decodeHtml($data));
    Severity: Minor
    Found in modules/Vtiger/dashboards/Rss.php by phpmd

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

                        if (!\App\Validator::url((string) $announcement->get_link())) {
    Severity: Minor
    Found in modules/Vtiger/dashboards/Rss.php by phpmd

    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

                            'date' => \App\Fields\DateTime::formatToViewDate($announcement->get_date('Y-m-d H:i:s')),
    Severity: Minor
    Found in modules/Vtiger/dashboards/Rss.php by phpmd

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

                        $title = App\Purifier::decodeHtml(\App\Purifier::purify(App\Purifier::decodeHtml($announcement->get_title())));
    Severity: Minor
    Found in modules/Vtiger/dashboards/Rss.php by phpmd

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

                            'link' => App\Purifier::decodeHtml($announcement->get_link()),
    Severity: Minor
    Found in modules/Vtiger/dashboards/Rss.php by phpmd

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

            } else {
                $viewer->view('dashboards/RssHeader.tpl', $moduleName);
            }
    Severity: Minor
    Found in modules/Vtiger/dashboards/Rss.php by phpmd

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

                    \App\Log::warning($error, 'RSS');
    Severity: Minor
    Found in modules/Vtiger/dashboards/Rss.php by phpmd

    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 method getInstanceWithWidgetId from undeclared class \Vtiger_Widget_Model
    Open

            $widget = Vtiger_Widget_Model::getInstanceWithWidgetId($widgetId, $currentUser->getId());
    Severity: Critical
    Found in modules/Vtiger/dashboards/Rss.php by phan

    Call to method error from undeclared class \SimplePie
    Open

                } elseif ($error = $feed->error()) {
    Severity: Critical
    Found in modules/Vtiger/dashboards/Rss.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('WIDGET', $widget);
    Severity: Critical
    Found in modules/Vtiger/dashboards/Rss.php by phan

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

                    \App\Log::warning($error, 'RSS');
    Severity: Critical
    Found in modules/Vtiger/dashboards/Rss.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('LIST_SUBJECTS', $items);
    Severity: Critical
    Found in modules/Vtiger/dashboards/Rss.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('ERRORS', $errors);
    Severity: Critical
    Found in modules/Vtiger/dashboards/Rss.php by phan

    Call to method init from undeclared class \SimplePie
    Open

                if ($feed->init()) {
    Severity: Critical
    Found in modules/Vtiger/dashboards/Rss.php by phan

    Call to method url from undeclared class \App\Validator (Did you mean class \Tests\App\Validator)
    Open

                        if (!\App\Validator::url((string) $announcement->get_link())) {
    Severity: Critical
    Found in modules/Vtiger/dashboards/Rss.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('MODULE_NAME', $moduleName);
    Severity: Critical
    Found in modules/Vtiger/dashboards/Rss.php by phan

    Call to method get_items from undeclared class \SimplePie
    Open

                    foreach ($feed->get_items(0, 10) as $announcement) {
    Severity: Critical
    Found in modules/Vtiger/dashboards/Rss.php by phan

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

    class Vtiger_Rss_Dashboard extends Vtiger_IndexAjax_View

    The class Vtiger_Rss_Dashboard is not named in CamelCase.
    Open

    class Vtiger_Rss_Dashboard extends Vtiger_IndexAjax_View
    {
        public function process(App\Request $request, $widget = null)
        {
            $currentUser = Users_Record_Model::getCurrentUserModel();
    Severity: Minor
    Found in modules/Vtiger/dashboards/Rss.php by phpmd

    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

            foreach ($data['channels'] as $rss) {

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

                            continue;

    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

            $data = \App\Json::decode(App\Purifier::decodeHtml($data));

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

                $feed = Rss_Record_Model::getRssClient($rss);

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

                    \App\Log::warning($error, 'RSS');

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

                $viewer->view('dashboards/RssContents.tpl', $moduleName);

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

        }

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

            $currentUser = Users_Record_Model::getCurrentUserModel();

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

                            'title' => \App\TextUtils::textTruncate($title, 50),

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

            if ($request->has('content')) {

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

            $widget = Vtiger_Widget_Model::getInstanceWithWidgetId($widgetId, $currentUser->getId());

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

            $errors = $items = [];

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

                        $title = App\Purifier::decodeHtml(\App\Purifier::purify(App\Purifier::decodeHtml($announcement->get_title())));

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

            $viewer->assign('WIDGET', $widget);

    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

            } else {

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

                } elseif ($error = $feed->error()) {

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

                $viewer->view('dashboards/RssHeader.tpl', $moduleName);

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

                        if (!\App\Validator::url((string) $announcement->get_link())) {

    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

            $viewer->assign('LIST_SUBJECTS', $items);

    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 = $request->getModule();

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

                            'date' => \App\Fields\DateTime::formatToViewDate($announcement->get_date('Y-m-d H:i:s')),

    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 = $this->getViewer($request);

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

            $viewer->assign('MODULE_NAME', $moduleName);

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

            }

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

            }

    Line exceeds 120 characters; contains 131 characters
    Open

                        $title = App\Purifier::decodeHtml(\App\Purifier::purify(App\Purifier::decodeHtml($announcement->get_title())));

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

                            'link' => App\Purifier::decodeHtml($announcement->get_link()),

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

            $viewer->assign('ERRORS', $errors);

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

        public function process(App\Request $request, $widget = null)

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

                $widgetId = $widget->get('id');

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

            $data = $widget->get('data');

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

                            'fullTitle' => $title,

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

                if ($feed->init()) {

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

                    foreach ($feed->get_items(0, 10) as $announcement) {

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

                        $items[] = [

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

                    $errors[$rss] = $error;

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

            if ($widget && !$request->has('widgetid')) {

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

                $widgetId = $request->getInteger('widgetid');

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

                            'source' => $rss,

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

    class Vtiger_Rss_Dashboard extends Vtiger_IndexAjax_View

    There are no issues that match your filters.

    Category
    Status