-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add clang-format #291
base: main
Are you sure you want to change the base?
Add clang-format #291
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I'd like to do a couple more iterations.
src/DbConnection.cpp
Outdated
bool DbConnection::is_valid() { | ||
return !!get_conn(); | ||
} | ||
bool DbConnection::is_valid() { return !!get_conn(); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather avoid braces on a single line.
_["thread.id"] = (int) mysql_thread_id(pConn_) | ||
); | ||
_["protocol.version"] = (int)mysql_get_proto_info(pConn_), | ||
_["thread.id"] = (int)mysql_thread_id(pConn_)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move the closing paren );
to the next line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feature will be added to clang-format. Seems now doesn't exists.
src/DbConnection.cpp
Outdated
|
||
if (pCurrentResult_ != NULL) { | ||
if (pResult != NULL) | ||
warning("Cancelling previous query"); | ||
if (pResult != NULL) warning("Cancelling previous query"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to always add braces, but keep it on a new line.
const Nullable<std::string>& password, | ||
const Nullable<std::string>& db, unsigned int port, | ||
const Nullable<std::string>& unix_socket, | ||
unsigned long client_flag, const Nullable<std::string>& groups, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we ensure that each argument gets its own line in these cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think now it's not possible. Clang-format add new line if arguments are to long, but it doesn't check the context of this lines.
src/MariaBinding.cpp
Outdated
case MY_INT64: | ||
binding_update(j, MYSQL_TYPE_LONGLONG, 0); | ||
break; | ||
case MY_LGL: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original indent was fine.
src/MariaBinding.h
Outdated
@@ -16,17 +17,17 @@ class MariaBinding : public boost::noncopyable { | |||
std::vector<MariaFieldType> types; | |||
std::vector<MYSQL_TIME> time_buffers; | |||
|
|||
public: | |||
public: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Single-space indent for access modifiers looks awkward, but I'm willing to be convinced otherwise.
src/MariaResult.cpp
Outdated
#include "MariaResultPrep.h" | ||
#include "MariaResultSimple.h" | ||
|
||
#include "pch.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did the "include" move? The pch.h
include must come first here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clang-format reordering header includes by some rules. But I think it's more general question. Seems pch.h
is not "real" precompiled header, it's more like general include.
But it cause to problem with order of includes, so if order is changes then build is failing.
Maybe it is make sense to fix includes, that they do not depend on the order?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could specify IncludeCategories
so that pch.h
is always sorted first?
Found useful tool to check configurations of clang-format: https://zed0.co.uk/clang-format-configurator/ |
Can we try https://clangpowertools.com/clang-format-editor.html on the main branch? |
We also want |
No description provided.