Hi,
On 16-07-2026 11:14, Marc Mutz via Development wrote:
Hi,
The current style guide¹ asks for attached braces on if statements,
incl. when the if condition spans multiple lines (#6):
// Correct if (address.isEmpty() || !isValid() || !codec) { return
false; }
I've been bothered by this for years, since I think this is totally
unreadable. In particular, if the last line of the if is on the longer
side, the body of the then branch is almost impossible to distinguish
from a continuation of the condition.
I would therefore like to propose to allow placing the opening brace
on a separate line if the if condition is multi-line:
// (now also) Correct if (address.isEmpty() || !isValid() || !codec) {
return false; }
I agree. I find this more readable. But I would prefer to have logical
groups of the condition be either broken one per line, or all on the
same line. So:
// Correct
if (address.isEmpty() || !isValid() || !codec) {
return false;
}
or
// (now also) Correct
if (address.isEmpty()
|| !isValid()
|| !codec)
{
return false;
}
But also this:
// (now also) Correct
if ((address.isEmpty() && !isValid())
|| !codec)
{
return false;
}
Cheers,
André
--
Development mailing list
[email protected]
https://lists.qt-project.org/listinfo/development