Skip to content

BSL237 — Redundant access to an object

Summary

Redundant access to an object

Identifiers

Field Value
Rule code BSL237
Compatible alias RedundantAccessToObject
Severity INFORMATION
Enabled by default Yes
Implemented Yes
Tags redundant, performance

Behavior

  • The public identifier BSL237 and alias RedundantAccessToObject are stable.
  • The rule reports the cases documented on this page.
  • Suppressions and project configuration are applied before publication.
  • The rule requires neither an external analyzer nor network access.

Configuration and suppression

BSL### is the primary stable identifier. The compatible alias is accepted in select, ignore, and compatible block suppression comments.

[tool.onec-hbk-bsl]
select = ["BSL237"]
ignore = ["RedundantAccessToObject"]

All three suppression families support both a current line and a range. When an opening comment follows code, it affects only that line. Use any one form:

  • noqa:
Value = "example";  // noqa: BSL237
  • bsl-disable:
Value = "example";  // bsl-disable: BSL237
  • compatible BSLLS form:
Value = "example";  // BSLLS:RedundantAccessToObject-off

When the same opening comment is on a line by itself, it starts a range. Close it with the matching marker from the same family:

// noqa: BSL237
// code without this diagnostic
// noqa-enable: BSL237

// bsl-disable: BSL237
// code without this diagnostic
// bsl-enable: BSL237

// BSLLS:RedundantAccessToObject-off
// code without this diagnostic
// BSLLS:RedundantAccessToObject-on

To disable the rule until the end of the file, omit the closing noqa-enable, bsl-enable, or BSLLS:…-on marker.

Opening and closing markers must belong to the same family.

Description

In the forms and modules of objects, it is wrong to refer to the attributes through the property ThisObject. In common modules, it is redundant to refer to methods through their name, except for modules with Cashed.

Examples

In the ObjectModule of the Document with the attribute Countractor, it is wrong to use

ThisObject.Contractor = GetContractor();

correctly use the props directly

Contractor = GetContractor();

In the common module Commons, the following method call will be incorrect

Commons.SendMessage("en = 'Hi!'");

correct

SendMessage("en = 'Hi!'");