Conversation
7554f92 to
e545785
Compare
3212cc4 to
3592572
Compare
|
I'd love to have a better visual separation between c'tor member initializer lists and c'tor code. E.g.: Current: Channel_Impl_13::Channel_Impl_13(const std::shared_ptr<Callbacks>& callbacks,
const std::shared_ptr<Session_Manager>& session_manager,
const std::shared_ptr<Credentials_Manager>& credentials_manager,
const std::shared_ptr<RandomNumberGenerator>& rng,
const std::shared_ptr<const Policy>& policy,
bool is_server) :
m_side(is_server ? Connection_Side::Server : Connection_Side::Client),
m_callbacks(callbacks),
m_session_manager(session_manager),
m_credentials_manager(credentials_manager),
m_rng(rng),
m_policy(policy),
m_record_layer(m_side),
m_handshake_layer(m_side),
m_can_read(true),
m_can_write(true),
m_opportunistic_key_update(false),
m_first_message_sent(false),
m_first_message_received(false) {
BOTAN_ASSERT_NONNULL(m_callbacks);
BOTAN_ASSERT_NONNULL(m_session_manager);
BOTAN_ASSERT_NONNULL(m_credentials_manager);
BOTAN_ASSERT_NONNULL(m_rng);
BOTAN_ASSERT_NONNULL(m_policy);
}Ideas
Channel_Impl_13::Channel_Impl_13(/* ... */) :
/* ... */
m_opportunistic_key_update(false),
m_first_message_sent(false),
m_first_message_received(false) {
BOTAN_ASSERT_NONNULL(m_callbacks);
BOTAN_ASSERT_NONNULL(m_session_manager);
/* ... */
}
Channel_Impl_13::Channel_Impl_13(/* ... */)
: m_side(is_server ? Connection_Side::Server : Connection_Side::Client)
/* ... */
, m_opportunistic_key_update(false)
, m_first_message_sent(false)
, m_first_message_received(false) {
BOTAN_ASSERT_NONNULL(m_callbacks);
BOTAN_ASSERT_NONNULL(m_session_manager);
/* ... */
} |
reneme
left a comment
There was a problem hiding this comment.
I like the more compact style!
Apart from the suggestions above, I didn't stumble over any big annoyances. Thanks for the effort!
30ed230 to
c85c79d
Compare
6049c14 to
9324ff9
Compare
d242236 to
88033d6
Compare
|
The Windows amalgamation does not work. |
88033d6 to
48907e2
Compare
|
We should probably all agree on a concrete clang-format version to use, otherwise the CI validation could become annoying. clang-format being a developer tool, I think it should be as new as possible. E.g. support for C++20 concepts is basically non-extistent before clang-format 15 and leaves a lot to be desired in clang-format 16. 😢 My suggestion: Let's stick with 15, as this is available in Ubuntu 22.04. Particularly, for the Suggestion: Add
|
|
Here's are a few wishes: Visual separation of declaration and implementationIf the parameter list is floating to the next line (e.g. due to long function names), its hard to visually see where the function implementation starts: std::vector<X509_Certificate> search_cert_stores(
const _CRYPTOAPI_BLOB& blob,
const DWORD& find_type,
std::function<bool(const std::vector<X509_Certificate>& certs, const X509_Certificate& cert)>
filter,
bool return_on_first_found) {
std::vector<X509_Certificate> certs;
for(const auto store_name : cert_store_names) {
// [...]
}
return certs;
}Suggestion 1: Indent "continuation lines" further
std::vector<X509_Certificate> search_cert_stores(
const _CRYPTOAPI_BLOB& blob,
const DWORD& find_type,
std::function<bool(const std::vector<X509_Certificate>& certs, const X509_Certificate& cert)>
filter,
bool return_on_first_found) {
std::vector<X509_Certificate> certs;
for(const auto store_name : cert_store_names) {
// [...]
}
return certs;
}Suggestion 2: Add newline before braces of declarationsstd::vector<X509_Certificate> search_cert_stores(
const _CRYPTOAPI_BLOB& blob,
const DWORD& find_type,
std::function<bool(const std::vector<X509_Certificate>& certs, const X509_Certificate& cert)>
filter,
bool return_on_first_found)
{
std::vector<X509_Certificate> certs;
for(const auto store_name : cert_store_names) {
// [...]
}
return certs;
}Suggestion 3: Do both of the aboveThat's my preference, as it emphasizes this visual separation the most. std::vector<X509_Certificate> search_cert_stores(
const _CRYPTOAPI_BLOB& blob,
const DWORD& find_type,
std::function<bool(const std::vector<X509_Certificate>& certs, const X509_Certificate& cert)>
filter,
bool return_on_first_found)
{
std::vector<X509_Certificate> certs;
for(const auto store_name : cert_store_names) {
// [...]
}
return certs;
} |
|
One minor thing: |
This seems fine but tbh I would think any time a parameter type is so long that it can't fit on a single line, it should be a typedef
TBH I find that just as verbose as the current style, but harder to parse
I find these to be just kind of noisy without much benefit, but maybe that's just because emacs always shows what the matching start of the block is anyway (though I would think any other editor would do the same??). Not totally adverse to it just wondering what I am missing. |
Right now the formatter script refuses to run on anything other than
I'll add these |
|
Also, as a general comment - any formatter is not going to do the right thing some proportion of the time. Even in Rust where the language and formatter are co-evolved, Which is one reason I have avoided using a formatter in the past, because with careful hand formatting the result is always cleaner. But less consistent, especially as more people contribute, so this approach does not scale so well. The only real fix is to accept that the initial automatic formatting is, no matter what configuration we use, not going to be ideal, and that for best readability it will be required to reformulate some code. New code, being written with the formatter in place, will more naturally co-evolve with the limitations of the formatter. |
I couldn't agree more on the typedef. And admittedly, I have a hard time finding a bunch of other examples to back this argument. Let's leave as is then. 👍
Typically,
Let's fix it! 😄 |
caee2c9 to
3f87e1e
Compare
#3499