YetiForceCompany/YetiForceCRM

View on GitHub
modules/Settings/AutomaticAssignment/views/Edit.php

Summary

Maintainability
A
1 hr
Test Coverage
F
0%

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

    public function process(App\Request $request)
    {
        $qualifiedModuleName = $request->getModule(false);
        $selectedModuleName = '';
        if ($request->isEmpty('record')) {
Severity: Minor
Found in modules/Settings/AutomaticAssignment/views/Edit.php - About 1 hr to fix

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

        public function process(App\Request $request)
        {
            $qualifiedModuleName = $request->getModule(false);
            $selectedModuleName = '';
            if ($request->isEmpty('record')) {
    Severity: Minor
    Found in modules/Settings/AutomaticAssignment/views/Edit.php - About 45 mins 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\Json' in method 'process'.
    Open

            $viewer->assign('ADVANCE_CRITERIA', \App\Json::decode($recordModel->get('conditions')));

    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 {
                $recordModel = Settings_AutomaticAssignment_Record_Model::getInstanceById($request->getInteger('record'));
                $selectedModuleName = \App\Module::getModuleName($recordModel->get('tabid'));
            }

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

            \App\Config::set('performance', 'picklistLimit', 9999);

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

                $recordModel = Settings_AutomaticAssignment_Record_Model::getInstanceById($request->getInteger('record'));

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

                $sourceModuleModel = Vtiger_Module_Model::getInstance($selectedModuleName);

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

                $recordModel = Settings_AutomaticAssignment_Record_Model::getCleanInstance();

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

                        $recordStructureModulesField[$relatedModuleName][$referenceField->getFieldName()] = Vtiger_RecordStructure_Model::getInstanceForModule(Vtiger_Module_Model::getInstance($relatedModuleName))->getStructure();

    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

                $selectedModuleName = \App\Module::getModuleName($recordModel->get('tabid'));

    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 \Vtiger_Viewer::assign
    Open

                $viewer->assign('RECORD_STRUCTURE_RELATED_MODULES', $recordStructureModulesField);

    Call to undeclared method \Vtiger_Viewer::assign
    Open

                $viewer->assign('RECORD_STRUCTURE', Vtiger_RecordStructure_Model::getInstanceForModule($sourceModuleModel)->getStructure());

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('SOURCE_MODULE', $selectedModuleName);

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('RECORD_MODEL', $recordModel);

    Call to deprecated function \Vtiger_Field_Model::getFieldName() defined at /code/modules/Vtiger/models/Field.php:203
    Open

                        $recordStructureModulesField[$relatedModuleName][$referenceField->getFieldName()] = Vtiger_RecordStructure_Model::getInstanceForModule(Vtiger_Module_Model::getInstance($relatedModuleName))->getStructure();

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('ADVANCE_CRITERIA', \App\Json::decode($recordModel->get('conditions')));

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('RECORD_ID', $recordModel->getId());

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('STRUCTURE', $recordModel->getModule()->getEditViewStructure($recordModel));

    Avoid excessively long variable names like $recordStructureModulesField. Keep variable name length under 20.
    Open

                $recordStructureModulesField = [];

    LongVariable

    Since: 0.2

    Detects when a field, formal or local variable is declared with a long name.

    Example

    class Something {
        protected $reallyLongIntName = -3; // VIOLATION - Field
        public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
            $otherReallyLongName = -5; // VIOLATION - Local
            for ($interestingIntIndex = 0; // VIOLATION - For
                 $interestingIntIndex < 10;
                 $interestingIntIndex++ ) {
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#longvariable

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

    class Settings_AutomaticAssignment_Edit_View extends Settings_Vtiger_Index_View

    The class Settings_AutomaticAssignment_Edit_View is not named in CamelCase.
    Open

    class Settings_AutomaticAssignment_Edit_View extends Settings_Vtiger_Index_View
    {
        /**
         * Process.
         *

    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

                $recordModel = Settings_AutomaticAssignment_Record_Model::getInstanceById($request->getInteger('record'));

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

                $selectedModuleName = \App\Module::getModuleName($recordModel->get('tabid'));

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

            $viewer->assign('STRUCTURE', $recordModel->getModule()->getEditViewStructure($recordModel));

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

            \App\Config::set('performance', 'picklistLimit', 9999);

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

            $viewer->assign('SOURCE_MODULE', $selectedModuleName);

    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

            if ($selectedModuleName) {

    Line exceeds 120 characters; contains 225 characters
    Open

                        $recordStructureModulesField[$relatedModuleName][$referenceField->getFieldName()] = Vtiger_RecordStructure_Model::getInstanceForModule(Vtiger_Module_Model::getInstance($relatedModuleName))->getStructure();

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

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

    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

            $viewer = $this->getViewer($request);

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

            if ($request->isEmpty('record')) {

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

                    foreach ($referenceField->getReferenceList() as $relatedModuleName) {

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

            $viewer->assign('RECORD_MODEL', $recordModel);

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

                $sourceModuleModel = Vtiger_Module_Model::getInstance($selectedModuleName);

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

                $viewer->assign('RECORD_STRUCTURE', Vtiger_RecordStructure_Model::getInstanceForModule($sourceModuleModel)->getStructure());

    Line exceeds 120 characters; contains 136 characters
    Open

                $viewer->assign('RECORD_STRUCTURE', Vtiger_RecordStructure_Model::getInstanceForModule($sourceModuleModel)->getStructure());

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

            }

    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

         */

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

            $selectedModuleName = '';

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

                }

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

         * Process.

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

                foreach ($sourceModuleModel->getFieldsByReference() as $referenceField) {

    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

         * @param \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

        {

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

                $recordModel = Settings_AutomaticAssignment_Record_Model::getCleanInstance();

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

                    }

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

                $recordStructureModulesField = [];

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

                        $recordStructureModulesField[$relatedModuleName][$referenceField->getFieldName()] = Vtiger_RecordStructure_Model::getInstanceForModule(Vtiger_Module_Model::getInstance($relatedModuleName))->getStructure();

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

                $viewer->assign('RECORD_STRUCTURE_RELATED_MODULES', $recordStructureModulesField);

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

            $viewer->assign('ADVANCE_CRITERIA', \App\Json::decode($recordModel->get('conditions')));

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

            $viewer->assign('RECORD_ID', $recordModel->getId());

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

    class Settings_AutomaticAssignment_Edit_View extends Settings_Vtiger_Index_View

    There are no issues that match your filters.

    Category
    Status