YetiForceCompany/YetiForceCRM

View on GitHub
modules/Vtiger/views/GenerateModal.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

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)

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

        $handlerClass = Vtiger_Loader::getComponentClassName('Model', 'MappedFields', $moduleName);

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

            $allRecords = Vtiger_Mass_Action::getRecordsListFromRequest($request);

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 {
            $recordId = $request->getInteger('record');
            $templates = $mfModel->getActiveTemplatesForRecord($recordId, $view, $moduleName);
        }

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 unused parameters such as '$request'.
Open

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

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

Avoid unused parameters such as '$display'.
Open

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

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('TEMPLATES', $templates);
Severity: Critical
Found in modules/Vtiger/views/GenerateModal.php by phan

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('VIEW', $view);
Severity: Critical
Found in modules/Vtiger/views/GenerateModal.php by phan

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('BASE_MODULE_NAME', 'Vtiger');
Severity: Critical
Found in modules/Vtiger/views/GenerateModal.php by phan

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('RECORD', $recordId ?? '');
Severity: Critical
Found in modules/Vtiger/views/GenerateModal.php by phan

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('MODULE_NAME', $moduleName);
Severity: Critical
Found in modules/Vtiger/views/GenerateModal.php by phan

Call to undeclared method \Vtiger_Viewer::assign
Open

            $viewer->assign('ALL_RECORDS', $allRecords);
Severity: Critical
Found in modules/Vtiger/views/GenerateModal.php by phan

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

class Vtiger_GenerateModal_View extends Vtiger_BasicModal_View

The class Vtiger_GenerateModal_View is not named in CamelCase.
Open

class Vtiger_GenerateModal_View extends Vtiger_BasicModal_View
{
    public function preProcess(App\Request $request, $display = true)
    {
        echo '<div class="generateMappingModal modal fade"><div class="modal-dialog"><div class="modal-content">';

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

    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 preProcess(App\Request $request, $display = true)

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

        echo '<div class="generateMappingModal modal fade"><div class="modal-dialog"><div class="modal-content">';

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

        $mfModel = new $handlerClass();

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

        $viewer->assign('BASE_MODULE_NAME', 'Vtiger');

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

            $templates = $mfModel->getActiveTemplatesForModule($moduleName, $view);

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

        $this->postProcess($request);

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

            $recordId = $request->getInteger('record');

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

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

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

        if ('List' === $view) {

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

        $viewer->assign('RECORD', $recordId ?? '');

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

        $this->preProcess($request);

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

        $handlerClass = Vtiger_Loader::getComponentClassName('Model', 'MappedFields', $moduleName);

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

        $viewer->view('GenerateModal.tpl', $moduleName);

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

        $view = $request->getByType('fromview', 1);

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

            $allRecords = Vtiger_Mass_Action::getRecordsListFromRequest($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

            $viewer->assign('ALL_RECORDS', $allRecords);

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

            $templates = $mfModel->getActiveTemplatesForRecord($recordId, $view, $moduleName);

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

        $viewer->assign('VIEW', $view);

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

        $viewer->assign('TEMPLATES', $templates);

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

class Vtiger_GenerateModal_View extends Vtiger_BasicModal_View

There are no issues that match your filters.

Category
Status