BSL240 — Rewrite method parameter¶
Summary¶
Rewrite method parameter
Identifiers¶
| Field | Value |
|---|---|
| Rule code | BSL240 |
| Compatible alias | RewriteMethodParameter |
| Severity | WARNING |
| Enabled by default | Yes |
| Implemented | Yes |
| Tags | suspicious, correctness |
Behavior¶
- The public identifier
BSL240and aliasRewriteMethodParameterare 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: BSL240
// code without this diagnostic
// noqa-enable: BSL240
// bsl-disable: BSL240
// code without this diagnostic
// bsl-enable: BSL240
// BSLLS:RewriteMethodParameter-off
// code without this diagnostic
// BSLLS:RewriteMethodParameter-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¶
It is wrong to write methods in which their arguments are overwritten immediately on entry.
It is necessary to correct this deficiency by removing the parameters, converting them to local variables.
Examples¶
Suspicious code
Procedure Configor(Val ConnectionString, Val User = "", Val Pass = "") Export
ConnectionString = "/F""" + DataBaseDir + """"; // Error
...
EndProcedure
Сorrected:
Procedure Configor(Val DataBaseDir, Val User = "", Val Pass = "") Export
ConnectionString = "/F""" + DataBaseDir + """"; // No error
...
EndProcedure
Procedure Configor(Val DataBaseDir, Val User = "", Val Pass = "") Export
If Not EmpyString(DataBaseDir) Then
NewConnectionString = "/F""" + DataBaseDir + """";
Else
NewConnectionString = ConnectionString; // Hmm, where is this from?
EndIf;
...
EndProcedure