YetiForceCompany/YetiForceCRM

View on GitHub
modules/Settings/Picklist/views/IndexAjax.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

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

            $fieldModel = Settings_Picklist_Field_Model::getInstance($pickFieldName, Vtiger_Module_Model::getInstance($sourceModule));

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 'getPickListValueByRole'.
Open

        $fieldModel = Settings_Picklist_Field_Model::getInstance($pickFieldName, Vtiger_Module_Model::getInstance($sourceModule));

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\Fields\Picklist' in method 'getPickListValueForField'.
Open

            $selectedFieldAllPickListValues = App\Fields\Picklist::getValuesName($fieldModel->getName());

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_Roles_Record_Model' in method 'getPickListValueForField'.
Open

        $viewer->assign('ROLES_LIST', Settings_Roles_Record_Model::getAll());

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\Fields\Picklist' in method 'getPickListValueByRole'.
Open

        $allPickListValues = App\Fields\Picklist::getValuesName($fieldModel->getName());

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_Picklist_Field_Model' in method 'getPickListValueForField'.
Open

            $fieldModel = Settings_Picklist_Field_Model::getInstance($pickFieldName, Vtiger_Module_Model::getInstance($sourceModule));

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_Picklist_Field_Model' in method 'getPickListValueByRole'.
Open

        $fieldModel = Settings_Picklist_Field_Model::getInstance($pickFieldName, Vtiger_Module_Model::getInstance($sourceModule));

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 "SELECTED_MODULE_NAME" 3 times.
Open

        $viewer->assign('SELECTED_MODULE_NAME', $sourceModule);

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.

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

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

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.

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

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

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.

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('SELECTED_PICKLIST_FIELDMODEL', $fieldModel);

Call to undeclared method \Vtiger_Viewer::assign
Open

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

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('SELECTED_PICKLISTFIELD_ALL_VALUES', $selectedFieldAllPickListValues);

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('PICKLIST_FIELDS', $pickListFields);

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('ROLES_LIST', Settings_Roles_Record_Model::getAll());

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('PICKLIST_INTERDEPENDENT', $moduleModel->listModuleInterdependentPickList(array_keys($pickListFields)));

Call to undeclared method \Vtiger_Viewer::assign
Open

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

Call to undeclared method \Vtiger_Viewer::assign
Open

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

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('SELECTED_MODULE_NAME', $sourceModule);

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('SELECTED_MODULE_NAME', $sourceModule);

Argument 1 (roleIdList) is array{0:bool|mixed} but \Settings_Picklist_Field_Model::getPicklistValuesForRole() takes \type defined at /code/modules/Settings/Picklist/models/Field.php:51
Open

        $pickListValuesForRole = $fieldModel->getPicklistValuesForRole([$userSelectedRoleId], 'CONJUNCTION');

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('ROLE_PICKLIST_VALUES', $pickListValuesForRole);

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('ALL_PICKLIST_VALUES', $allPickListValues);

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('SELECTED_MODULE_NAME', $sourceModule);

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('SELECTED_PICKLIST_FIELDMODEL', $fieldModel);

Call to undeclared method \Vtiger_Viewer::assign
Open

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

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

        $pickListValuesForRole = $fieldModel->getPicklistValuesForRole([$userSelectedRoleId], 'CONJUNCTION');

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

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

        $selectedFieldAllPickListValues = [];

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_Picklist_IndexAjax_View extends Settings_Vtiger_IndexAjax_View

The class Settings_Picklist_IndexAjax_View is not named in CamelCase.
Open

class Settings_Picklist_IndexAjax_View extends Settings_Vtiger_IndexAjax_View
{
    use \App\Controller\ExposeMethod;

    /**

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

        $viewer = $this->getViewer($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

        $sourceModule = $request->getByType('source_module', \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

     * Get picklist details for module.

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

    public function getPickListDetailsForModule(App\Request $request)

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

        $moduleModel = Settings_Picklist_Module_Model::getInstance($qualifiedName)->setSourceModule($sourceModule);

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

     * Get picklist values for field.

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

    public function __construct()

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('source_module', 2);

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

    /**

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

        $this->exposeMethod('getPickListValueForField');

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

    use \App\Controller\ExposeMethod;

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

            $selectedFieldAllPickListValues = App\Fields\Picklist::getValuesName($fieldModel->getName());

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

    {

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

        $fieldModel = null;

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

    /**

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

    public function getPickListValueByRole(App\Request $request)

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

        $fieldModel = Settings_Picklist_Field_Model::getInstance($pickFieldName, Vtiger_Module_Model::getInstance($sourceModule));

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

        $viewer->assign('ROLES_LIST', Settings_Roles_Record_Model::getAll());

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

        $this->exposeMethod('getPickListDetailsForModule');

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

        $viewer->assign('SELECTED_PICKLIST_FIELDMODEL', $fieldModel);

Line exceeds 120 characters; contains 134 characters
Open

            $fieldModel = Settings_Picklist_Field_Model::getInstance($pickFieldName, Vtiger_Module_Model::getInstance($sourceModule));

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

        $allPickListValues = App\Fields\Picklist::getValuesName($fieldModel->getName());

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

    }

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('QUALIFIED_MODULE', $qualifiedName);

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

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

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

            $fieldModel = Settings_Picklist_Field_Model::getInstance($pickFieldName, Vtiger_Module_Model::getInstance($sourceModule));

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

     * Get picklist value by role.

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('SELECTED_MODULE_NAME', $sourceModule);

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

     *

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

        $this->exposeMethod('getPickListValueByRole');

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

        $pickListFields = $moduleModel->getFieldsByType(['picklist', 'multipicklist'], 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

     * @param App\Request $request

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

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

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

        $pickListValuesForRole = $fieldModel->getPicklistValuesForRole([$userSelectedRoleId], 'CONJUNCTION');

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

    public function getPickListValueForField(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('SELECTED_PICKLISTFIELD_ALL_VALUES', $selectedFieldAllPickListValues);

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

        $viewer->assign('ROLE_PICKLIST_VALUES', $pickListValuesForRole);

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

        $viewer->assign('SELECTED_PICKLIST_FIELDMODEL', $fieldModel);

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

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

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

        $viewer->assign('SELECTED_MODULE_NAME', $sourceModule);

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

        $viewer->assign('ALL_PICKLIST_VALUES', $allPickListValues);

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

     * Constructor.

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('SELECTED_MODULE_NAME', $sourceModule);

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

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

Line exceeds 120 characters; contains 130 characters
Open

        $fieldModel = Settings_Picklist_Field_Model::getInstance($pickFieldName, Vtiger_Module_Model::getInstance($sourceModule));

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

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

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

        $viewer->assign('PICKLIST_FIELDS', $pickListFields);

Line exceeds 120 characters; contains 128 characters
Open

        $viewer->assign('PICKLIST_INTERDEPENDENT', $moduleModel->listModuleInterdependentPickList(array_keys($pickListFields)));

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

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

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

        if (!empty($pickFieldName)) {

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

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

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

        $pickFieldName = $request->getByType('picklistName', \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

        $viewer->view('PickListValueDetail.tpl', $qualifiedName);

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

        parent::__construct();

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

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

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

        $viewer->assign('PICKLIST_INTERDEPENDENT', $moduleModel->listModuleInterdependentPickList(array_keys($pickListFields)));

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

        $viewer->view('ModulePickListDetail.tpl', $qualifiedName);

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

        $selectedFieldAllPickListValues = [];

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

        $viewer->view('PickListValueByRole.tpl', $qualifiedName);

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

class Settings_Picklist_IndexAjax_View extends Settings_Vtiger_IndexAjax_View

There are no issues that match your filters.

Category
Status