Rewrite method parameter (RewriteMethodParameter)¶
Type | Scope | Severity | Activated by default |
Minutes to fix |
Tags |
---|---|---|---|---|---|
Code smell |
BSL OS |
Major |
Yes |
2 |
suspicious |
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
Sources¶
Diagnostic ignorance in code¶
// BSLLS:RewriteMethodParameter-off
// BSLLS:RewriteMethodParameter-on
Parameter for config¶
"RewriteMethodParameter": false