BSL266 — Using parameter "Cancel"¶
Summary¶
Using parameter "Cancel"
Identifiers¶
| Field | Value |
|---|---|
| Rule code | BSL266 |
| Compatible alias | UsingCancelParameter |
| Severity | WARNING |
| Enabled by default | Yes |
| Implemented | Yes |
| Tags | correctness, events |
Behavior¶
- The public identifier
BSL266and aliasUsingCancelParameterare 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.
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:
bsl-disable:
- compatible
BSLLSform:
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: BSL266
// code without this diagnostic
// noqa-enable: BSL266
// bsl-disable: BSL266
// code without this diagnostic
// bsl-enable: BSL266
// BSLLS:UsingCancelParameter-off
// code without this diagnostic
// BSLLS:UsingCancelParameter-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 event handlers of object's modules, record sets, forms and etc. using parameter "Cancel" (for example BeforeWrite and etc.) it should not be assigned value "false". This is due to the fact, that in code of event handlers the parameter "Cancel" can be set in several consecutive checks (or in several subscriptions on the same event). In this case, by the time the next check is performed, the Cancel parameter may already contain the True value, and you can erroneously reset it back to False. In addition, with configuration improvements, the number of these checks may increase.
Examples¶
Incorrect¶
Correct¶
or