YetiForceCompany/YetiForceCRM

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

Summary

Maintainability
A
1 hr
Test Coverage
F
0%

Method step has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function step($step, App\Request $request)
    {
        $viewer = $this->getViewer($request);
        $moduleName = $request->getModule();
        $qualifiedModuleName = $request->getModule(false);
Severity: Minor
Found in modules/Settings/PDF/views/Edit.php - About 1 hr to fix

    Function step has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function step($step, App\Request $request)
        {
            $viewer = $this->getViewer($request);
            $moduleName = $request->getModule();
            $qualifiedModuleName = $request->getModule(false);
    Severity: Minor
    Found in modules/Settings/PDF/views/Edit.php - About 25 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

    The method preProcess has a boolean flag argument $display, which is a certain sign of a Single Responsibility Principle violation.
    Open

        public function preProcess(App\Request $request, $display = true)
    Severity: Minor
    Found in modules/Settings/PDF/views/Edit.php by phpmd

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

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

    Avoid using static access to class 'Settings_PDF_Record_Model' in method 'step'.
    Open

                $pdfModel = Settings_PDF_Record_Model::getCleanInstance();
    Severity: Minor
    Found in modules/Settings/PDF/views/Edit.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

    Avoid using static access to class 'Vtiger_AdvancedFilter_Helper' in method 'step'.
    Open

                    $viewer->assign('ADVANCE_CRITERIA', Vtiger_AdvancedFilter_Helper::transformToAdvancedFilterCondition($pdfModel->get('conditions')));
    Severity: Minor
    Found in modules/Settings/PDF/views/Edit.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

    Avoid using static access to class 'Vtiger_PDF_Model' in method 'step'.
    Open

                $pdfModel = Vtiger_PDF_Model::getInstanceById($request->getInteger('record'));
    Severity: Minor
    Found in modules/Settings/PDF/views/Edit.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

    Avoid using static access to class 'Vtiger_RecordStructure_Model' in method 'step'.
    Open

                    $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceForModule($moduleModel);
    Severity: Minor
    Found in modules/Settings/PDF/views/Edit.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

    Avoid using static access to class 'Vtiger_Module_Model' in method 'step'.
    Open

                    $moduleModel = Vtiger_Module_Model::getInstance($pdfModel->get('module_name'));
    Severity: Minor
    Found in modules/Settings/PDF/views/Edit.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

    Avoid using static access to class 'Settings_PDF_Module_Model' in method 'step'.
    Open

                    $viewer->assign('ALL_MODULES', Settings_PDF_Module_Model::getSupportedModules());
    Severity: Minor
    Found in modules/Settings/PDF/views/Edit.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 step uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                $selectedModuleName = $request->getByType('source_module', 2);
                $pdfModel = Settings_PDF_Record_Model::getCleanInstance();
            }
    Severity: Minor
    Found in modules/Settings/PDF/views/Edit.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

    Define a constant instead of duplicating this literal "record" 3 times.
    Open

            if (!$request->isEmpty('record', true)) {
    Severity: Critical
    Found in modules/Settings/PDF/views/Edit.php by sonar-php

    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.

    Avoid unused parameters such as '$display'.
    Open

        public function preProcess(App\Request $request, $display = true)
    Severity: Minor
    Found in modules/Settings/PDF/views/Edit.php by phpmd

    UnusedFormalParameter

    Since: 0.2

    Avoid passing parameters to methods or constructors and then not using those parameters.

    Example

    class Foo
    {
        private function bar($howdy)
        {
            // $howdy is not used
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('SELECTED_MODULE', $selectedModuleName);
    Severity: Critical
    Found in modules/Settings/PDF/views/Edit.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('RECORD_MODE', $request->getMode());
    Severity: Critical
    Found in modules/Settings/PDF/views/Edit.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

                    $viewer->assign('ADVANCE_CRITERIA', Vtiger_AdvancedFilter_Helper::transformToAdvancedFilterCondition($pdfModel->get('conditions')));
    Severity: Critical
    Found in modules/Settings/PDF/views/Edit.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName);
    Severity: Critical
    Found in modules/Settings/PDF/views/Edit.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

                $viewer->assign('RECORDID', $request->getInteger('record'));
    Severity: Critical
    Found in modules/Settings/PDF/views/Edit.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('MODULE', $moduleName);
    Severity: Critical
    Found in modules/Settings/PDF/views/Edit.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('SOURCE_MODULE', $selectedModuleName);
    Severity: Critical
    Found in modules/Settings/PDF/views/Edit.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

                    $viewer->assign('ALL_MODULES', Settings_PDF_Module_Model::getSupportedModules());
    Severity: Critical
    Found in modules/Settings/PDF/views/Edit.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('PDF_MODEL', $pdfModel);
    Severity: Critical
    Found in modules/Settings/PDF/views/Edit.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

                $viewer->assign('MODE', 'edit');
    Severity: Critical
    Found in modules/Settings/PDF/views/Edit.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

                    $viewer->assign('RECORD_STRUCTURE', $recordStructureInstance->getStructure());
    Severity: Critical
    Found in modules/Settings/PDF/views/Edit.php by phan

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

                    $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceForModule($moduleModel);
    Severity: Minor
    Found in modules/Settings/PDF/views/Edit.php by phpmd

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

    The class Settings_PDF_Edit_View is not named in CamelCase.
    Open

    class Settings_PDF_Edit_View extends Settings_Vtiger_Index_View
    {
        public function process(App\Request $request)
        {
            $step = strtolower($request->getMode());
    Severity: Minor
    Found in modules/Settings/PDF/views/Edit.php by phpmd

    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

        public function step($step, 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

                    $viewer->assign('RECORD_STRUCTURE', $recordStructureInstance->getStructure());

    Line exceeds 120 characters; contains 148 characters
    Open

                    $viewer->assign('ADVANCE_CRITERIA', Vtiger_AdvancedFilter_Helper::transformToAdvancedFilterCondition($pdfModel->get('conditions')));

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

                case 'step2':

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

            ]), parent::getHeaderCss($request));

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

            parent::preProcess($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

            switch ($step) {

    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->view('Step1.tpl', $qualifiedModuleName);

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

                "modules.Settings.$moduleName.resources.Edit2",

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

                $viewer->assign('MODE', 'edit');

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

                    break;

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

            }

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

                "modules.Settings.$moduleName.resources.Edit3",

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

            ]));

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

                'modules.Vtiger.resources.AdvanceFilterEx',

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

                'modules.Settings.' . $request->getModule() . '.Edit',

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

            $viewer->assign('RECORD_MODE', $request->getMode());

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

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

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

            $viewer->assign('MODULE', $moduleName);

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

                    $moduleModel = Vtiger_Module_Model::getInstance($pdfModel->get('module_name'));

    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

            $viewer->view('EditHeader.tpl', $request->getModule(false));

    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

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

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

                    $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceForModule($moduleModel);

    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

            $step = strtolower($request->getMode());

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

                $selectedModuleName = $pdfModel->get('module_name');

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

            $viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName);

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

                    $viewer->assign('ALL_MODULES', Settings_PDF_Module_Model::getSupportedModules());

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

                "modules.Settings.$moduleName.resources.Edit",

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

            $moduleName = $request->getModule();

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

                    break;

    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

        public function getHeaderCss(App\Request $request)

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

            $this->step($step, $request);

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

                $pdfModel = Settings_PDF_Record_Model::getCleanInstance();

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

                    $viewer->assign('ADVANCE_CRITERIA', Vtiger_AdvancedFilter_Helper::transformToAdvancedFilterCondition($pdfModel->get('conditions')));

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

                    break;

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

            $viewer->assign('PDF_MODEL', $pdfModel);

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

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

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

                case 'step1':

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

        public function preProcess(App\Request $request, $display = true)

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

        }

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

                case 'step3':

    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

        {

    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

            } else {

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

                default:

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

            $moduleName = $request->getModule();

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

                "modules.Settings.$moduleName.resources.Edit1",

    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

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

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

            if (!$request->isEmpty('record', true)) {

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

                $viewer->assign('RECORDID', $request->getInteger('record'));

    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

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

    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

                'modules.Vtiger.resources.AdvanceFilter',

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

        {

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

                $pdfModel = Vtiger_PDF_Model::getInstanceById($request->getInteger('record'));

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

        }

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

            return array_merge($this->checkAndConvertCssStyles([

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

    class Settings_PDF_Edit_View extends Settings_Vtiger_Index_View

    There are no issues that match your filters.

    Category
    Status