YetiForceCompany/YetiForceCRM

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

Summary

Maintainability
A
2 hrs
Test Coverage
F
0%

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

    public function process(App\Request $request)
    {
        $viewer = $this->getViewer($request);
        $moduleName = $request->getModule();

Severity: Minor
Found in modules/Vtiger/views/MiniListWizard.php - About 1 hr to fix

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

        public function process(App\Request $request)
        {
            $viewer = $this->getViewer($request);
            $moduleName = $request->getModule();
    
    
    Severity: Minor
    Found in modules/Vtiger/views/MiniListWizard.php - About 35 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

    Missing class import via use statement (line '62', column '27').
    Open

                    $queryGenerator = new \App\QueryGenerator($selectedModule);

    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 '60', column '16').
    Open

                        throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 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 '51', column '16').
    Open

                        throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 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 '27', column '29').
    Open

                $this->widgetModel = new Vtiger_MiniListModel_Dashboard();

    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 using static access to class '\Vtiger_Widget_Model' in method 'checkPermission'.
    Open

                $this->widgetModel = \Vtiger_Widget_Model::getInstanceFromValues($linkData);

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

            } else {
                $this->widgetModel = new Vtiger_MiniListModel_Dashboard();
            }

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

                    if (!\App\Privilege::isPermitted($selectedModule)) {

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

                    if (!\App\Privilege::isPermitted($selectedModule)) {

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

                $this->widgetModel = \Vtiger_Widget_Model::getInstanceWithTemplateId($request->getInteger('templateId'));

    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 '\vtlib\Link' in method 'checkPermission'.
    Open

                $linkData = \vtlib\Link::getLinkData($request->getInteger('linkId'));

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

                    $filters = CustomView_Record_Model::getAllByGroup($selectedModule);

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

                    $modules = vtlib\Functions::getAllModules(true, false, 0);

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

            $viewer->assign('WIDGET_ID', $this->widgetModel->getId());
    Severity: Critical
    Found in modules/Vtiger/views/MiniListWizard.php by phan

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

                    $viewer->assign('FIELDS_BY_BLOCK', $queryGenerator->getModuleModel()->getFieldsByBlocks());
    Severity: Critical
    Found in modules/Vtiger/views/MiniListWizard.php by phan

    Call to method getInstanceWithTemplateId from undeclared class \Vtiger_Widget_Model
    Open

                $this->widgetModel = \Vtiger_Widget_Model::getInstanceWithTemplateId($request->getInteger('templateId'));
    Severity: Critical
    Found in modules/Vtiger/views/MiniListWizard.php by phan

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

                    $queryGenerator = new \App\QueryGenerator($selectedModule);
    Severity: Critical
    Found in modules/Vtiger/views/MiniListWizard.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

                    $viewer->assign('SELECTED_MODULE', $selectedModule);
    Severity: Critical
    Found in modules/Vtiger/views/MiniListWizard.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

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

    Call to method getInstanceFromValues from undeclared class \Vtiger_Widget_Model
    Open

                $this->widgetModel = \Vtiger_Widget_Model::getInstanceFromValues($linkData);
    Severity: Critical
    Found in modules/Vtiger/views/MiniListWizard.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('WIZARD_STEP', $request->getByType('step', 2));
    Severity: Critical
    Found in modules/Vtiger/views/MiniListWizard.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('WIDGET_ID', $this->widgetModel->getId());
    Severity: Critical
    Found in modules/Vtiger/views/MiniListWizard.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

                    $viewer->assign('ALLFILTERS', $filters);
    Severity: Critical
    Found in modules/Vtiger/views/MiniListWizard.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

                    $viewer->assign('FIELDS_BY_BLOCK', $queryGenerator->getModuleModel()->getFieldsByBlocks());
    Severity: Critical
    Found in modules/Vtiger/views/MiniListWizard.php by phan

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

                    $viewer->assign('LIST_VIEW_FIELDS', $queryGenerator->getListViewFields());
    Severity: Critical
    Found in modules/Vtiger/views/MiniListWizard.php by phan

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

            if (!$request->isEmpty('templateId', true) && \App\User::getCurrentUserModel()->isAdmin()) {
    Severity: Critical
    Found in modules/Vtiger/views/MiniListWizard.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

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

    Property \Vtiger_MiniListWizard_View->widgetModel has undeclared type \Vtiger_Widget_Model
    Open

        public $widgetModel;

    Call to undeclared method \Vtiger_Viewer::assign
    Open

                    $viewer->assign('QUERY_GENERATOR', $queryGenerator);
    Severity: Critical
    Found in modules/Vtiger/views/MiniListWizard.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('WIDGET_MODEL', $this->widgetModel);
    Severity: Critical
    Found in modules/Vtiger/views/MiniListWizard.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

                    $viewer->assign('SELECTED_MODULE', $selectedModule);
    Severity: Critical
    Found in modules/Vtiger/views/MiniListWizard.php by phan

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

                    $queryGenerator->initForCustomViewById($request->getInteger('filterid'));
    Severity: Critical
    Found in modules/Vtiger/views/MiniListWizard.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

                    $viewer->assign('LIST_VIEW_FIELDS', $queryGenerator->getListViewFields());
    Severity: Critical
    Found in modules/Vtiger/views/MiniListWizard.php by phan

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

    class Vtiger_MiniListWizard_View extends Vtiger_Index_View

    The class Vtiger_MiniListWizard_View is not named in CamelCase.
    Open

    class Vtiger_MiniListWizard_View extends Vtiger_Index_View
    {
        /** @var \Vtiger_Widget_Model Widget Model */
        public $widgetModel;
    
    

    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

            switch ($request->getByType('step', 2)) {

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

                    $viewer->assign('SELECTED_MODULE', $selectedModule);

    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

                $this->widgetModel = \Vtiger_Widget_Model::getInstanceWithTemplateId($request->getInteger('templateId'));

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

            $viewer->assign('WIDGET_MODEL', $this->widgetModel);

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

                case 'step3':

    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

                    if (!\App\Privilege::isPermitted($selectedModule)) {

    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('WIDGET_ID', $this->widgetModel->getId());

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

                    $modules = vtlib\Functions::getAllModules(true, false, 0);

    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('ALLFILTERS', $filters);

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

                    $selectedModule = $request->getByType('selectedModule', 2);

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

            parent::checkPermission($request);

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

                    if (!\App\Privilege::isPermitted($selectedModule)) {

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

                        throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);

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

            if (!$request->isEmpty('templateId', true) && \App\User::getCurrentUserModel()->isAdmin()) {

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

                $linkData = \vtlib\Link::getLinkData($request->getInteger('linkId'));

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

                    //Since comments is not treated as seperate module

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

                    $queryGenerator = new \App\QueryGenerator($selectedModule);

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

                $this->widgetModel = new Vtiger_MiniListModel_Dashboard();

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

                    $viewer->assign('MODULES', $modules);

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

                    $viewer->assign('FIELDS_BY_BLOCK', $queryGenerator->getModuleModel()->getFieldsByBlocks());

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

        /** @var \Vtiger_Widget_Model Widget Model */

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

                $this->widgetModel = \Vtiger_Widget_Model::getInstanceFromValues($linkData);

    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

                    $viewer->assign('LIST_VIEW_FIELDS', $queryGenerator->getListViewFields());

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

        public $widgetModel;

    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

            $moduleName = $request->getModule();

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

            $viewer->assign('WIZARD_STEP', $request->getByType('step', 2));

    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

            } else {

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

                    unset($modules['ModComments']);

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

                case 'step2':

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

                    $selectedModule = $request->getByType('selectedModule', 2);

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

                    $queryGenerator->initForCustomViewById($request->getInteger('filterid'));

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

                    $viewer->assign('QUERY_GENERATOR', $queryGenerator);

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

        {

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

                case 'step1':

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

                default:

    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

                        throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);

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

                    $filters = CustomView_Record_Model::getAllByGroup($selectedModule);

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

            $viewer->view('dashboards/MiniListWizard.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

            } elseif (!$request->isEmpty('linkId')) {

    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

                    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

                    $viewer->assign('SELECTED_MODULE', $selectedModule);

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

                    break;

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

    class Vtiger_MiniListWizard_View extends Vtiger_Index_View

    There are no issues that match your filters.

    Category
    Status