YetiForceCompany/YetiForceCRM

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

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

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

            throw new \App\Exceptions\AppException(\App\Language::translate('ERR_TREE_NOT_FOUND', $moduleName));
Severity: Minor
Found in modules/Vtiger/views/TreeModal.php by phpmd

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 '38', column '14').
Open

            throw new \App\Exceptions\NoPermitted('LBL_NO_PERMISSIONS_TO_FIELD');
Severity: Minor
Found in modules/Vtiger/views/TreeModal.php by phpmd

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 '33', column '14').
Open

            throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);
Severity: Minor
Found in modules/Vtiger/views/TreeModal.php by phpmd

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

        $recordModel = Settings_TreesManager_Record_Model::getInstanceById($templateId);
Severity: Minor
Found in modules/Vtiger/views/TreeModal.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 process uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $this->successBtn = '';
        }
Severity: Minor
Found in modules/Vtiger/views/TreeModal.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

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

            throw new \App\Exceptions\AppException(\App\Language::translate('ERR_TREE_NOT_FOUND', $moduleName));
Severity: Minor
Found in modules/Vtiger/views/TreeModal.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 'Users_Privileges_Model' in method 'checkPermission'.
Open

        $userModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
Severity: Minor
Found in modules/Vtiger/views/TreeModal.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 '\App\Json' in method 'process'.
Open

        $viewer->assign('TREE', \App\Json::encode($recordModel->getTree($type, $request->getByType('value', 'Text'))));
Severity: Minor
Found in modules/Vtiger/views/TreeModal.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

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

        if ($request->getBoolean('multiple')) {
Severity: Critical
Found in modules/Vtiger/views/TreeModal.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.

Class extends undeclared class \App\Controller\Modal
Open

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

Call to undeclared method \Vtiger_TreeModal_View::checkAndConvertJsScripts
Open

        return array_merge(parent::getModalScripts($request), $this->checkAndConvertJsScripts($jsFileNames));
Severity: Critical
Found in modules/Vtiger/views/TreeModal.php by phan

Reference to undeclared class \App\Controller\Modal
Open

        parent::preProcessAjax($request);
Severity: Critical
Found in modules/Vtiger/views/TreeModal.php by phan

Reference to undeclared class \App\Controller\Modal
Open

        return array_merge(parent::getModalCss($request), $this->checkAndConvertCssStyles([
Severity: Critical
Found in modules/Vtiger/views/TreeModal.php by phan

Call to undeclared method \Vtiger_TreeModal_View::getViewer
Open

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

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

        $this->pageTitle = $this->fieldModel->getFieldLabel();
Severity: Minor
Found in modules/Vtiger/views/TreeModal.php by phan

Reference to undeclared class \App\Controller\Modal
Open

        return array_merge(parent::getModalScripts($request), $this->checkAndConvertJsScripts($jsFileNames));
Severity: Critical
Found in modules/Vtiger/views/TreeModal.php by phan

Reference to undeclared property \Vtiger_TreeModal_View->pageTitle
Open

        $this->pageTitle = $this->fieldModel->getFieldLabel();
Severity: Minor
Found in modules/Vtiger/views/TreeModal.php by phan

Call to undeclared method \Vtiger_TreeModal_View::checkAndConvertCssStyles
Open

        return array_merge(parent::getModalCss($request), $this->checkAndConvertCssStyles([
Severity: Critical
Found in modules/Vtiger/views/TreeModal.php by phan

Call to undeclared method \Vtiger_TreeModal_View::getViewer
Open

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

Argument 1 (mixed) is string but \Users_Privileges_Model::hasModulePermission() takes int defined at /code/modules/Users/models/Privileges.php:101
Open

        if (!$userModel->hasModulePermission($request->getModule())) {
Severity: Minor
Found in modules/Vtiger/views/TreeModal.php by phan

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

class Vtiger_TreeModal_View extends \App\Controller\Modal

The class Vtiger_TreeModal_View is not named in CamelCase.
Open

class Vtiger_TreeModal_View extends \App\Controller\Modal
{
    /**
     * The name of the success button.
     *
Severity: Minor
Found in modules/Vtiger/views/TreeModal.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

    /**

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

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

        if ($request->getBoolean('multiple')) {

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

    /** {@inheritdoc} */

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

        $this->fieldModel = Vtiger_Module_Model::getInstance($request->getModule())->getFieldByName($request->getByType('fieldName', 2));

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

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

     */

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

    public $successBtn = 'LBL_SELECT_OPTION';

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

    public $fieldModel;

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

        if (!$userModel->hasModulePermission($request->getModule())) {

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

            throw new \App\Exceptions\NoPermitted('LBL_NO_PERMISSIONS_TO_FIELD');

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

    }

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

        }

Line exceeds 120 characters; contains 157 characters
Open

        if (!$this->fieldModel || !$this->fieldModel->isViewable() || !\in_array($this->fieldModel->getFieldDataType(), ['categoryMultipicklist', 'tree'])) {

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_TreesManager_Record_Model::getInstanceById($templateId);

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

            $this->successBtn = '';

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

        $viewer->assign('TREE', \App\Json::encode($recordModel->getTree($type, $request->getByType('value', 'Text'))));

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

            $jsFileNames[] = '~layouts/resources/libraries/jstree.category.js';

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

        }

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

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

        $templateId = (int) $this->fieldModel->getFieldParams();

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

        if (!$recordModel) {

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

        return array_merge(parent::getModalCss($request), $this->checkAndConvertCssStyles([

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

     * The name of the success button.

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

        if (!$this->fieldModel || !$this->fieldModel->isViewable() || !\in_array($this->fieldModel->getFieldDataType(), ['categoryMultipicklist', 'tree'])) {

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

        return 'Modals/TreeHeader.tpl';

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

            throw new \App\Exceptions\AppException(\App\Language::translate('ERR_TREE_NOT_FOUND', $moduleName));

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

            $type = 'category';

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

        $jsFileNames = array_merge($jsFileNames, [

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

    {

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

     *

Line exceeds 120 characters; contains 137 characters
Open

        $this->fieldModel = Vtiger_Module_Model::getInstance($request->getModule())->getFieldByName($request->getByType('fieldName', 2));

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

        return array_merge(parent::getModalScripts($request), $this->checkAndConvertJsScripts($jsFileNames));

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

    }

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

     * @var Vtiger_Field_Model

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

    public function getModalCss(App\Request $request)

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

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

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

        $this->pageTitle = $this->fieldModel->getFieldLabel();

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

    protected function preProcessTplName(App\Request $request)

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

     * Tree in popup.

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

        $viewer->assign('IS_MULTIPLE', $request->getBoolean('multiple'));

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

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

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

     * @var string

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

     * Field model.

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('FIELD_INSTANCE', $this->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

        $type = false;

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

        if ($request->getBoolean('multiple')) {

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

            'modules.Vtiger.resources.TreeModal',

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

            "modules.$moduleName.resources.TreeModal",

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

            '~libraries/jstree-bootstrap-theme/dist/themes/proton/style.css',

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

        ]));

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

        $userModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();

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

    /**

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

        $jsFileNames = ['~libraries/jstree/dist/jstree.js'];

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

            $jsFileNames[] = '~layouts/resources/libraries/jstree.checkbox.js';

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

     */

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

     * @param \App\Request $request

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

        $moduleName = $request->getModule();

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

class Vtiger_TreeModal_View extends \App\Controller\Modal

There are no issues that match your filters.

Category
Status