From: Alexander Turenko via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Sergey Bronnikov <sergeyb@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH v2] tools: fix luacheck invocation in different cases
Date: Thu, 25 Feb 2021 19:35:52 +0300 [thread overview]
Message-ID: <20210225163552.qzsjgz6t7rjld7zl@tkn_work_nb> (raw)
In-Reply-To: <47b923aa-6d73-451b-169f-ea0c0e48f628@tarantool.org>
> > +if (BINARY_DIR_INSIDE_SOURCE_DIR)
>
> extra whitespace after "if"
To be honest, it was always unclear for me, which style is right and I
just tried to be consistent with the surrounding code.
For CMakeLists.txt (this file, on master):
| $ grep '\bif(' CMakeLists.txt | wc -l
| 10
| $ grep '\bif (' CMakeLists.txt | wc -l
| 22
For tarantool at whole:
| $ find . -name CMakeLists.txt -not -path '*third_party*' -or -name '*.cmake' -not -path '*third_party*' -print | xargs -I {} grep '\bif(' {} | wc -l
| 74
| $ find . -name CMakeLists.txt -not -path '*third_party*' -or -name '*.cmake' -not -path '*third_party*' -print | xargs -I {} grep '\bif (' {} | wc -l
| 163
For CMake built-in modules:
| $ find /usr/share/cmake/Modules -name '*.cmake' -print | xargs -I {} grep '\bif(' {} | wc -l
| 5752
| $ find /usr/share/cmake/Modules -name '*.cmake' -print | xargs -I {} grep '\bif (' {} | wc -l
| 1492
What the world think:
* CMake follows `if()` style in its docs ([1]).
* WebKit agreed on using `if ()` ([2]).
* cmakelint ([3]) requires `if()`.
* polysquare-cmake-linter ([4]) requires `if ()`.
* cmake-lint from cmake_format ([5]) does not complain about any variant
by default, but the default config has the
`separate_ctrl_name_with_space` option (False). Bug?
(JFYI: CMake autoformatter / linter issue: [6].)
If we'll attempt to apply some common sense:
1. `if()` is consistent with `else()` and `endif()`.
2. `if ()` looks usual for a C developer (visual differentiation of
control flow constructions from function calls).
So, to be honest, I still don't know. There is no general rule neither
in tarantool, nor in the world. There is no good choice, because of the
language syntax.
My personal preference is `if ()`, because it differentiates control
flow constructions from macro / function calls (that's usual in C).
[1]: https://cmake.org/cmake/help/latest/command/if.html
[2]: http://trac.webkit.org/changeset/136790/webkit
[3]: https://github.com/cmake-lint/cmake-lint
[4]: https://github.com/polysquare/polysquare-cmake-linter
[5]: https://github.com/cheshirekow/cmake_format
[6]: https://gitlab.kitware.com/cmake/cmake/-/issues/17441
next prev parent reply other threads:[~2021-02-25 16:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-18 16:09 Alexander Turenko via Tarantool-patches
2021-02-25 11:59 ` Sergey Bronnikov via Tarantool-patches
2021-02-25 16:35 ` Alexander Turenko via Tarantool-patches [this message]
2021-02-26 9:25 ` Sergey Bronnikov via Tarantool-patches
2021-02-26 18:11 ` Igor Munkin via Tarantool-patches
2021-03-03 18:02 ` Alexander Turenko via Tarantool-patches
2021-03-04 22:21 ` Igor Munkin via Tarantool-patches
2021-03-05 3:50 ` Alexander Turenko via Tarantool-patches
2021-03-05 20:04 ` Alexander Turenko via Tarantool-patches
2021-03-05 23:24 ` Igor Munkin via Tarantool-patches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210225163552.qzsjgz6t7rjld7zl@tkn_work_nb \
--to=tarantool-patches@dev.tarantool.org \
--cc=alexander.turenko@tarantool.org \
--cc=sergeyb@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH v2] tools: fix luacheck invocation in different cases' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox