YetiForceCompany/YetiForceCRM

View on GitHub
modules/Settings/WidgetsManagement/views/Configuration.php

Summary

Maintainability
A
1 hr
Test Coverage
F
0%

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

    public function process(App\Request $request)
    {
        \App\Log::trace(__METHOD__ . ' | Start');
        $sourceModule = $request->getByType('sourceModule', 2);
        $widgetsManagementModel = new Settings_WidgetsManagement_Module_Model();
Severity: Minor
Found in modules/Settings/WidgetsManagement/views/Configuration.php - About 1 hr to fix

    Missing class import via use statement (line '22', column '33').
    Open

            $widgetsManagementModel = new Settings_WidgetsManagement_Module_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

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

            $currentDashboard = $request->isEmpty('dashboardId', true) ? Settings_WidgetsManagement_Module_Model::getDefaultDashboard() : $request->getInteger('dashboardId');

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

            \App\Log::trace(__METHOD__ . ' | Start');

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

            $specialWidgets = Settings_WidgetsManagement_Module_Model::getSpecialWidgets($sourceModule);

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

            $viewer->assign('DATE_SELECT_DEFAULT', Settings_WidgetsManagement_Module_Model::getDateSelectDefault());

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

            \App\Log::trace(__METHOD__ . ' | End');

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

            $viewer->assign('DASHBOARD_TYPES', Settings_WidgetsManagement_Module_Model::getDashboardTypes());

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

            $viewer->assign('ALL_SERVERS', Settings_WebserviceApps_Module_Model::getServers());

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

            $authorization = Settings_Roles_Record_Model::getAll();

    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('DEFAULTVALUES', $defaultValues);

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('FILTER_SELECT', $filterSelect);

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('SIZE', $size);

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('QUALIFIED_MODULE', $request->getModule(false));

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

            \App\Log::trace(__METHOD__ . ' | Start');

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('ALL_SERVERS', Settings_WebserviceApps_Module_Model::getServers());

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('SPECIAL_WIDGETS', $specialWidgets);

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('WIDGETS', $widgets);

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('DASHBOARD_TYPES', Settings_WidgetsManagement_Module_Model::getDashboardTypes());

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('FILTER_SELECT_DEFAULT', $filterSelectDefault);

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('DATE_SELECT_DEFAULT', Settings_WidgetsManagement_Module_Model::getDateSelectDefault());

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('CURRENT_DASHBOARD', $currentDashboard);

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('SELECTED_MODULE_NAME', $sourceModule);

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('ALL_AUTHORIZATION', $authorization);

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('WIDGETS_AUTHORIZATION_INFO', $dashboardStored);

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

            \App\Log::trace(__METHOD__ . ' | End');

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('SUPPORTED_MODULES', array_keys($dashboardModules));

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('DASHBOARD_AUTHORIZATION_BLOCKS', $blocks[$sourceModule] ?? []);

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('TITLE_OF_LIMIT', $widgetsWithLimit);

    Avoid excessively long class names like Settings_WidgetsManagement_Configuration_View. Keep class name length under 40.
    Open

    class Settings_WidgetsManagement_Configuration_View extends Settings_Vtiger_Index_View
    {
        /**
         * Process.
         *

    LongClassName

    Since: 2.9

    Detects when classes or interfaces are declared with excessively long names.

    Example

    class ATooLongClassNameThatHintsAtADesignProblem {
    
    }
    
    interface ATooLongInterfaceNameThatHintsAtADesignProblem {
    
    }

    Source https://phpmd.org/rules/naming.html#longclassname

    Avoid excessively long variable names like $widgetsManagementModel. Keep variable name length under 20.
    Open

            $widgetsManagementModel = new Settings_WidgetsManagement_Module_Model();

    LongVariable

    Since: 0.2

    Detects when a field, formal or local variable is declared with a long name.

    Example

    class Something {
        protected $reallyLongIntName = -3; // VIOLATION - Field
        public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
            $otherReallyLongName = -5; // VIOLATION - Local
            for ($interestingIntIndex = 0; // VIOLATION - For
                 $interestingIntIndex < 10;
                 $interestingIntIndex++ ) {
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#longvariable

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

    class Settings_WidgetsManagement_Configuration_View extends Settings_Vtiger_Index_View

    The class Settings_WidgetsManagement_Configuration_View is not named in CamelCase.
    Open

    class Settings_WidgetsManagement_Configuration_View extends Settings_Vtiger_Index_View
    {
        /**
         * Process.
         *

    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

            $widgets = $dashboardModules[$sourceModule];

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

            $filterSelect = $widgetsManagementModel->getFilterSelect();

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

            $viewer->assign('FILTER_SELECT', $filterSelect);

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

            $viewer->assign('SUPPORTED_MODULES', array_keys($dashboardModules));

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

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

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

            $widgetsManagementModel = new Settings_WidgetsManagement_Module_Model();

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

            $viewer->assign('FILTER_SELECT_DEFAULT', $filterSelectDefault);

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

            $viewer->assign('SPECIAL_WIDGETS', $specialWidgets);

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

            $currentDashboard = $request->isEmpty('dashboardId', true) ? Settings_WidgetsManagement_Module_Model::getDefaultDashboard() : $request->getInteger('dashboardId');

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

            echo $viewer->view('Configuration.tpl', $request->getModule(false), true);

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

            $specialWidgets = Settings_WidgetsManagement_Module_Model::getSpecialWidgets($sourceModule);

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

            $viewer->assign('WIDGETS_AUTHORIZATION_INFO', $dashboardStored);

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

         */

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

            $dashboardModules = $widgetsManagementModel->getSelectableDashboard();

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

            if (empty($sourceModule)) {

    Line exceeds 120 characters; contains 170 characters
    Open

            $currentDashboard = $request->isEmpty('dashboardId', true) ? Settings_WidgetsManagement_Module_Model::getDefaultDashboard() : $request->getInteger('dashboardId');

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

            $viewer->assign('DASHBOARD_TYPES', Settings_WidgetsManagement_Module_Model::getDashboardTypes());

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

                $sourceModule = 'Home';

    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

            $filterSelectDefault = $widgetsManagementModel->getFilterSelectDefault();

    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

            $size = $widgetsManagementModel->getSize();

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

            $viewer->assign('ALL_SERVERS', Settings_WebserviceApps_Module_Model::getServers());

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

            $viewer->assign('DASHBOARD_AUTHORIZATION_BLOCKS', $blocks[$sourceModule] ?? []);

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

        }

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

            $defaultValues = $widgetsManagementModel->getDefaultValues();

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

            $viewer->assign('CURRENT_DASHBOARD', $currentDashboard);

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

         * @param \App\Request $request

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

            \App\Log::trace(__METHOD__ . ' | Start');

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

            // get widgets list

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

            $viewer->assign('SIZE', $size);

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

            $viewer->assign('WIDGETS', $widgets);

    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

            $widgetsWithLimit = $widgetsManagementModel->getWidgetsWithLimit();

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

            $viewer->assign('DATE_SELECT_DEFAULT', Settings_WidgetsManagement_Module_Model::getDateSelectDefault());

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

        /**

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

            $authorization = Settings_Roles_Record_Model::getAll();

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

            $viewer->assign('ALL_AUTHORIZATION', $authorization);

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

            $viewer->assign('SELECTED_MODULE_NAME', $sourceModule);

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

            $viewer->assign('DEFAULTVALUES', $defaultValues);

    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

            $dashboardStored = $widgetsManagementModel->getDashboardForModule($sourceModule);

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

            $blocks = $widgetsManagementModel->getBlocksId($currentDashboard);

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

            $viewer->assign('QUALIFIED_MODULE', $request->getModule(false));

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

            $viewer->assign('TITLE_OF_LIMIT', $widgetsWithLimit);

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

            \App\Log::trace(__METHOD__ . ' | End');

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

    class Settings_WidgetsManagement_Configuration_View extends Settings_Vtiger_Index_View

    There are no issues that match your filters.

    Category
    Status