Skip to content

Commit 1c5a8ba

Browse files
committed
Allow to build with clang-tidy and clang-tidy fixes
1 parent dc2a94c commit 1c5a8ba

File tree

14 files changed

+46
-37
lines changed

14 files changed

+46
-37
lines changed

CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.8)
1+
cmake_minimum_required(VERSION 3.10)
22

33
project(AnyBlob)
44

@@ -55,6 +55,13 @@ if (ANYBLOB_LIBCXX_COMPAT)
5555
set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_COVERAGE} -stdlib=libc++")
5656
endif()
5757

58+
# Allow enabling clang-tidy
59+
option(ANYBLOB_CLANG_TIDY "enable clang-tidy" OFF)
60+
if(ANYBLOB_CLANG_TIDY)
61+
find_program(ANYBLOB_CLANG_TIDY_BINARY "clang-tidy" REQUIRED)
62+
set(CMAKE_CXX_CLANG_TIDY "${ANYBLOB_CLANG_TIDY_BINARY}")
63+
endif()
64+
5865
# ---------------------------------------------------------------------------
5966
# Coverage Environment
6067
# ---------------------------------------------------------------------------

include/cloud/ibm.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,23 @@ namespace cloud {
1818
//---------------------------------------------------------------------------
1919
/// Implements the IBM logic using the AWS S3 compatibility API
2020
class IBM : public AWS {
21+
/// Get the address of the server
22+
[[nodiscard]] std::string getAddressImpl() const;
23+
2124
public:
2225
/// The constructor
2326
explicit IBM(const RemoteInfo& info) : AWS(info) {
2427
assert(info.provider == Provider::CloudService::IBM);
2528
// COS requires path-style bucket URLs - similar to MinIO, thus we use the endpoint setting
26-
_settings.endpoint = getAddress();
29+
_settings.endpoint = getAddressImpl();
2730
}
2831
/// The custom endpoint constructor
2932
IBM(const RemoteInfo& info, const std::string& keyId, const std::string& key) : AWS(info, keyId, key) {
3033
// COS requires path-style bucket URLs - similar to MinIO, thus we use the endpoint setting
31-
_settings.endpoint = getAddress();
34+
_settings.endpoint = getAddressImpl();
3235
}
3336
/// Get the address of the server
34-
[[nodiscard]] std::string getAddress() const override;
37+
[[nodiscard]] std::string getAddress() const override { return getAddressImpl(); }
3538
/// Get the instance details
3639
[[nodiscard]] Provider::Instance getInstanceDetails(network::TaskedSendReceiverHandle& sendReceiver) override;
3740

include/network/tasked_send_receiver.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ class TaskedSendReceiverHandle {
175175
/// Default constructor is deleted
176176
TaskedSendReceiverHandle() = delete;
177177
/// Consturctor
178-
explicit TaskedSendReceiverHandle(TaskedSendReceiverGroup* group);
178+
explicit TaskedSendReceiverHandle(TaskedSendReceiverGroup* group, TaskedSendReceiver* _sendReceiver);
179179
/// Delete copy
180180
TaskedSendReceiverHandle(TaskedSendReceiverHandle& other) = delete;
181181
/// Delete copy assignment
@@ -186,9 +186,9 @@ class TaskedSendReceiverHandle {
186186

187187
public:
188188
/// Move constructor
189-
TaskedSendReceiverHandle(TaskedSendReceiverHandle&& other);
189+
TaskedSendReceiverHandle(TaskedSendReceiverHandle&& other) noexcept;
190190
/// Move assignment
191-
TaskedSendReceiverHandle& operator=(TaskedSendReceiverHandle&& other);
191+
TaskedSendReceiverHandle& operator=(TaskedSendReceiverHandle&& other) noexcept;
192192
/// Destructor
193193
~TaskedSendReceiverHandle();
194194

include/utils/timer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class Timer {
9393
/// Default copy constructor
9494
Timer(const Timer&) = default;
9595
/// Move Assignment - Timer and Merge
96-
Timer& operator=(Timer&& rhs);
96+
Timer& operator=(Timer&& rhs) noexcept;
9797
/// Destructor
9898
~Timer() {
9999
if (_outStream)

src/cloud/aws.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ unique_ptr<utils::DataVector<uint8_t>> AWS::downloadIAMUser() const
110110
unique_ptr<utils::DataVector<uint8_t>> AWS::downloadSecret(string_view content, string& iamUser)
111111
// Builds the secret http request
112112
{
113-
auto pos = content.find("\n");
113+
auto pos = content.find('\n');
114114
string httpHeader = "GET /latest/meta-data/iam/security-credentials/";
115115
if (!content.substr(0, pos).size())
116116
return nullptr;
@@ -132,31 +132,31 @@ bool AWS::updateSecret(string_view content, string_view iamUser)
132132
if (pos == content.npos)
133133
return false;
134134
pos += needle.length();
135-
auto end = content.find("\"", pos);
135+
auto end = content.find('\"', pos);
136136
secret->keyId = content.substr(pos, end - pos);
137137

138138
needle = "\"SecretAccessKey\" : \"";
139139
pos = content.find(needle);
140140
if (pos == content.npos)
141141
return false;
142142
pos += needle.length();
143-
end = content.find("\"", pos);
143+
end = content.find('\"', pos);
144144
secret->secret = content.substr(pos, end - pos);
145145

146146
needle = "\"Token\" : \"";
147147
pos = content.find(needle);
148148
if (pos == content.npos)
149149
return false;
150150
pos += needle.length();
151-
end = content.find("\"", pos);
151+
end = content.find('\"', pos);
152152
secret->token = content.substr(pos, end - pos);
153153

154154
needle = "\"Expiration\" : \"";
155155
pos = content.find(needle);
156156
if (pos == content.npos)
157157
return false;
158158
pos += needle.length();
159-
end = content.find("\"", pos);
159+
end = content.find('\"', pos);
160160
auto sv = content.substr(pos, end - pos);
161161
string timestamp(sv.begin(), sv.end());
162162
secret->expiration = convertIAMTimestamp(timestamp);

src/cloud/azure.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Provider::Instance Azure::getInstanceDetails(network::TaskedSendReceiverHandle&
6767
auto pos = s.find(needle);
6868
if (pos != s.npos) {
6969
pos += needle.length();
70-
auto end = s.find("\"", pos);
70+
auto end = s.find('\"', pos);
7171
auto vmType = s.substr(pos, end - pos);
7272

7373
for (auto& instance : AzureInstance::getInstanceDetails())
@@ -98,7 +98,7 @@ string Azure::getRegion(network::TaskedSendReceiverHandle& sendReceiverHandle)
9898
if (pos == s.npos)
9999
throw runtime_error("Azure Region: No location found.");
100100
pos += needle.length();
101-
auto end = s.find("\"", pos);
101+
auto end = s.find('\"', pos);
102102
auto region = s.substr(pos, end - pos);
103103

104104
return string(region);

src/cloud/ibm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Provider::Instance IBM::getInstanceDetails(network::TaskedSendReceiverHandle& /*
2020
return IBMInstance{"ibm", 0, 0, 0};
2121
}
2222
//---------------------------------------------------------------------------
23-
string IBM::getAddress() const
23+
string IBM::getAddressImpl() const
2424
// Gets the address of IBM COS
2525
{
2626
return "s3." + _settings.region + ".cloud-object-storage.appdomain.cloud";

src/cloud/provider.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ string Provider::getETag(string_view header)
109109
if (pos == header.npos)
110110
return "";
111111
pos += needle.length();
112-
auto end = header.find("\"", pos);
112+
auto end = header.find('\"', pos);
113113
return string(header.substr(pos, end - pos));
114114
}
115115
//---------------------------------------------------------------------------
@@ -209,6 +209,7 @@ unique_ptr<Provider> Provider::makeProvider(const string& filepath, bool https,
209209

210210
if (keyId.empty()) {
211211
auto aws = make_unique<anyblob::cloud::AWS>(info);
212+
assert(sendReceiverHandle);
212213
aws->initSecret(*sendReceiverHandle);
213214
return aws;
214215
}

src/network/http_request.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ HttpRequest HttpRequest::deserialize(string_view data)
6767
}
6868

6969
// parse path, requires HTTP type, otherwise invalid
70-
pos = line.find(" ", 1);
70+
pos = line.find(' ', 1);
7171
if (pos == line.npos)
7272
throw runtime_error("Invalid HttpRequest: Could not find path, or missing HTTP type!");
7373
auto pathQuery = line.substr(1, pos - 1);

src/network/tasked_send_receiver.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,11 @@ TaskedSendReceiverHandle TaskedSendReceiverGroup::getHandle()
5454
{
5555
auto result = _sendReceiverCache.consume();
5656
if (result.has_value()) {
57-
TaskedSendReceiverHandle handle(this);
58-
handle._sendReceiver = result.value();
59-
return handle;
57+
return TaskedSendReceiverHandle(this, result.value());
6058
}
6159
lock_guard<mutex> lg(_resizeMutex);
6260
auto& ref = _sendReceivers.emplace_back(unique_ptr<TaskedSendReceiver>(new TaskedSendReceiver(*this)));
63-
TaskedSendReceiverHandle handle(this);
64-
handle._sendReceiver = ref.get();
65-
return handle;
61+
return TaskedSendReceiverHandle(this, ref.get());
6662
}
6763
//---------------------------------------------------------------------------
6864
void TaskedSendReceiverGroup::process(bool oneQueueInvocation)
@@ -72,20 +68,20 @@ void TaskedSendReceiverGroup::process(bool oneQueueInvocation)
7268
handle.process(oneQueueInvocation);
7369
}
7470
//---------------------------------------------------------------------------
75-
TaskedSendReceiverHandle::TaskedSendReceiverHandle(TaskedSendReceiverGroup* group) : _group(group)
71+
TaskedSendReceiverHandle::TaskedSendReceiverHandle(TaskedSendReceiverGroup* group, TaskedSendReceiver* sendReceiver) : _group(group), _sendReceiver(sendReceiver)
7672
// The constructor
7773
{
7874
}
7975
//---------------------------------------------------------------------------
80-
TaskedSendReceiverHandle::TaskedSendReceiverHandle(TaskedSendReceiverHandle&& other)
76+
TaskedSendReceiverHandle::TaskedSendReceiverHandle(TaskedSendReceiverHandle&& other) noexcept
8177
// Move constructor
8278
{
8379
_group = other._group;
8480
_sendReceiver = other._sendReceiver;
8581
other._sendReceiver = nullptr;
8682
}
8783
//---------------------------------------------------------------------------
88-
TaskedSendReceiverHandle& TaskedSendReceiverHandle::operator=(TaskedSendReceiverHandle&& other)
84+
TaskedSendReceiverHandle& TaskedSendReceiverHandle::operator=(TaskedSendReceiverHandle&& other) noexcept
8985
// Move assignment
9086
{
9187
if (other._group == _group) {

0 commit comments

Comments
 (0)