YetiForceCompany/YetiForceCRM

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

Summary

Maintainability
A
1 hr
Test Coverage
F
0%

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

    public function process(App\Request $request)
    {
        $moduleName = $request->getModule();
        $mailModuleActive = \App\Module::getModuleId('OSSMail');
        $mailScannerRecordModel = Vtiger_Record_Model::getCleanInstance('OSSMailScanner');
Severity: Minor
Found in modules/Settings/OSSMailScanner/views/Index.php - About 1 hr to fix

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

        public function process(App\Request $request)
        {
            $moduleName = $request->getModule();
            $mailModuleActive = \App\Module::getModuleId('OSSMail');
            $mailScannerRecordModel = Vtiger_Record_Model::getCleanInstance('OSSMailScanner');
    Severity: Minor
    Found in modules/Settings/OSSMailScanner/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 undefined variables such as '$numbering' which will lead to PHP notices.
    Open

            $viewer->assign('RECORDNUMBERING', $numbering ?? []);

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

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

    Avoid using undefined variables such as '$numbering' which will lead to PHP notices.
    Open

                    $numbering[$supportedModule->name] = \App\Fields\RecordNumber::getInstance($supportedModule->name);

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

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

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

            $emailSearchList = OSSMailScanner_Record_Model::getEmailSearchList();

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

            $actionsList = OSSMailScanner_Record_Model::getActionsList();

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

            $mailScannerRecordModel = Vtiger_Record_Model::getCleanInstance('OSSMailScanner');

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

            $ConfigFolderList = OSSMailScanner_Record_Model::getConfigFolderList();

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

                    $identityList[$account['user_id']] = OSSMailScanner_Record_Model::getIdentities($account['user_id']);

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

            $widgetCfg = OSSMailScanner_Record_Model::getConfig(false);

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

                    $numbering[$supportedModule->name] = \App\Fields\RecordNumber::getInstance($supportedModule->name);

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

            $emailSearch = OSSMailScanner_Record_Model::getEmailSearch(false, false);

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

            $checkCron = OSSMailScanner_Record_Model::getCron();

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

            $mailModuleActive = \App\Module::getModuleId('OSSMail');

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

                $accountsList = OSSMail_Record_Model::getAccountsList(false, false, false, false);

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

            $supportedModules = Settings_RecordNumbering_Module_Model::getSupportedModules();

    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('RECORDNUMBERING', $numbering ?? []);

    Call to method getConfigFolderList from undeclared class \OSSMailScanner_Record_Model
    Open

            $ConfigFolderList = OSSMailScanner_Record_Model::getConfigFolderList();

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('ACCOUNTS_LIST', $accountsList);

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('CONFIGFOLDERLIST', $ConfigFolderList);

    Call to undeclared method \Vtiger_Viewer::assign
    Open

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

    Call to method getConfig from undeclared class \OSSMailScanner_Record_Model
    Open

            $widgetCfg = OSSMailScanner_Record_Model::getConfig(false);

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('WIDGET_CFG', $widgetCfg);

    Call to method getIdentities from undeclared class \OSSMailScanner_Record_Model
    Open

                    $identityList[$account['user_id']] = OSSMailScanner_Record_Model::getIdentities($account['user_id']);

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('CHECKCRON', $checkCron);

    Call to method getInstance from undeclared class \App\Fields\RecordNumber (Did you mean class \Tests\Base\RecordNumber)
    Open

                    $numbering[$supportedModule->name] = \App\Fields\RecordNumber::getInstance($supportedModule->name);

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('ERRORNOMODULE', !$mailModuleActive);

    Call to method getActionsList from undeclared class \OSSMailScanner_Record_Model
    Open

            $actionsList = OSSMailScanner_Record_Model::getActionsList();

    Variable $numbering was undeclared, but array fields are being added to it.
    Open

                    $numbering[$supportedModule->name] = \App\Fields\RecordNumber::getInstance($supportedModule->name);

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('RECORD_MODEL', $mailScannerRecordModel);

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('ACTIONS_LIST', $actionsList);

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('IDENTITYLIST', $identityList);

    Call to method getEmailSearchList from undeclared class \OSSMailScanner_Record_Model
    Open

            $emailSearchList = OSSMailScanner_Record_Model::getEmailSearchList();

    Call to method getCron from undeclared class \OSSMailScanner_Record_Model
    Open

            $checkCron = OSSMailScanner_Record_Model::getCron();

    Call to method getEmailSearch from undeclared class \OSSMailScanner_Record_Model
    Open

            $emailSearch = OSSMailScanner_Record_Model::getEmailSearch(false, false);

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('EMAILSEARCHLIST', $emailSearchList);

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('EMAILSEARCH', $emailSearch);

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

            $mailScannerRecordModel = Vtiger_Record_Model::getCleanInstance('OSSMailScanner');

    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_OSSMailScanner_Index_View extends Settings_Vtiger_Index_View

    The class Settings_OSSMailScanner_Index_View is not named in CamelCase.
    Open

    class Settings_OSSMailScanner_Index_View extends Settings_Vtiger_Index_View
    {
        private $prefixesForModules = ['Project', 'HelpDesk', 'SSalesProcesses', 'Campaigns'];
    
        /** {@inheritdoc} */

    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

            if ($mailModuleActive) {

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

                $accountsList = OSSMail_Record_Model::getAccountsList(false, false, false, false);

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

            $viewer->assign('ACTIONS_LIST', $actionsList);

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

            $viewer->assign('WIDGET_CFG', $widgetCfg);

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

            $viewer->assign('CHECKCRON', $checkCron);

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

        private $prefixesForModules = ['Project', 'HelpDesk', 'SSalesProcesses', 'Campaigns'];

    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('ACCOUNTS_LIST', $accountsList);

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

            $emailSearch = OSSMailScanner_Record_Model::getEmailSearch(false, false);

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

            $identityList = [];

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

            foreach ($supportedModules as $supportedModule) {

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

            $viewer->assign('EMAILSEARCH', $emailSearch);

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

                foreach ($accountsList as $account) {

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

            }

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

            $checkCron = OSSMailScanner_Record_Model::getCron();

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

            $actionsList = OSSMailScanner_Record_Model::getActionsList();

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

            $widgetCfg = OSSMailScanner_Record_Model::getConfig(false);

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

            $viewer->assign('EMAILSEARCHLIST', $emailSearchList);

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

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

    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 array_merge(parent::getFooterScripts($request), $this->checkAndConvertJsScripts([

    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 function process(App\Request $request)

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

            $emailSearchList = OSSMailScanner_Record_Model::getEmailSearchList();

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

                    $identityList[$account['user_id']] = OSSMailScanner_Record_Model::getIdentities($account['user_id']);

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

                if (\in_array($supportedModule->name, $this->prefixesForModules)) {

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

                '~layouts/resources/libraries/jstree.checkbox.js',

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

            $supportedModules = Settings_RecordNumbering_Module_Model::getSupportedModules();

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

            $viewer->assign('RECORD_MODEL', $mailScannerRecordModel);

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

            $viewer->assign('RECORDNUMBERING', $numbering ?? []);

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

            $viewer->assign('ERRORNOMODULE', !$mailModuleActive);

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

            $viewer->assign('IDENTITYLIST', $identityList);

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

            $mailModuleActive = \App\Module::getModuleId('OSSMail');

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

            $ConfigFolderList = OSSMailScanner_Record_Model::getConfigFolderList();

    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

        {

    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

                }

    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('MODULE_NAME', $moduleName);

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

        public function getFooterScripts(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

            $mailScannerRecordModel = Vtiger_Record_Model::getCleanInstance('OSSMailScanner');

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

                    $numbering[$supportedModule->name] = \App\Fields\RecordNumber::getInstance($supportedModule->name);

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

            $viewer->assign('CONFIGFOLDERLIST', $ConfigFolderList);

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

    class Settings_OSSMailScanner_Index_View extends Settings_Vtiger_Index_View

    The variable $ConfigFolderList is not named in camelCase.
    Open

        public function process(App\Request $request)
        {
            $moduleName = $request->getModule();
            $mailModuleActive = \App\Module::getModuleId('OSSMail');
            $mailScannerRecordModel = Vtiger_Record_Model::getCleanInstance('OSSMailScanner');

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $ConfigFolderList is not named in camelCase.
    Open

        public function process(App\Request $request)
        {
            $moduleName = $request->getModule();
            $mailModuleActive = \App\Module::getModuleId('OSSMail');
            $mailScannerRecordModel = Vtiger_Record_Model::getCleanInstance('OSSMailScanner');

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    There are no issues that match your filters.

    Category
    Status