Skip to content

IsInRole global method call (IsInRoleMethod)

Type Scope Severity Activated
by default
Minutes
to fix
Tags
Code smell BSL Major Yes 5 error

Description

To check access rights in the code, use the AccessRight method.

When a role does not grant access rights to metadata objects and defines an additional access right only, use the IsInRole method.

If Standard Subsystems Library is used in a configuration, use the RolesAvailable function of the Users common module, otherwise IsInRole method call must be combined with PrivilegedMode() method call. If Standard Subsystems Library is used in a configuration, use the RolesAvailable() function of the Users common module, otherwise IsInRole() method call must be combined with PrivilegedMode() method call.

Examples

Wrong:

If RolesAvailable("AddingChangingCountriesWorld") Then...
If RolesAvailable("ViewPopularCountriesReport") Then ...
Correct:
If AccessRight("Edit", Metadata.Catalogs.WorldCountries) Then ...
If AccessRight("View", Metadata.Reports.PopularCountries) Then ...
Wrong:
If RolesAvailable("Treasurer") Then...
Сorrect:
If IsInRole("Treasurer") OR PrivilegedMode() Then ...

Sources

Snippets

Diagnostic ignorance in code

// BSLLS:IsInRoleMethod-off
// BSLLS:IsInRoleMethod-on

Parameter for config

"IsInRoleMethod": false