YetiForceCompany/YetiForceCRM

View on GitHub
modules/Settings/RecordNumbering/views/CustomRecordNumbering.php

Summary

Maintainability
A
2 hrs
Test Coverage
F
0%

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

    public function process(App\Request $request)
    {
        $qualifiedModuleName = $request->getModule(false);
        $supportedModules = Settings_RecordNumbering_Module_Model::getSupportedModules();
        $sourceModule = $request->getByType('sourceModule', 2);
Severity: Minor
Found in modules/Settings/RecordNumbering/views/CustomRecordNumbering.php - About 1 hr to fix

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

        public function process(App\Request $request)
        {
            $qualifiedModuleName = $request->getModule(false);
            $supportedModules = Settings_RecordNumbering_Module_Model::getSupportedModules();
            $sourceModule = $request->getByType('sourceModule', 2);
    Severity: Minor
    Found in modules/Settings/RecordNumbering/views/CustomRecordNumbering.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

    Avoid using static access to class 'App\TextParser' in method 'process'.
    Open

            $textParser = App\TextParser::getInstance($defaultModuleModel->getName());

    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

                    $blockName = \App\Language::translate($blockName, $defaultModuleModel->getName());

    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

    Avoid using static access to class '\App\Module' in method 'process'.
    Open

                $defaultModuleModel = $supportedModules[\App\Module::getModuleId($sourceModule)];

    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

                        $referenceFields[$blockName][$field['var_value']] = \App\Language::translate($field['label'], $defaultModuleModel->getName());

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

                if (\App\Fields\Picklist::prefixExist($fieldModel->getFieldName())) {

    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 process uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                $defaultModuleModel = reset($supportedModules);
            }

    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

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

            $textParser = App\TextParser::getInstance($defaultModuleModel->getName());

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('SUPPORTED_MODULES', $supportedModules);

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('DEFAULT_MODULE_MODEL', $defaultModuleModel);

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('PICKLISTS', $picklistFields);

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('IS_AJAX', $request->isAjax());

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('REFERENCE_FIELDS', $referenceFields);

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

    class Settings_RecordNumbering_CustomRecordNumbering_View extends Settings_Vtiger_Index_View
    {
        /** {@inheritdoc} */
        protected $pageTitle = 'LBL_CUSTOMIZE_RECORD_NUMBERING';
    
    

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

    The class Settings_RecordNumbering_CustomRecordNumbering_View is not named in CamelCase.
    Open

    class Settings_RecordNumbering_CustomRecordNumbering_View extends Settings_Vtiger_Index_View
    {
        /** {@inheritdoc} */
        protected $pageTitle = 'LBL_CUSTOMIZE_RECORD_NUMBERING';
    
    

    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

                    $picklistFields[$fieldModel->getName()] = $fieldModel;

    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

                'libraries.clipboard.dist.clipboard',

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

            $picklistFields = [];

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

            $textParser = App\TextParser::getInstance($defaultModuleModel->getName());

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

        protected $pageTitle = 'LBL_CUSTOMIZE_RECORD_NUMBERING';

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

            foreach ($textParser->getRelatedVariable('string') as $modules) {

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

            $viewer->assign('REFERENCE_FIELDS', $referenceFields);

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

            $viewer->assign('IS_AJAX', $request->isAjax());

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

            if ($sourceModule) {

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

                $defaultModuleModel = $supportedModules[\App\Module::getModuleId($sourceModule)];

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

            foreach ($picklistsModels as $fieldModel) {

    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('DEFAULT_MODULE_MODEL', $defaultModuleModel);

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

            $referenceFields = [];

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

                    foreach ($fields as $field) {

    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

            $sourceModule = $request->getByType('sourceModule', 2);

    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 = $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

        /** {@inheritdoc} */

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

                $defaultModuleModel = reset($supportedModules);

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

            }

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

                foreach ($modules as $blockName => $fields) {

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

                'modules.Settings.Vtiger.resources.Edit',

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

            $qualifiedModuleName = $request->getModule(false);

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

                        $referenceFields[$blockName][$field['var_value']] = \App\Language::translate($field['label'], $defaultModuleModel->getName());

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

            $viewer->view('CustomRecordNumbering.tpl', $qualifiedModuleName);

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

        {

    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

        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

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

                    $blockName = \App\Language::translate($blockName, $defaultModuleModel->getName());

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

            $viewer->assign('SUPPORTED_MODULES', $supportedModules);

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

            $viewer->assign('PICKLISTS', $picklistFields);

    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

            $picklistsModels = $defaultModuleModel->getFieldsByType(['picklist']);

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

                if (\App\Fields\Picklist::prefixExist($fieldModel->getFieldName())) {

    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

            } else {

    Line exceeds 120 characters; contains 146 characters
    Open

                        $referenceFields[$blockName][$field['var_value']] = \App\Language::translate($field['label'], $defaultModuleModel->getName());

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

                    }

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

    class Settings_RecordNumbering_CustomRecordNumbering_View extends Settings_Vtiger_Index_View

    There are no issues that match your filters.

    Category
    Status