Mailing List Archive

Inconsistencies in code recommendations regarding if/else bodies
For quite some time now ctidy has been
reporting:

"warning: statement should be inside braces
[readability-braces-around-statements]"

and various codes in the project have been
updated accordingly.

HOWEVER, in the coding standards
documentation at:

https://www.mythtv.org/wiki/Coding_Standards

it explicitly says:

"One-line if or else bodies do not need braces."

Since this would appear to be a change in the
projects coding standards (it now does need
the braces?), the person who made that change
should likely update the wiki (or the ctidy checks
if the braces are still not a hard requirement) so
that future contributors know how to properly
write their code.

Thanks.
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Inconsistencies in code recommendations regarding if/else bodies [ In reply to ]
On Sat, 2020-08-29 at 16:24 +0000, Gary Buhrmaster wrote:
> For quite some time now ctidy has been
> reporting:
>
> "warning: statement should be inside braces
> [readability-braces-around-statements]"
>
> and various codes in the project have been
> updated accordingly.
>
> HOWEVER, in the coding standards
> documentation at:
>
> https://www.mythtv.org/wiki/Coding_Standards
>
> it explicitly says:
>
> "One-line if or else bodies do not need braces."
>
> Since this would appear to be a change in the
> projects coding standards (it now does need
> the braces?), the person who made that change
> should likely update the wiki (or the ctidy checks
> if the braces are still not a hard requirement) so
> that future contributors know how to properly
> write their code.

Tidy is set to only complains about missing braces if the if/else body
is three or more lines long. I've had it remove braces as well as add
braces. In today's commit I believe it was a couple of intervening
conditional compilation statements that caused tidy to recommend the
braces.

David


_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Inconsistencies in code recommendations regarding if/else bodies [ In reply to ]
On Sat, Aug 29, 2020 at 4:33 PM David Hampton <mythtv@love2code.net> wrote:

> Tidy is set to only complains about missing braces if the if/else body
> is three or more lines long. I've had it remove braces as well as add
> braces. In today's commit I believe it was a couple of intervening
> conditional compilation statements that caused tidy to recommend the
> braces.

Good information. I am sure the updated wiki
will provide the proper guidance going forward.
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org