Nested constructors with parameters in structure declaration (NestedConstructorsInStructureDeclaration)¶
Type | Scope | Severity | Activated by default |
Minutes to fix |
Tags |
---|---|---|---|---|---|
Code smell |
BSL OS |
Minor |
Yes |
10 |
badpractice brainoverload |
Description¶
It is not recommended to use constructors of other objects in the structure constructor if these constructors accept parameters. In particular, in the constructor of one structure it is not recommended to create other structures with the declaration of property values.
Examples¶
Incorrect
GoodsServer.MakeGoods(
Object.Products,
New Structure(
"CharacteristicsUsed,
|Type, Variant",
New Structure("Good", "CharacteristicsUsed"),
New Structure("Good", "Type"),
New Structure("Good", "Variant")
)
);
Correct
Parameters = New Structure;
Parameters.Вставить("CharacteristicsUsed", New Structure("Good", "CharacteristicsUsed"));
Parameters.Вставить("Type", New Structure("Good", "Type"));
Parameters.Вставить("Variant", New Structure("Good", "Variant"));
GoodsServer.MakeGoods(Object.Products, Parameters);
Snippets¶
Diagnostic ignorance in code¶
// BSLLS:NestedConstructorsInStructureDeclaration-off
// BSLLS:NestedConstructorsInStructureDeclaration-on
Parameter for config¶
"NestedConstructorsInStructureDeclaration": false