YetiForceCompany/YetiForceCRM

View on GitHub
modules/ApiAddress/ApiAddress.php

Summary

Maintainability
A
1 hr
Test Coverage
B
80%

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

    public function moduleHandler($moduleName, $eventType)
    {
        require_once 'include/utils/CommonUtils.php';
        require_once 'include/fields/DateTimeField.php';
        require_once 'include/fields/DateTimeRange.php';
Severity: Minor
Found in modules/ApiAddress/ApiAddress.php - About 1 hr to fix

    Avoid using static access to class 'Settings_Vtiger_Module_Model' in method 'moduleHandler'.
    Open

                Settings_Vtiger_Module_Model::addSettingsField('LBL_INTEGRATION', [
                    'name' => $displayLabel,
                    'iconpath' => '',
                    'description' => 'LBL_API_ADDRESS_DESCRIPTION',
                    'linkto' => 'index.php?module=ApiAddress&parent=Settings&view=Configuration',
    Severity: Minor
    Found in modules/ApiAddress/ApiAddress.php by phpmd

    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

    The method moduleHandler uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                Settings_Vtiger_Module_Model::deleteSettingsField('LBL_INTEGRATION', $displayLabel);
            }
    Severity: Minor
    Found in modules/ApiAddress/ApiAddress.php by phpmd

    ElseExpression

    Since: 1.4.0

    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($flag) {
                // one branch
            } else {
                // another branch
            }
        }
    }

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

    Avoid using static access to class 'Settings_Vtiger_Module_Model' in method 'moduleHandler'.
    Open

                Settings_Vtiger_Module_Model::deleteSettingsField('LBL_INTEGRATION', $displayLabel);
    Severity: Minor
    Found in modules/ApiAddress/ApiAddress.php by phpmd

    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 \App\Db::createCommand
    Open

                \App\Db::getInstance()->createCommand()->insert('s_yf_address_finder_config', ['nominatim' => 0, 'key' => 0, 'source' => 'https://api.opencagedata.com/geocode/v1/', 'min_length' => 3])->execute();
    Severity: Critical
    Found in modules/ApiAddress/ApiAddress.php by phan

    Saw possibly unextractable annotation for a fragment of comment '* @param string Module name': after string, did not see an element name (will guess based on comment order)
    Open

         * @param string Module name
    Severity: Info
    Found in modules/ApiAddress/ApiAddress.php by phan

    Saw possibly unextractable annotation for a fragment of comment '* @param string Event Type': after string, did not see an element name (will guess based on comment order)
    Open

         * @param string Event Type
    Severity: Info
    Found in modules/ApiAddress/ApiAddress.php by phan

    Call to undeclared method \App\Db::createCommand
    Open

                \App\Db::getInstance()->createCommand()->update('vtiger_tab', ['customized' => 0], ['name' => $moduleName])->execute();
    Severity: Critical
    Found in modules/ApiAddress/ApiAddress.php by phan

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

    class ApiAddress

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

         * @param mixed $eventType

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

        {

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

                Settings_Vtiger_Module_Model::addSettingsField('LBL_INTEGRATION', [

    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 moduleHandler($moduleName, $eventType)

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

            require_once 'include/fields/CurrencyField.php';

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

                    'iconpath' => '',

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

                    'linkto' => 'index.php?module=ApiAddress&parent=Settings&view=Configuration',

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

         * Invoked when special actions are performed on the module.

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

            require_once 'include/CRMEntity.php';

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

            include_once 'modules/Vtiger/CRMEntity.php';

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

            }

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

            require_once 'include/Webservices/Utils.php';

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

                //Add Assets Module to Customer Portal

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

                \App\Db::getInstance()->createCommand()->update('vtiger_tab', ['customized' => 0], ['name' => $moduleName])->execute();

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

         * @param mixed $moduleName

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

            require_once 'modules/PickList/DependentPickListUtils.php';

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

                $registerLink = true;

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

                \App\Db::getInstance()->createCommand()->insert('s_yf_address_finder_config', ['nominatim' => 0, 'key' => 0, 'source' => 'https://api.opencagedata.com/geocode/v1/', 'min_length' => 3])->execute();

    Line exceeds 120 characters; contains 208 characters
    Open

                \App\Db::getInstance()->createCommand()->insert('s_yf_address_finder_config', ['nominatim' => 0, 'key' => 0, 'source' => 'https://api.opencagedata.com/geocode/v1/', 'min_length' => 3])->execute();

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

            $displayLabel = 'LBL_API_ADDRESS';

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

        /**

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

            require_once 'include/runtime/Cache.php';

    Line exceeds 120 characters; contains 131 characters
    Open

                \App\Db::getInstance()->createCommand()->update('vtiger_tab', ['customized' => 0], ['name' => $moduleName])->execute();

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

                    'description' => 'LBL_API_ADDRESS_DESCRIPTION',

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

                Settings_Vtiger_Module_Model::deleteSettingsField('LBL_INTEGRATION', $displayLabel);

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

         * @param string Event Type

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

         */

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

            require_once 'include/fields/DateTimeRange.php';

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

            require_once 'modules/Vtiger/helpers/Util.php';

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

            require_once 'modules/Users/Users.php';

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

                    'name' => $displayLabel,

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

                ]);

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

            require_once 'include/fields/DateTimeField.php';

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

            $registerLink = false;

    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 ($registerLink) {

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

        }

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

         * @param string Module name

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

            } else {

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

            require_once 'include/utils/CommonUtils.php';

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

            if ('module.postinstall' === $eventType) {

    There are no issues that match your filters.

    Category
    Status