Skip to content

Commit fe693fc

Browse files
bretambroseBret Ambrose
and
Bret Ambrose
authored
Update formatting to use latest approach; apply formatting to all files (#798)
Co-authored-by: Bret Ambrose <[email protected]>
1 parent e474c30 commit fe693fc

File tree

63 files changed

+1078
-588
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1078
-588
lines changed

.github/workflows/lint.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,12 @@ on:
99
jobs:
1010
clang-format:
1111

12-
runs-on: ubuntu-latest
12+
runs-on: ubuntu-24.04 # latest
1313

1414
steps:
15-
- name: Checkout Sources
16-
uses: actions/checkout@v1
15+
- name: Checkout Sources
16+
uses: actions/checkout@v4
1717

18-
- name: clang-format lint
19-
uses: DoozyX/[email protected]
20-
with:
21-
# List of extensions to check
22-
extensions: cpp,h
23-
clangFormatVersion: 11.1.0
18+
- name: clang-format lint
19+
run: |
20+
./format-check.py

devicedefender/source/DeviceDefender.cpp

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace Aws
2525
public:
2626
Crt::Allocator *m_allocator;
2727

28-
virtual ~CustomMetricBase(){};
28+
virtual ~CustomMetricBase() {};
2929
};
3030

3131
/**
@@ -97,9 +97,10 @@ namespace Aws
9797
CustomMetricNumberList *metric = (CustomMetricNumberList *)data;
9898
Crt::Vector<double> function_data = Crt::Vector<double>();
9999
int returnValue = metric->m_metricFunction(&function_data);
100-
std::for_each(function_data.begin(), function_data.end(), [output](double &i) {
101-
aws_array_list_push_back(output, &i);
102-
});
100+
std::for_each(
101+
function_data.begin(),
102+
function_data.end(),
103+
[output](double &i) { aws_array_list_push_back(output, &i); });
103104
return returnValue;
104105
}
105106

@@ -116,10 +117,14 @@ namespace Aws
116117
CustomMetricStringList *metric = (CustomMetricStringList *)data;
117118
Crt::Vector<Crt::String> function_data = Crt::Vector<Crt::String>();
118119
int returnValue = metric->m_metricFunction(&function_data);
119-
std::for_each(function_data.begin(), function_data.end(), [output, metric](Crt::String &i) {
120-
aws_string *tmp_str = aws_string_new_from_c_str(metric->m_allocator, i.c_str());
121-
aws_array_list_push_back(output, &tmp_str);
122-
});
120+
std::for_each(
121+
function_data.begin(),
122+
function_data.end(),
123+
[output, metric](Crt::String &i)
124+
{
125+
aws_string *tmp_str = aws_string_new_from_c_str(metric->m_allocator, i.c_str());
126+
aws_array_list_push_back(output, &tmp_str);
127+
});
123128
return returnValue;
124129
}
125130

@@ -134,10 +139,14 @@ namespace Aws
134139
CustomMetricIpList *metric = (CustomMetricIpList *)data;
135140
Crt::Vector<Crt::String> function_data = Crt::Vector<Crt::String>();
136141
int returnValue = metric->m_metricFunction(&function_data);
137-
std::for_each(function_data.begin(), function_data.end(), [output, metric](Crt::String &i) {
138-
aws_string *tmp_str = aws_string_new_from_c_str(metric->m_allocator, i.c_str());
139-
aws_array_list_push_back(output, &tmp_str);
140-
});
142+
std::for_each(
143+
function_data.begin(),
144+
function_data.end(),
145+
[output, metric](Crt::String &i)
146+
{
147+
aws_string *tmp_str = aws_string_new_from_c_str(metric->m_allocator, i.c_str());
148+
aws_array_list_push_back(output, &tmp_str);
149+
});
141150
return returnValue;
142151
}
143152

@@ -184,7 +193,10 @@ namespace Aws
184193
}
185194
}
186195

187-
ReportTaskStatus ReportTask::GetStatus() noexcept { return this->m_status; }
196+
ReportTaskStatus ReportTask::GetStatus() noexcept
197+
{
198+
return this->m_status;
199+
}
188200

189201
int ReportTask::StartTask() noexcept
190202
{

devicedefender/tests/DeviceDefenderMetricsTest.cpp

Lines changed: 62 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ static int s_TestDeviceDefenderCustomMetricSuccess(Aws::Crt::Allocator *allocato
4343
std::condition_variable cv;
4444
bool taskStopped = false;
4545

46-
auto onCancelled = [&](void *a) -> void {
46+
auto onCancelled = [&](void *a) -> void
47+
{
4748
auto *data = reinterpret_cast<bool *>(a);
4849
*data = true;
4950
taskStopped = true;
@@ -60,7 +61,8 @@ static int s_TestDeviceDefenderCustomMetricSuccess(Aws::Crt::Allocator *allocato
6061

6162
// ================
6263
// Add the custom metrics
63-
std::function<int(double *)> local_metric_number_func = [](double *output) {
64+
std::function<int(double *)> local_metric_number_func = [](double *output)
65+
{
6466
*output = 10;
6567
return AWS_OP_SUCCESS;
6668
};
@@ -69,32 +71,35 @@ static int s_TestDeviceDefenderCustomMetricSuccess(Aws::Crt::Allocator *allocato
6971
task->RegisterCustomMetricNumber("CustomNumberTwo", std::move(global_metric_number_func_ref));
7072

7173
std::function<int(Aws::Crt::Vector<double> *)> local_metric_number_list_func =
72-
[](Aws::Crt::Vector<double> *output) {
73-
output->push_back(101);
74-
output->push_back(102);
75-
output->push_back(103);
76-
return AWS_OP_SUCCESS;
77-
};
74+
[](Aws::Crt::Vector<double> *output)
75+
{
76+
output->push_back(101);
77+
output->push_back(102);
78+
output->push_back(103);
79+
return AWS_OP_SUCCESS;
80+
};
7881
task->RegisterCustomMetricNumberList("CustomNumberList", std::move(local_metric_number_list_func));
7982

8083
std::function<int(Aws::Crt::Vector<Aws::Crt::String> *)> local_metric_str_list_func =
81-
[](Aws::Crt::Vector<Aws::Crt::String> *output) {
82-
output->push_back("One Fish");
83-
output->push_back("Two Fish");
84-
output->push_back("Red Fish");
85-
output->push_back("Blue Fish");
86-
return AWS_OP_SUCCESS;
87-
};
84+
[](Aws::Crt::Vector<Aws::Crt::String> *output)
85+
{
86+
output->push_back("One Fish");
87+
output->push_back("Two Fish");
88+
output->push_back("Red Fish");
89+
output->push_back("Blue Fish");
90+
return AWS_OP_SUCCESS;
91+
};
8892
task->RegisterCustomMetricStringList("CustomStringList", std::move(local_metric_str_list_func));
8993

9094
std::function<int(Aws::Crt::Vector<Aws::Crt::String> *)> local_metric_ip_list_func =
91-
[](Aws::Crt::Vector<Aws::Crt::String> *output) {
92-
output->push_back("192.0.2.0");
93-
output->push_back("198.51.100.0");
94-
output->push_back("203.0.113.0");
95-
output->push_back("233.252.0.0");
96-
return AWS_OP_SUCCESS;
97-
};
95+
[](Aws::Crt::Vector<Aws::Crt::String> *output)
96+
{
97+
output->push_back("192.0.2.0");
98+
output->push_back("198.51.100.0");
99+
output->push_back("203.0.113.0");
100+
output->push_back("233.252.0.0");
101+
return AWS_OP_SUCCESS;
102+
};
98103
task->RegisterCustomMetricIpAddressList("CustomIPList", std::move(local_metric_ip_list_func));
99104

100105
// ================
@@ -146,7 +151,8 @@ static int s_TestDeviceDefenderCustomMetricFail(Aws::Crt::Allocator *allocator,
146151
std::condition_variable cv;
147152
bool taskStopped = false;
148153

149-
auto onCancelled = [&](void *a) -> void {
154+
auto onCancelled = [&](void *a) -> void
155+
{
150156
auto *data = reinterpret_cast<bool *>(a);
151157
*data = true;
152158
taskStopped = true;
@@ -162,7 +168,8 @@ static int s_TestDeviceDefenderCustomMetricFail(Aws::Crt::Allocator *allocator,
162168
std::shared_ptr<Aws::Iotdevicedefenderv1::ReportTask> task = taskBuilder.Build();
163169

164170
// Add the error custom metric
165-
std::function<int(double *)> number_metric_func = [](double *output) {
171+
std::function<int(double *)> number_metric_func = [](double *output)
172+
{
166173
*output = 10;
167174
return AWS_OP_ERR;
168175
};
@@ -220,7 +227,8 @@ static int s_TestMqtt5DeviceDefenderCustomMetricSuccess(Aws::Crt::Allocator *all
220227
std::condition_variable cv;
221228
bool taskStopped = false;
222229

223-
auto onCancelled = [&](void *a) -> void {
230+
auto onCancelled = [&](void *a) -> void
231+
{
224232
auto *data = reinterpret_cast<bool *>(a);
225233
*data = true;
226234
taskStopped = true;
@@ -237,7 +245,8 @@ static int s_TestMqtt5DeviceDefenderCustomMetricSuccess(Aws::Crt::Allocator *all
237245

238246
// ================
239247
// Add the custom metrics
240-
std::function<int(double *)> local_metric_number_func = [](double *output) {
248+
std::function<int(double *)> local_metric_number_func = [](double *output)
249+
{
241250
*output = 10;
242251
return AWS_OP_SUCCESS;
243252
};
@@ -246,32 +255,35 @@ static int s_TestMqtt5DeviceDefenderCustomMetricSuccess(Aws::Crt::Allocator *all
246255
task->RegisterCustomMetricNumber("CustomNumberTwo", std::move(global_metric_number_func_ref));
247256

248257
std::function<int(Aws::Crt::Vector<double> *)> local_metric_number_list_func =
249-
[](Aws::Crt::Vector<double> *output) {
250-
output->push_back(101);
251-
output->push_back(102);
252-
output->push_back(103);
253-
return AWS_OP_SUCCESS;
254-
};
258+
[](Aws::Crt::Vector<double> *output)
259+
{
260+
output->push_back(101);
261+
output->push_back(102);
262+
output->push_back(103);
263+
return AWS_OP_SUCCESS;
264+
};
255265
task->RegisterCustomMetricNumberList("CustomNumberList", std::move(local_metric_number_list_func));
256266

257267
std::function<int(Aws::Crt::Vector<Aws::Crt::String> *)> local_metric_str_list_func =
258-
[](Aws::Crt::Vector<Aws::Crt::String> *output) {
259-
output->push_back("One Fish");
260-
output->push_back("Two Fish");
261-
output->push_back("Red Fish");
262-
output->push_back("Blue Fish");
263-
return AWS_OP_SUCCESS;
264-
};
268+
[](Aws::Crt::Vector<Aws::Crt::String> *output)
269+
{
270+
output->push_back("One Fish");
271+
output->push_back("Two Fish");
272+
output->push_back("Red Fish");
273+
output->push_back("Blue Fish");
274+
return AWS_OP_SUCCESS;
275+
};
265276
task->RegisterCustomMetricStringList("CustomStringList", std::move(local_metric_str_list_func));
266277

267278
std::function<int(Aws::Crt::Vector<Aws::Crt::String> *)> local_metric_ip_list_func =
268-
[](Aws::Crt::Vector<Aws::Crt::String> *output) {
269-
output->push_back("192.0.2.0");
270-
output->push_back("198.51.100.0");
271-
output->push_back("203.0.113.0");
272-
output->push_back("233.252.0.0");
273-
return AWS_OP_SUCCESS;
274-
};
279+
[](Aws::Crt::Vector<Aws::Crt::String> *output)
280+
{
281+
output->push_back("192.0.2.0");
282+
output->push_back("198.51.100.0");
283+
output->push_back("203.0.113.0");
284+
output->push_back("233.252.0.0");
285+
return AWS_OP_SUCCESS;
286+
};
275287
task->RegisterCustomMetricIpAddressList("CustomIPList", std::move(local_metric_ip_list_func));
276288

277289
// ================
@@ -333,7 +345,8 @@ static int s_TestMqtt5DeviceDefenderCustomMetricFail(Aws::Crt::Allocator *alloca
333345
std::condition_variable cv;
334346
bool taskStopped = false;
335347

336-
auto onCancelled = [&](void *a) -> void {
348+
auto onCancelled = [&](void *a) -> void
349+
{
337350
auto *data = reinterpret_cast<bool *>(a);
338351
*data = true;
339352
taskStopped = true;
@@ -349,7 +362,8 @@ static int s_TestMqtt5DeviceDefenderCustomMetricFail(Aws::Crt::Allocator *alloca
349362
std::shared_ptr<Aws::Iotdevicedefenderv1::ReportTask> task = taskBuilder.Build();
350363

351364
// Add the error custom metric
352-
std::function<int(double *)> number_metric_func = [](double *output) {
365+
std::function<int(double *)> number_metric_func = [](double *output)
366+
{
353367
*output = 10;
354368
return AWS_OP_ERR;
355369
};

devicedefender/tests/DeviceDefenderTest.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ static int s_TestDeviceDefenderResourceSafety(Aws::Crt::Allocator *allocator, vo
4646
std::condition_variable cv;
4747
bool taskStopped = false;
4848

49-
auto onCancelled = [&](void *a) -> void {
49+
auto onCancelled = [&](void *a) -> void
50+
{
5051
auto *data = reinterpret_cast<bool *>(a);
5152
*data = true;
5253
taskStopped = true;
@@ -177,7 +178,8 @@ static int s_TestMqtt5DeviceDefenderResourceSafety(Aws::Crt::Allocator *allocato
177178
std::condition_variable cv;
178179
bool taskStopped = false;
179180

180-
auto onCancelled = [&](void *a) -> void {
181+
auto onCancelled = [&](void *a) -> void
182+
{
181183
auto *data = reinterpret_cast<bool *>(a);
182184
*data = true;
183185
taskStopped = true;

discovery/source/ConnectivityInfo.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ namespace Aws
3131
}
3232
}
3333

34-
ConnectivityInfo::ConnectivityInfo(const Crt::JsonView &doc) { LoadFromObject(*this, doc); }
34+
ConnectivityInfo::ConnectivityInfo(const Crt::JsonView &doc)
35+
{
36+
LoadFromObject(*this, doc);
37+
}
3538

3639
ConnectivityInfo &ConnectivityInfo::operator=(const Crt::JsonView &doc)
3740
{

discovery/source/DiscoverResponse.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ namespace Aws
2222
}
2323
}
2424

25-
DiscoverResponse::DiscoverResponse(const Crt::JsonView &doc) { LoadFromObject(*this, doc); }
25+
DiscoverResponse::DiscoverResponse(const Crt::JsonView &doc)
26+
{
27+
LoadFromObject(*this, doc);
28+
}
2629

2730
DiscoverResponse &DiscoverResponse::operator=(const Crt::JsonView &doc)
2831
{

discovery/source/DiscoveryClient.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ namespace Aws
119119

120120
bool res = m_connectionManager->AcquireConnection(
121121
[this, callbackContext, thingName, onDiscoverResponse](
122-
std::shared_ptr<Crt::Http::HttpClientConnection> connection, int errorCode) {
122+
std::shared_ptr<Crt::Http::HttpClientConnection> connection, int errorCode)
123+
{
123124
if (errorCode)
124125
{
125126
onDiscoverResponse(nullptr, errorCode, 0);
@@ -164,15 +165,14 @@ namespace Aws
164165
[](Crt::Http::HttpStream &, aws_http_header_block, const Crt::Http::HttpHeader *, std::size_t) {
165166
};
166167
requestOptions.onIncomingHeadersBlockDone =
167-
[callbackContext](Crt::Http::HttpStream &stream, aws_http_header_block) {
168-
callbackContext->responseCode = stream.GetResponseStatusCode();
169-
};
168+
[callbackContext](Crt::Http::HttpStream &stream, aws_http_header_block)
169+
{ callbackContext->responseCode = stream.GetResponseStatusCode(); };
170170
requestOptions.onIncomingBody =
171-
[callbackContext](Crt::Http::HttpStream &, const Crt::ByteCursor &data) {
172-
callbackContext->ss.write(reinterpret_cast<const char *>(data.ptr), data.len);
173-
};
171+
[callbackContext](Crt::Http::HttpStream &, const Crt::ByteCursor &data)
172+
{ callbackContext->ss.write(reinterpret_cast<const char *>(data.ptr), data.len); };
174173
requestOptions.onStreamComplete = [request, connection, callbackContext, onDiscoverResponse](
175-
Crt::Http::HttpStream &, int errorCode) {
174+
Crt::Http::HttpStream &, int errorCode)
175+
{
176176
if (!errorCode && callbackContext->responseCode == 200)
177177
{
178178
Crt::JsonObject jsonObject(callbackContext->ss.str());

discovery/source/GGCore.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ namespace Aws
2929
}
3030
}
3131

32-
GGCore::GGCore(const Crt::JsonView &doc) { LoadFromObject(*this, doc); }
32+
GGCore::GGCore(const Crt::JsonView &doc)
33+
{
34+
LoadFromObject(*this, doc);
35+
}
3336

3437
GGCore &GGCore::operator=(const Crt::JsonView &doc)
3538
{

discovery/source/GGGroup.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ namespace Aws
3838
}
3939
}
4040

41-
GGGroup::GGGroup(const Crt::JsonView &doc) { LoadFromObject(*this, doc); }
41+
GGGroup::GGGroup(const Crt::JsonView &doc)
42+
{
43+
LoadFromObject(*this, doc);
44+
}
4245

4346
GGGroup &GGGroup::operator=(const Crt::JsonView &doc)
4447
{

eventstream_rpc/include/aws/eventstreamrpc/EventStreamClient.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ namespace Aws
127127
void PrependHeaders(Crt::List<EventStreamHeader> &&headers);
128128
void SetPayload(const Crt::Optional<Crt::ByteBuf> &payload) noexcept;
129129
void SetPayload(Crt::Optional<Crt::ByteBuf> &&payload);
130-
const Crt::List<EventStreamHeader> &GetHeaders() const &noexcept;
130+
const Crt::List<EventStreamHeader> &GetHeaders() const & noexcept;
131131
Crt::List<EventStreamHeader> &&GetHeaders() &&;
132-
const Crt::Optional<Crt::ByteBuf> &GetPayload() const &noexcept;
132+
const Crt::Optional<Crt::ByteBuf> &GetPayload() const & noexcept;
133133
Crt::Optional<Crt::ByteBuf> &&GetPayload() &&;
134134

135135
private:

0 commit comments

Comments
 (0)