YetiForceCompany/YetiForceCRM

View on GitHub
modules/Settings/MailRbl/models/ConfigModal.php

Summary

Maintainability
A
1 hr
Test Coverage
F
0%

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

    public static function getFields(): array
    {
        $config = \App\Config::component('Mail', null, []);
        $fields = [
            'rcListCheckRbl' => [
Severity: Minor
Found in modules/Settings/MailRbl/models/ConfigModal.php - About 1 hr to fix

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

            $config = \App\Config::component('Mail', 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 '\Vtiger_Field_Model' in method 'getFields'.
    Open

                $fields[$key] = \Vtiger_Field_Model::init('OSSMail', $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

    Define a constant instead of duplicating this literal "fieldvalue" 4 times.
    Open

                    'fieldvalue' => $config['rcListCheckRbl'] ?? false,

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "uitype" 4 times.
    Open

                    'uitype' => 56,

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "purifyType" 4 times.
    Open

                    'purifyType' => 'bool',

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "labelDesc" 4 times.
    Open

                    'labelDesc' => 'LBL_ACTIVATE_RBL_LIST_DESC',

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "label" 4 times.
    Open

                    'label' => 'LBL_ACTIVATE_RBL_LIST',

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

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

    class Settings_MailRbl_ConfigModal_Model

    The class Settings_MailRbl_ConfigModal_Model is not named in CamelCase.
    Open

    class Settings_MailRbl_ConfigModal_Model
    {
        /**
         * Function determines fields available in modal view.
         *

    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 for alignment; tabs are not allowed
    Open

                    'labelDesc' => 'LBL_ACTIVATE_RBL_LIST_DESC',

    Spaces must be used for alignment; tabs are not allowed
    Open

                    'label' => 'LBL_ACCEPT_AUTOMATICALLY',

    Spaces must be used for alignment; tabs are not allowed
    Open

            $config = \App\Config::component('Mail', null, []);

    Spaces must be used for alignment; tabs are not allowed
    Open

                    'labelDesc' => 'LBL_ACTIVATE_RBL_DETAIL_DESC',

    Spaces must be used for alignment; tabs are not allowed
    Open

                ],

    Spaces must be used for alignment; tabs are not allowed
    Open

                    'labelDesc' => 'LBL_SEND_REPORT_AUTOMATICALLY_DESC',

    Spaces must be used for alignment; tabs are not allowed
    Open

     * @author      Mariusz Krzaczkowski <m.krzaczkowski@yetiforce.com>

    Spaces must be used for alignment; tabs are not allowed
    Open

                ],

    Spaces must be used for alignment; tabs are not allowed
    Open

                    'label' => 'LBL_ACTIVATE_RBL_DETAIL',

    Spaces must be used for alignment; tabs are not allowed
    Open

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

    Spaces must be used for alignment; tabs are not allowed
    Open

                'rcDetailCheckRbl' => [

    Spaces must be used for alignment; tabs are not allowed
    Open

                    'purifyType' => 'bool',

    Spaces must be used for alignment; tabs are not allowed
    Open

            $fields = [

    Spaces must be used for alignment; tabs are not allowed
    Open

                    'uitype' => 56,

    Spaces must be used for alignment; tabs are not allowed
    Open

         *

    Spaces must be used for alignment; tabs are not allowed
    Open

         */

    Spaces must be used for alignment; tabs are not allowed
    Open

                ],

    Spaces must be used for alignment; tabs are not allowed
    Open

        /**

    Spaces must be used for alignment; tabs are not allowed
    Open

         * @return Vtiger_Field_Model[]

    Spaces must be used for alignment; tabs are not allowed
    Open

        public static function getFields(): array

    Spaces must be used for alignment; tabs are not allowed
    Open

                    'uitype' => 56,

    Spaces must be used for alignment; tabs are not allowed
    Open

            }

    Spaces must be used for alignment; tabs are not allowed
    Open

                    'purifyType' => 'bool',

    Spaces must be used for alignment; tabs are not allowed
    Open

                    'fieldvalue' => $config['rcDetailCheckRbl'] ?? false,

    Spaces must be used for alignment; tabs are not allowed
    Open

                    'labelDesc' => 'LBL_ACCEPT_AUTOMATICALLY_DESC',

    Spaces must be used for alignment; tabs are not allowed
    Open

                    'purifyType' => 'bool',

    Spaces must be used for alignment; tabs are not allowed
    Open

                'rcListAcceptAutomatically' => [

    Spaces must be used for alignment; tabs are not allowed
    Open

                    'fieldvalue' => $config['rcListAcceptAutomatically'] ?? false,

    Spaces must be used for alignment; tabs are not allowed
    Open

                'rcListSendReportAutomatically' => [

    Spaces must be used for alignment; tabs are not allowed
    Open

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

    Spaces must be used for alignment; tabs are not allowed
    Open

        }

    Spaces must be used for alignment; tabs are not allowed
    Open

         * Function determines fields available in modal view.

    Spaces must be used for alignment; tabs are not allowed
    Open

                'rcListCheckRbl' => [

    Spaces must be used for alignment; tabs are not allowed
    Open

                    'purifyType' => 'bool',

    Spaces must be used for alignment; tabs are not allowed
    Open

                    'uitype' => 56,

    Spaces must be used for alignment; tabs are not allowed
    Open

        {

    Spaces must be used for alignment; tabs are not allowed
    Open

                    'label' => 'LBL_ACTIVATE_RBL_LIST',

    Spaces must be used for alignment; tabs are not allowed
    Open

                ],

    Spaces must be used for alignment; tabs are not allowed
    Open

            ];

    Spaces must be used for alignment; tabs are not allowed
    Open

                    'uitype' => 56,

    Spaces must be used for alignment; tabs are not allowed
    Open

                    'fieldvalue' => $config['rcListCheckRbl'] ?? false,

    Spaces must be used for alignment; tabs are not allowed
    Open

            return $fields;

    Spaces must be used for alignment; tabs are not allowed
    Open

                    'label' => 'LBL_SEND_REPORT_AUTOMATICALLY',

    Spaces must be used for alignment; tabs are not allowed
    Open

                    'fieldvalue' => $config['rcListSendReportAutomatically'] ?? false,

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

    class Settings_MailRbl_ConfigModal_Model

    There are no issues that match your filters.

    Category
    Status