Back to questions
JuniorDebuggingCommon
Which line of this procedure breaks the 1C standards?
Процедура ПроверитьОстаток(Остаток, ЕстьОшибки)
Если ЕстьОшибки = Истина Тогда
Возврат;
КонецЕсли;
ЕстьОшибки = Остаток < 0;
КонецПроцедурыLine 2: a boolean is compared with Истина
- Taking the direct assignment
ЕстьОшибки = Остаток < 0for a violation: the standards allow it and forbid the comparison withИстина - Writing
Если Флаг = Истинаto make the condition clearer: the boolean already is the condition, and standard #441 forbids the comparison
- How do you check that
ЕстьОшибкиis false without comparing it withЛожь? - Which tool checks 1C code against the standards automatically?
A boolean already is a condition, so the comparison with Истина is redundant and breaks standard #441. The fixed procedure:
Процедура ПроверитьОстаток(Остаток, ЕстьОшибки)
Если ЕстьОшибки Тогда
Возврат;
КонецЕсли;
ЕстьОшибки = Остаток < 0;
КонецПроцедуры