|
3 | 3 | <!-- Блоки выше заполняются автоматически, не трогать -->
|
4 | 4 | ## Description
|
5 | 5 | <!-- Описание диагностики заполняется вручную. Необходимо понятным языком описать смысл и схему работу -->
|
| 6 | +It is wrong to write methods in which their arguments are overwritten immediately on entry. |
| 7 | + |
| 8 | +It is necessary to correct this deficiency by removing the parameters, converting them to local variables. |
6 | 9 |
|
7 | 10 | ## Examples
|
8 | 11 | <!-- В данном разделе приводятся примеры, на которые диагностика срабатывает, а также можно привести пример, как можно исправить ситуацию -->
|
| 12 | +Suspicious code |
| 13 | +```bsl |
| 14 | +Procedure Configor(Val ConnectionString, Val User = "", Val Pass = "") Export |
| 15 | + ConnectionString = "/F""" + DataBaseDir + """"; // Error |
| 16 | +... |
| 17 | +EndProcedure |
| 18 | +``` |
| 19 | + |
| 20 | +Сorrected: |
| 21 | +```bsl |
| 22 | +Procedure Configor(Val DataBaseDir, Val User = "", Val Pass = "") Export |
| 23 | +ConnectionString = "/F""" + DataBaseDir + """"; // No error |
| 24 | +... |
| 25 | +EndProcedure |
| 26 | +``` |
| 27 | +or |
| 28 | +```bsl |
| 29 | +Procedure Configor(Val DataBaseDir, Val User = "", Val Pass = "") Export |
| 30 | + If Not EmpyString(DataBaseDir) Then |
| 31 | +NewConnectionString = "/F""" + DataBaseDir + """"; |
| 32 | +Else |
| 33 | +NewConnectionString = ConnectionString; // Hmm, where is this from? |
| 34 | +EndIf; |
| 35 | +
|
| 36 | +... |
| 37 | +EndProcedure |
| 38 | +``` |
9 | 39 |
|
10 | 40 | ## Sources
|
11 | 41 | <!-- Необходимо указывать ссылки на все источники, из которых почерпнута информация для создания диагностики -->
|
12 | 42 | <!-- Примеры источников
|
13 | 43 |
|
14 |
| -* Источник: [Стандарт: Тексты модулей](https://its.1c.ru/db/v8std#content:456:hdoc) |
15 |
| -* Полезная информация: [Отказ от использования модальных окон](https://its.1c.ru/db/metod8dev#content:5272:hdoc) |
16 |
| -* Источник: [Cognitive complexity, ver. 1.4](https://www.sonarsource.com/docs/CognitiveComplexity.pdf) --> |
| 44 | +* [PVS-Studio V763. Parameter is always rewritten in function body before being used](https://pvs-studio.com/ru/docs/warnings/v6023) |
0 commit comments