YetiForceCompany/YetiForceCRM

View on GitHub
modules/Settings/MailIntegration/models/ConfigForm.php

Summary

Maintainability
A
1 hr
Test Coverage
F
0%

Method getFields has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function getFields(string $moduleName): array
    {
        $config = App\Config::module('MailIntegration', null, []);
        $outlookUrls = $config['outlookUrls'] ?? [];
        $fields = [
Severity: Minor
Found in modules/Settings/MailIntegration/models/ConfigForm.php - About 1 hr to fix

    Avoid using static access to class 'App\Config' in method 'getFields'.
    Open

            $config = App\Config::module('MailIntegration', null, []);

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

                    'picklistValues' => \App\Module::getAllModuleNamesFilter(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

    Avoid using static access to class '\Vtiger_Field_Model' in method 'getFields'.
    Open

                $fields[$key] = \Vtiger_Field_Model::init($moduleName, $value, $key);

    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 excessively long class names like Settings_MailIntegration_ConfigForm_Model. Keep class name length under 40.
    Open

    class Settings_MailIntegration_ConfigForm_Model
    {
        /**
         * Get fields for config form.
         *

    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

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

    class Settings_MailIntegration_ConfigForm_Model

    The class Settings_MailIntegration_ConfigForm_Model is not named in CamelCase.
    Open

    class Settings_MailIntegration_ConfigForm_Model
    {
        /**
         * Get fields for config form.
         *

    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

            $config = App\Config::module('MailIntegration', null, []);

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

         * @param string $moduleName

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

                    'isArray' => true,

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

                    'fieldvalue' => $config['modulesListQuickCreate'] ?? ''

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

                    'labelDescArgs' => 'https://outlook.live.com, https://outlook.office365.com, https://outlook.office.com',

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

                ],

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

                    'purifyType' => 'Alnum',

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

            foreach ($fields as $key => $value) {

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

        public static function getFields(string $moduleName): array

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

                ],

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

         * Get fields for config form.

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

                    'labelDesc' => 'LBL_QUICK_CREATE_MODULES_DESC',

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

                    'picklistValues' => \App\Module::getAllModuleNamesFilter(true, false, 0),

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

                    'fieldvalue' => $outlookUrls,

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

                $fields[$key] = \Vtiger_Field_Model::init($moduleName, $value, $key);

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

         * @return Vtiger_Field_Model[]

    Line exceeds 120 characters; contains 121 characters
    Open

                    'labelDescArgs' => 'https://outlook.live.com, https://outlook.office365.com, https://outlook.office.com',

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

            }

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

                'modulesListQuickCreate' => [

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

                'outlookUrls' => [

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

                    'label' => 'LBL_OUTLOOK_ADDRESSES',

    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

                    'isArray' => true,

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

                    'uitype' => 33,

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

            $outlookUrls = $config['outlookUrls'] ?? [];

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

                    'uitype' => 33,

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

                    'labelDesc' => 'LBL_OUTLOOK_ADDRESSES_DESC',

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

            $fields = [

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

            return $fields;

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

         *

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

                    'purifyType' => 'url',

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

                    'dataSelect' => 'tags',

    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

                    'label' => 'LBL_QUICK_CREATE_MODULES',

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

                    'picklistValues' => array_combine($outlookUrls, $outlookUrls),

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

    class Settings_MailIntegration_ConfigForm_Model

    There are no issues that match your filters.

    Category
    Status