YetiForceCompany/YetiForceCRM

View on GitHub
modules/Settings/MailIntegration/actions/SaveConfigForm.php

Summary

Maintainability
A
2 hrs
Test Coverage
F
0%

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

    public function process(App\Request $request)
    {
        $fields = Settings_MailIntegration_ConfigForm_Model::getFields($request->getModule(false));
        $field = $request->getByType('updateField');
        if (!isset($fields[$field])) {
Severity: Minor
Found in modules/Settings/MailIntegration/actions/SaveConfigForm.php - About 1 hr 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

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

    public function process(App\Request $request)
    {
        $fields = Settings_MailIntegration_ConfigForm_Model::getFields($request->getModule(false));
        $field = $request->getByType('updateField');
        if (!isset($fields[$field])) {
Severity: Minor
Found in modules/Settings/MailIntegration/actions/SaveConfigForm.php - About 1 hr to fix

    Missing class import via use statement (line '37', column '19').
    Open

            $security = new \App\ConfigFile('security');

    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 '23', column '14').
    Open

                throw new \App\Exceptions\IllegalValue('ERR_ILLEGAL_VALUE');

    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 '19').
    Open

            $response = new Vtiger_Response();

    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 '33', column '21').
    Open

            $configFile = new \App\ConfigFile('module', 'MailIntegration');

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

            $fields = Settings_MailIntegration_ConfigForm_Model::getFields($request->getModule(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\Language' in method 'process'.
    Open

            $response->setResult(['notify' => ['type' => 'success', 'text' => \App\Language::translate('LBL_CHANGES_SAVED')]]);

    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 assigning values to variables in if clauses and the like (line '42', column '21').
    Open

        public function process(App\Request $request)
        {
            $fields = Settings_MailIntegration_ConfigForm_Model::getFields($request->getModule(false));
            $field = $request->getByType('updateField');
            if (!isset($fields[$field])) {

    IfStatementAssignment

    Since: 2.7.0

    Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($foo = 'bar') { // possible typo
                // ...
            }
            if ($baz = 0) { // always false
                // ...
            }
        }
    }

    Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

    Reference to static property outlookUrls from undeclared class \Config\Modules\MailIntegration
    Open

                $oldValue = \Config\Modules\MailIntegration::$outlookUrls;

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

    class Settings_MailIntegration_SaveConfigForm_Action extends Settings_Vtiger_Basic_Action
    {
        /** {@inheritdoc} */
        public function process(App\Request $request)
        {

    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_SaveConfigForm_Action extends Settings_Vtiger_Basic_Action

    The class Settings_MailIntegration_SaveConfigForm_Action is not named in CamelCase.
    Open

    class Settings_MailIntegration_SaveConfigForm_Action extends Settings_Vtiger_Basic_Action
    {
        /** {@inheritdoc} */
        public function process(App\Request $request)
        {

    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

            if (!isset($fields[$field])) {

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

            $configFile->create();

    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

        {

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

            $value = $fieldModel->get('isArray') ? $request->getArray($field, $fieldModel->get('purifyType')) : $request->getByType($field, $fieldModel->get('purifyType'));

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

                $oldValue = \Config\Modules\MailIntegration::$outlookUrls;

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

            if ('outlookUrls' === $field) {

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

            $configFile->set($field, $value);

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

                $updateValue = array_unique(array_merge((\Config\Security::$allowedFrameDomains), $value));

    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

            $configFile = new \App\ConfigFile('module', 'MailIntegration');

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

            if ('outlookUrls' === $field) {

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

                if (isset($toRemove)) {

    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

            $response->emit();

    Line exceeds 120 characters; contains 168 characters
    Open

            $value = $fieldModel->get('isArray') ? $request->getArray($field, $fieldModel->get('purifyType')) : $request->getByType($field, $fieldModel->get('purifyType'));

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

            $field = $request->getByType('updateField');

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

            }

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

            $security->create();

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

                $security->set('allowedFrameDomains', array_values($updateValue));

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

            $fields = Settings_MailIntegration_ConfigForm_Model::getFields($request->getModule(false));

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

                            unset($updateValue[$key]);

    Line exceeds 120 characters; contains 123 characters
    Open

            $response->setResult(['notify' => ['type' => 'success', 'text' => \App\Language::translate('LBL_CHANGES_SAVED')]]);

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

            }

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

                $toRemove = array_diff($oldValue, $value);

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

                        if (false !== ($key = array_search($value, $updateValue))) {

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

                        }

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

            $response->setResult(['notify' => ['type' => 'success', 'text' => \App\Language::translate('LBL_CHANGES_SAVED')]]);

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

                throw new \App\Exceptions\IllegalValue('ERR_ILLEGAL_VALUE');

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

            $fieldModel->getUITypeModel()->validate($value, true);

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

            $fieldModel = $fields[$field];

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

            $security = new \App\ConfigFile('security');

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

                    foreach ($toRemove as $value) {

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

            $response = new Vtiger_Response();

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

        }

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

    class Settings_MailIntegration_SaveConfigForm_Action extends Settings_Vtiger_Basic_Action

    There are no issues that match your filters.

    Category
    Status