YetiForceCompany/YetiForceCRM

View on GitHub
modules/Settings/Updates/views/Index.php

Summary

Maintainability
A
25 mins
Test Coverage
F
0%

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

    public function process(App\Request $request)
    {
        $viewer = $this->getViewer($request);
        $qualifiedModuleName = $request->getModule(false);
        $toInstall = \App\YetiForce\Updater::getToInstall();
Severity: Minor
Found in modules/Settings/Updates/views/Index.php - About 25 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 'Settings_Updates_Module_Model' in method 'process'.
Open

        $viewer->assign('INSTALLED', Settings_Updates_Module_Model::getUpdates());

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

        $toInstall = \App\YetiForce\Updater::getToInstall();

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

                    \App\YetiForce\Updater::download($package);

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('TO_INSTALL', $toInstall);
Severity: Critical
Found in modules/Settings/Updates/views/Index.php by phan

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('INSTALLED', Settings_Updates_Module_Model::getUpdates());
Severity: Critical
Found in modules/Settings/Updates/views/Index.php by phan

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

class Settings_Updates_Index_View extends Settings_Vtiger_Index_View

The class Settings_Updates_Index_View is not named in CamelCase.
Open

class Settings_Updates_Index_View extends Settings_Vtiger_Index_View
{
    public function process(App\Request $request)
    {
        $viewer = $this->getViewer($request);

CamelCaseClassName

Since: 0.2

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

Example

class class_name {
}

Source

Expected 1 space after "as"; 2 found
Open

            foreach ($toInstall as  $package) {

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->view('Index.tpl', $qualifiedModuleName);

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

    {

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

        $qualifiedModuleName = $request->getModule(false);

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

            foreach ($toInstall as  $package) {

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('TO_INSTALL', $toInstall);

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

            }

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

            $download = $request->getByType('download', 'Alnum');

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

        $toInstall = \App\YetiForce\Updater::getToInstall();

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

                if ($package['hash'] === $download) {

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

                    \App\YetiForce\Updater::download($package);

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

        $viewer->assign('INSTALLED', Settings_Updates_Module_Model::getUpdates());

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

        if (!$request->isEmpty('download')) {

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

    public function process(App\Request $request)

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

class Settings_Updates_Index_View extends Settings_Vtiger_Index_View

There are no issues that match your filters.

Category
Status