From 4dc7dbb4e68bac9e2d8d0cff241c002cbb46c6eb Mon Sep 17 00:00:00 2001 From: tastytea Date: Mon, 27 Jan 2020 01:08:45 +0100 Subject: [PATCH 1/5] CMake: We are already in the build directory. --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4db25d3..7ab4dba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,7 +33,6 @@ include(debug_flags) if(WITH_CLANG-TIDY) set(CMAKE_CXX_CLANG_TIDY "clang-tidy" - "-p=build" "-header-filter=${PROJECT_SOURCE_DIR}" "-quiet") endif() From 56cabf48a8a0c58e683b531453266f92c0ed6ca5 Mon Sep 17 00:00:00 2001 From: tastytea Date: Mon, 27 Jan 2020 01:09:20 +0100 Subject: [PATCH 2/5] Add clang-tidy exceptions for http_method. --- include/curl_wrapper.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/curl_wrapper.hpp b/include/curl_wrapper.hpp index f72847e..7674478 100644 --- a/include/curl_wrapper.hpp +++ b/include/curl_wrapper.hpp @@ -39,11 +39,11 @@ using std::string_view; */ enum class http_method { - GET, - POST, - PATCH, - PUT, - DELETE + GET, // NOLINT(readability-identifier-naming) + POST, // NOLINT(readability-identifier-naming) + PATCH, // NOLINT(readability-identifier-naming) + PUT, // NOLINT(readability-identifier-naming) + DELETE // NOLINT(readability-identifier-naming) }; /*! From 2bbead14e5ff7fce95fc0426e54c4959dea1d05e Mon Sep 17 00:00:00 2001 From: tastytea Date: Mon, 27 Jan 2020 03:19:47 +0100 Subject: [PATCH 3/5] Add .clang-tidy. --- .clang-tidy | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .clang-tidy diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000..447c4dd --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,41 @@ +# -*- mode: conf; fill-column: 100; -*- +# Written for clang-tidy 9. + +--- +Checks: '*, + -cppcoreguidelines-non-private-member-variables-in-classes, + -fuchsia-default-arguments-calls, + -fuchsia-default-arguments, + -llvm-include-order, + -llvm-header-guard, + -misc-non-private-member-variables-in-classes, + -fuchsia-overloaded-operator, + -cppcoreguidelines-avoid-magic-numbers, + -readability-magic-numbers, + -cppcoreguidelines-pro-bounds-array-to-pointer-decay, + -hicpp-no-array-decay, + -modernize-avoid-c-arrays, + -cppcoreguidelines-avoid-c-arrays, + -hicpp-avoid-c-arrays, + -google-build-using-namespace, + -readability-named-parameter, + -google-runtime-references, + -hicpp-avoid-goto, + -hicpp-vararg, + -fuchsia-statically-constructed-objects, + -google-readability-todo, + -modernize-use-trailing-return-type' +CheckOptions: - { key: readability-identifier-naming.ClassCase, value: CamelCase } + # Clashes with constant private member prefix. (const int _var;) + # - { key: readability-identifier-naming.ConstantCase, value: lower_case } + - { key: readability-identifier-naming.EnumCase, value: lower_case } + - { key: readability-identifier-naming.FunctionCase, value: lower_case } + - { key: readability-identifier-naming.MemberCase, value: lower_case } + - { key: readability-identifier-naming.NamespaceCase, value: lower_case } + - { key: readability-identifier-naming.ParameterCase, value: lower_case } + - { key: readability-identifier-naming.PrivateMemberCase, value: lower_case } + - { key: readability-identifier-naming.PrivateMemberPrefix, value: _ } + - { key: readability-identifier-naming.StructCase, value: lower_case } + # Clashes with static private member prefix. (static int _var;) + # - { key: readability-identifier-naming.VariableCase, value: lower_case } +... From cdd7a465d225de631c72f5cf9bf11f026e4ca286 Mon Sep 17 00:00:00 2001 From: tastytea Date: Tue, 28 Jan 2020 08:03:16 +0100 Subject: [PATCH 4/5] Update .clang-tidy. --- .clang-tidy | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 447c4dd..97007d9 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -5,6 +5,7 @@ Checks: '*, -cppcoreguidelines-non-private-member-variables-in-classes, -fuchsia-default-arguments-calls, + -fuchsia-default-arguments-declarations, -fuchsia-default-arguments, -llvm-include-order, -llvm-header-guard, @@ -25,17 +26,18 @@ Checks: '*, -fuchsia-statically-constructed-objects, -google-readability-todo, -modernize-use-trailing-return-type' -CheckOptions: - { key: readability-identifier-naming.ClassCase, value: CamelCase } +CheckOptions: - { key: readability-identifier-naming.ClassCase, value: CamelCase } # Clashes with constant private member prefix. (const int _var;) - # - { key: readability-identifier-naming.ConstantCase, value: lower_case } - - { key: readability-identifier-naming.EnumCase, value: lower_case } - - { key: readability-identifier-naming.FunctionCase, value: lower_case } - - { key: readability-identifier-naming.MemberCase, value: lower_case } - - { key: readability-identifier-naming.NamespaceCase, value: lower_case } - - { key: readability-identifier-naming.ParameterCase, value: lower_case } - - { key: readability-identifier-naming.PrivateMemberCase, value: lower_case } - - { key: readability-identifier-naming.PrivateMemberPrefix, value: _ } - - { key: readability-identifier-naming.StructCase, value: lower_case } + # - { key: readability-identifier-naming.ConstantCase, value: lower_case } + - { key: readability-identifier-naming.EnumCase, value: lower_case } + - { key: readability-identifier-naming.FunctionCase, value: lower_case } + - { key: readability-identifier-naming.MemberCase, value: lower_case } + - { key: readability-identifier-naming.ParameterCase, value: lower_case } + - { key: readability-identifier-naming.PrivateMemberCase, value: lower_case } + - { key: readability-identifier-naming.PrivateMemberPrefix, value: _ } + - { key: readability-identifier-naming.ProtextedMemberCase, value: lower_case } + - { key: readability-identifier-naming.ProtectedMemberPrefix, value: _ } + - { key: readability-identifier-naming.StructCase, value: lower_case } # Clashes with static private member prefix. (static int _var;) - # - { key: readability-identifier-naming.VariableCase, value: lower_case } + # - { key: readability-identifier-naming.VariableCase, value: lower_case } ... From 185ab919784d7646d114e04bce187f60a7094e6d Mon Sep 17 00:00:00 2001 From: tastytea Date: Tue, 28 Jan 2020 08:11:56 +0100 Subject: [PATCH 5/5] =?UTF-8?q?Rename=20buffer=5Fmutex=20=E2=86=92=20=5Fbu?= =?UTF-8?q?ffer=5Fmutex.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/curl_wrapper.hpp | 2 +- src/connection.cpp | 8 ++++---- src/curl_wrapper.cpp | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/curl_wrapper.hpp b/include/curl_wrapper.hpp index 7674478..9fec3b6 100644 --- a/include/curl_wrapper.hpp +++ b/include/curl_wrapper.hpp @@ -172,7 +172,7 @@ protected: * * @since 0.1.0 */ - mutex buffer_mutex; + mutex _buffer_mutex; /*! * @brief Make a HTTP request. diff --git a/src/connection.cpp b/src/connection.cpp index 1b19833..81297ce 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -68,17 +68,17 @@ answer_type Connection::del(const endpoint_variant &endpoint, string Connection::get_new_stream_contents() { - buffer_mutex.lock(); + _buffer_mutex.lock(); auto &buffer{get_buffer()}; const string buffer_copy{buffer}; buffer.clear(); - buffer_mutex.unlock(); + _buffer_mutex.unlock(); return buffer_copy; } vector Connection::get_new_events() { - buffer_mutex.lock(); + _buffer_mutex.lock(); auto &buffer{get_buffer()}; vector events; @@ -103,7 +103,7 @@ vector Connection::get_new_events() buffer.erase(0, endpos); } - buffer_mutex.unlock(); + _buffer_mutex.unlock(); return events; } diff --git a/src/curl_wrapper.cpp b/src/curl_wrapper.cpp index 97c519d..bfa59ee 100644 --- a/src/curl_wrapper.cpp +++ b/src/curl_wrapper.cpp @@ -280,9 +280,9 @@ size_t CURLWrapper::writer_body(char *data, size_t size, size_t nmemb) return 0; } - buffer_mutex.lock(); + _buffer_mutex.lock(); _curl_buffer_body.append(data, size * nmemb); - buffer_mutex.unlock(); + _buffer_mutex.unlock(); return size * nmemb; }