YetiForceCompany/YetiForceCRM

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

Summary

Maintainability
A
1 hr
Test Coverage
F
0%

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

    public function process(App\Request $request)
    {
        $moduleName = $request->getModule();
        $changes = $request->getArray('changes');
        $recordStructure = $fieldInfo = [];
Severity: Minor
Found in modules/Vtiger/views/ChangesJsonModal.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

Missing class import via use statement (line '39', column '14').
Open

            throw new \App\Exceptions\NoPermitted('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '36', column '14').
Open

            throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

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

        $viewer->assign('MAPPING_RELATED_FIELD', \App\Json::encode(\App\ModuleHierarchy::getRelationFieldByHierarchy($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_Module_Model' in method 'process'.
Open

        $moduleModel = Vtiger_Module_Model::getInstance($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 '\App\ModuleHierarchy' in method 'process'.
Open

        $viewer->assign('MAPPING_RELATED_FIELD', \App\Json::encode(\App\ModuleHierarchy::getRelationFieldByHierarchy($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 '\App\ModuleHierarchy' in method 'process'.
Open

        $viewer->assign('LIST_FILTER_FIELDS', \App\Json::encode(\App\ModuleHierarchy::getFieldsForListFilter($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 '\App\Json' in method 'process'.
Open

        $viewer->assign('LIST_FILTER_FIELDS', \App\Json::encode(\App\ModuleHierarchy::getFieldsForListFilter($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

Class extends undeclared class \App\Controller\Modal
Open

class Vtiger_ChangesJsonModal_View extends \App\Controller\Modal
Severity: Critical
Found in modules/Vtiger/views/ChangesJsonModal.php by phan

Call to undeclared method \Vtiger_ChangesJsonModal_View::getViewer
Open

        $viewer = $this->getViewer($request);
Severity: Critical
Found in modules/Vtiger/views/ChangesJsonModal.php by phan

Call to undeclared method \Vtiger_ChangesJsonModal_View::checkAndConvertJsScripts
Open

        return array_merge($this->checkAndConvertJsScripts([
Severity: Critical
Found in modules/Vtiger/views/ChangesJsonModal.php by phan

Reference to undeclared class \App\Controller\Modal
Open

        ]), parent::getModalScripts($request));
Severity: Critical
Found in modules/Vtiger/views/ChangesJsonModal.php by phan

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

class Vtiger_ChangesJsonModal_View extends \App\Controller\Modal

The class Vtiger_ChangesJsonModal_View is not named in CamelCase.
Open

class Vtiger_ChangesJsonModal_View extends \App\Controller\Modal
{
    /** {@inheritdoc} */
    public $modalSize = 'modal-lg';

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

    /** {@inheritdoc} */

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

        $moduleName = $request->getModule();

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

            foreach ($blockModel->getFields() as $fieldName => $fieldModel) {

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

                        $fieldModel->getUITypeModel()->validate($changes[$fieldName], true);

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

        $viewer->assign('MAPPING_RELATED_FIELD', \App\Json::encode(\App\ModuleHierarchy::getRelationFieldByHierarchy($moduleName)));

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

    public function checkPermission(App\Request $request)

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

    public $modalSize = 'modal-lg';

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

        return \Vtiger_Module_Model::getInstance($request->getByType('sourceModule', \App\Purifier::ALNUM))

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

            throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);

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

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

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

        $viewer->view('Modals/ChangesJson.tpl', $moduleName);

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

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

    /** {@inheritdoc} */

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

        $moduleName = $request->getModule();

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

            "modules.{$moduleName}.resources.{$viewName}"

Line exceeds 120 characters; contains 132 characters
Open

        $viewer->assign('MAPPING_RELATED_FIELD', \App\Json::encode(\App\ModuleHierarchy::getRelationFieldByHierarchy($moduleName)));

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

        $viewer->assign('LIST_FILTER_FIELDS', \App\Json::encode(\App\ModuleHierarchy::getFieldsForListFilter($moduleName)));

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

        $recordStructure = $fieldInfo = [];

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

                }

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

            throw new \App\Exceptions\NoPermitted('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);

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

    public function getModalScripts(App\Request $request)

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

        $changes = $request->getArray('changes');

Line exceeds 120 characters; contains 124 characters
Open

        $viewer->assign('LIST_FILTER_FIELDS', \App\Json::encode(\App\ModuleHierarchy::getFieldsForListFilter($moduleName)));

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

        $sourceField = $request->getByType('sourceField', \App\Purifier::ALNUM);

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

    {

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

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

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

        $moduleModel = Vtiger_Module_Model::getInstance($moduleName);

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

                if ($fieldModel->isEditable() && $fieldModel->isMassEditable() && $fieldModel->isViewable() && !\in_array($fieldModel->getFieldDataType(), ['image', 'multiImage', 'accountName'])) {

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

                    $fieldInfo[$fieldName] = $fieldModel->getFieldInfo();

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

        $viewer->assign('RECORD_STRUCTURE', $recordStructure);

Line exceeds 120 characters; contains 125 characters
Open

        if (!$sourceField || !\Vtiger_Module_Model::getInstance($sourceModule)->getFieldByName($sourceField)->isEditable()) {

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

        $viewName = 'Edit';

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

    }

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

        $sourceModule = $request->getByType('sourceModule', \App\Purifier::ALNUM);

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

        foreach ($moduleModel->getBlocks() as $blockLabel => $blockModel) {

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 ($record && !\Vtiger_Record_Model::getInstanceById($record, $request->getModule())->isViewable()) {

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

            "modules.Vtiger.resources.{$viewName}",

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

                    if (isset($changes[$fieldName])) {

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

                    $recordStructure[$blockLabel][$fieldName] = $fieldModel;

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

        $viewer->assign('EDIT_FIELD_DETAILS', $fieldInfo);

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

    public $modalIcon = 'yfi yfi-full-editing-view';

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

        return array_merge($this->checkAndConvertJsScripts([

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

    /** {@inheritdoc} */

Line exceeds 120 characters; contains 197 characters
Open

                if ($fieldModel->isEditable() && $fieldModel->isMassEditable() && $fieldModel->isViewable() && !\in_array($fieldModel->getFieldDataType(), ['image', 'multiImage', 'accountName'])) {

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

            ->getFieldByName($request->getByType('sourceField', \App\Purifier::ALNUM))->getFullLabelTranslation();

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

        if (!$sourceField || !\Vtiger_Module_Model::getInstance($sourceModule)->getFieldByName($sourceField)->isEditable()) {

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

                        $fieldModel->set('fieldvalue', $fieldModel->getUITypeModel()->getDBValue($changes[$fieldName]));

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

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

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

class Vtiger_ChangesJsonModal_View extends \App\Controller\Modal

There are no issues that match your filters.

Category
Status