Skip to content

Commit 1aad9f3

Browse files
authored
Disallow short functions definition on the same line in clang-format (#552)
1 parent 3e900d6 commit 1aad9f3

File tree

27 files changed

+244
-81
lines changed

27 files changed

+244
-81
lines changed

.clang-format

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Standard: c++20
33
BasedOnStyle: Google
44
ColumnLimit: 120
55
UseTab: Never
6+
AllowShortFunctionsOnASingleLine: Empty
67
QualifierAlignment: Left
78
PointerAlignment: Right
89
ReferenceAlignment: Right

modules/performance/include/performance.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414

1515
namespace ppc::performance {
1616

17-
inline double DefaultTimer() { return -1.0; }
17+
inline double DefaultTimer() {
18+
return -1.0;
19+
}
1820

1921
struct PerfAttr {
2022
/// @brief Number of times the task is run for performance evaluation.
@@ -96,7 +98,9 @@ class Perf {
9698
}
9799
/// @brief Retrieves the performance test results.
98100
/// @return The latest PerfResults structure.
99-
[[nodiscard]] PerfResults GetPerfResults() const { return perf_results_; }
101+
[[nodiscard]] PerfResults GetPerfResults() const {
102+
return perf_results_;
103+
}
100104

101105
private:
102106
PerfResults perf_results_;

modules/performance/tests/perf_tests.cpp

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@ namespace ppc::test {
2323
template <typename InType, typename OutType>
2424
class TestPerfTask : public ppc::task::Task<InType, OutType> {
2525
public:
26-
explicit TestPerfTask(const InType& in) { this->GetInput() = in; }
26+
explicit TestPerfTask(const InType& in) {
27+
this->GetInput() = in;
28+
}
2729

28-
bool ValidationImpl() override { return !this->GetInput().empty(); }
30+
bool ValidationImpl() override {
31+
return !this->GetInput().empty();
32+
}
2933

3034
bool PreProcessingImpl() override {
3135
this->GetOutput() = 0;
@@ -39,7 +43,9 @@ class TestPerfTask : public ppc::task::Task<InType, OutType> {
3943
return true;
4044
}
4145

42-
bool PostProcessingImpl() override { return true; }
46+
bool PostProcessingImpl() override {
47+
return true;
48+
}
4349
};
4450

4551
template <typename InType, typename OutType>
@@ -203,7 +209,9 @@ class GetStringTaskTypeTest : public ::testing::TestWithParam<TaskTypeTestCase>
203209
std::ofstream(temp_path) << j->dump();
204210
}
205211

206-
void TearDown() override { std::filesystem::remove(temp_path); }
212+
void TearDown() override {
213+
std::filesystem::remove(temp_path);
214+
}
207215
};
208216

209217
TEST_P(GetStringTaskTypeTest, ReturnsExpectedString) {
@@ -279,10 +287,18 @@ TEST(GetStringTaskStatusTest, HandlesEnabledAndDisabled) {
279287
class DummyTask : public Task<int, int> {
280288
public:
281289
using Task::Task;
282-
bool ValidationImpl() override { return true; }
283-
bool PreProcessingImpl() override { return true; }
284-
bool RunImpl() override { return true; }
285-
bool PostProcessingImpl() override { return true; }
290+
bool ValidationImpl() override {
291+
return true;
292+
}
293+
bool PreProcessingImpl() override {
294+
return true;
295+
}
296+
bool RunImpl() override {
297+
return true;
298+
}
299+
bool PostProcessingImpl() override {
300+
return true;
301+
}
286302
};
287303

288304
TEST(TaskTest, GetDynamicTypeReturnsCorrectEnum) {
@@ -372,10 +388,18 @@ TEST(PerfTest, GetStringParamNameTest) {
372388
TEST(TaskTest, Destructor_InvalidPipelineOrderTerminates_PartialPipeline) {
373389
{
374390
struct BadTask : Task<int, int> {
375-
bool ValidationImpl() override { return true; }
376-
bool PreProcessingImpl() override { return true; }
377-
bool RunImpl() override { return true; }
378-
bool PostProcessingImpl() override { return true; }
391+
bool ValidationImpl() override {
392+
return true;
393+
}
394+
bool PreProcessingImpl() override {
395+
return true;
396+
}
397+
bool RunImpl() override {
398+
return true;
399+
}
400+
bool PostProcessingImpl() override {
401+
return true;
402+
}
379403
} task;
380404
task.Validation();
381405
}

modules/task/include/task.hpp

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,31 +164,45 @@ class Task {
164164

165165
/// @brief Returns the current testing mode.
166166
/// @return Reference to the current StateOfTesting.
167-
StateOfTesting &GetStateOfTesting() { return state_of_testing_; }
167+
StateOfTesting &GetStateOfTesting() {
168+
return state_of_testing_;
169+
}
168170

169171
/// @brief Sets the dynamic task type.
170172
/// @param type_of_task Task type to set.
171-
void SetTypeOfTask(TypeOfTask type_of_task) { type_of_task_ = type_of_task; }
173+
void SetTypeOfTask(TypeOfTask type_of_task) {
174+
type_of_task_ = type_of_task;
175+
}
172176

173177
/// @brief Returns the dynamic task type.
174178
/// @return Current dynamic task type.
175-
[[nodiscard]] TypeOfTask GetDynamicTypeOfTask() const { return type_of_task_; }
179+
[[nodiscard]] TypeOfTask GetDynamicTypeOfTask() const {
180+
return type_of_task_;
181+
}
176182

177183
/// @brief Returns the current task status.
178184
/// @return Task status (enabled or disabled).
179-
[[nodiscard]] StatusOfTask GetStatusOfTask() const { return status_of_task_; }
185+
[[nodiscard]] StatusOfTask GetStatusOfTask() const {
186+
return status_of_task_;
187+
}
180188

181189
/// @brief Returns the static task type.
182190
/// @return Static task type (default: kUnknown).
183-
static constexpr TypeOfTask GetStaticTypeOfTask() { return TypeOfTask::kUnknown; }
191+
static constexpr TypeOfTask GetStaticTypeOfTask() {
192+
return TypeOfTask::kUnknown;
193+
}
184194

185195
/// @brief Returns a reference to the input data.
186196
/// @return Reference to the task's input data.
187-
InType &GetInput() { return input_; }
197+
InType &GetInput() {
198+
return input_;
199+
}
188200

189201
/// @brief Returns a reference to the output data.
190202
/// @return Reference to the task's output data.
191-
OutType &GetOutput() { return output_; }
203+
OutType &GetOutput() {
204+
return output_;
205+
}
192206

193207
/// @brief Destructor. Verifies that the pipeline was executed in the correct order.
194208
/// @note Terminates the program if the pipeline order is incorrect or incomplete.

modules/task/tests/task_tests.cpp

Lines changed: 72 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,13 @@ namespace ppc::test {
3838
template <typename InType, typename OutType>
3939
class TestTask : public ppc::task::Task<InType, OutType> {
4040
public:
41-
explicit TestTask(const InType& in) { this->GetInput() = in; }
41+
explicit TestTask(const InType& in) {
42+
this->GetInput() = in;
43+
}
4244

43-
bool ValidationImpl() override { return !this->GetInput().empty(); }
45+
bool ValidationImpl() override {
46+
return !this->GetInput().empty();
47+
}
4448

4549
bool PreProcessingImpl() override {
4650
this->GetOutput() = 0;
@@ -54,7 +58,9 @@ class TestTask : public ppc::task::Task<InType, OutType> {
5458
return true;
5559
}
5660

57-
bool PostProcessingImpl() override { return true; }
61+
bool PostProcessingImpl() override {
62+
return true;
63+
}
5864
};
5965

6066
template <typename InType, typename OutType>
@@ -149,9 +155,13 @@ TEST(task_tests, premature_postprocessing_after_preprocessing) {
149155
EXPECT_THROW(test_task.PostProcessing(), std::runtime_error);
150156
}
151157

152-
TEST(TaskTest, GetStringTaskStatus_Disabled) { EXPECT_EQ(GetStringTaskStatus(StatusOfTask::kDisabled), "disabled"); }
158+
TEST(TaskTest, GetStringTaskStatus_Disabled) {
159+
EXPECT_EQ(GetStringTaskStatus(StatusOfTask::kDisabled), "disabled");
160+
}
153161

154-
TEST(TaskTest, GetStringTaskStatus_Enabled) { EXPECT_EQ(GetStringTaskStatus(StatusOfTask::kEnabled), "enabled"); }
162+
TEST(TaskTest, GetStringTaskStatus_Enabled) {
163+
EXPECT_EQ(GetStringTaskStatus(StatusOfTask::kEnabled), "enabled");
164+
}
155165

156166
TEST(TaskTest, GetStringTaskType_InvalidFileThrows) {
157167
EXPECT_THROW({ GetStringTaskType(TypeOfTask::kALL, "non_existing_file.json"); }, std::runtime_error);
@@ -217,11 +227,21 @@ TEST(TaskTest, TaskDestructor_ThrowsIfStageIncomplete) {
217227
{
218228
std::vector<int32_t> in(20, 1);
219229
struct LocalTask : Task<std::vector<int32_t>, int32_t> {
220-
explicit LocalTask(const std::vector<int32_t>& in) { this->GetInput() = in; }
221-
bool ValidationImpl() override { return true; }
222-
bool PreProcessingImpl() override { return true; }
223-
bool RunImpl() override { return true; }
224-
bool PostProcessingImpl() override { return true; }
230+
explicit LocalTask(const std::vector<int32_t>& in) {
231+
this->GetInput() = in;
232+
}
233+
bool ValidationImpl() override {
234+
return true;
235+
}
236+
bool PreProcessingImpl() override {
237+
return true;
238+
}
239+
bool RunImpl() override {
240+
return true;
241+
}
242+
bool PostProcessingImpl() override {
243+
return true;
244+
}
225245
} task(in);
226246
task.Validation();
227247
}
@@ -233,11 +253,21 @@ TEST(TaskTest, TaskDestructor_ThrowsIfEmpty) {
233253
{
234254
std::vector<int32_t> in(20, 1);
235255
struct LocalTask : Task<std::vector<int32_t>, int32_t> {
236-
explicit LocalTask(const std::vector<int32_t>& in) { this->GetInput() = in; }
237-
bool ValidationImpl() override { return true; }
238-
bool PreProcessingImpl() override { return true; }
239-
bool RunImpl() override { return true; }
240-
bool PostProcessingImpl() override { return true; }
256+
explicit LocalTask(const std::vector<int32_t>& in) {
257+
this->GetInput() = in;
258+
}
259+
bool ValidationImpl() override {
260+
return true;
261+
}
262+
bool PreProcessingImpl() override {
263+
return true;
264+
}
265+
bool RunImpl() override {
266+
return true;
267+
}
268+
bool PostProcessingImpl() override {
269+
return true;
270+
}
241271
} task(in);
242272
}
243273
EXPECT_TRUE(ppc::util::DestructorFailureFlag::Get());
@@ -246,14 +276,22 @@ TEST(TaskTest, TaskDestructor_ThrowsIfEmpty) {
246276

247277
TEST(TaskTest, InternalTimeTest_ThrowsIfTimeoutExceeded) {
248278
struct SlowTask : Task<std::vector<int32_t>, int32_t> {
249-
explicit SlowTask(const std::vector<int32_t>& in) { this->GetInput() = in; }
250-
bool ValidationImpl() override { return true; }
279+
explicit SlowTask(const std::vector<int32_t>& in) {
280+
this->GetInput() = in;
281+
}
282+
bool ValidationImpl() override {
283+
return true;
284+
}
251285
bool PreProcessingImpl() override {
252286
std::this_thread::sleep_for(std::chrono::seconds(2));
253287
return true;
254288
}
255-
bool RunImpl() override { return true; }
256-
bool PostProcessingImpl() override { return true; }
289+
bool RunImpl() override {
290+
return true;
291+
}
292+
bool PostProcessingImpl() override {
293+
return true;
294+
}
257295
};
258296

259297
std::vector<int32_t> in(20, 1);
@@ -268,10 +306,18 @@ TEST(TaskTest, InternalTimeTest_ThrowsIfTimeoutExceeded) {
268306
class DummyTask : public Task<int, int> {
269307
public:
270308
using Task::Task;
271-
bool ValidationImpl() override { return true; }
272-
bool PreProcessingImpl() override { return true; }
273-
bool RunImpl() override { return true; }
274-
bool PostProcessingImpl() override { return true; }
309+
bool ValidationImpl() override {
310+
return true;
311+
}
312+
bool PreProcessingImpl() override {
313+
return true;
314+
}
315+
bool RunImpl() override {
316+
return true;
317+
}
318+
bool PostProcessingImpl() override {
319+
return true;
320+
}
275321
};
276322

277323
TEST(TaskTest, ValidationThrowsIfCalledTwice) {
@@ -297,4 +343,6 @@ TEST(TaskTest, PostProcessingThrowsIfCalledBeforeRun) {
297343
EXPECT_THROW(task->PostProcessing(), std::runtime_error);
298344
}
299345

300-
int main(int argc, char** argv) { return ppc::runners::SimpleInit(argc, argv); }
346+
int main(int argc, char** argv) {
347+
return ppc::runners::SimpleInit(argc, argv);
348+
}

modules/util/include/func_test_util.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,13 @@ class BaseRunFuncTests : public ::testing::TestWithParam<FuncTestParam<InType, O
7272
InitializeAndRunTask(test_param);
7373
}
7474

75-
void ValidateTestName(const std::string& test_name) { EXPECT_FALSE(test_name.find("unknown") != std::string::npos); }
75+
void ValidateTestName(const std::string& test_name) {
76+
EXPECT_FALSE(test_name.find("unknown") != std::string::npos);
77+
}
7678

77-
bool IsTestDisabled(const std::string& test_name) { return test_name.find("disabled") != std::string::npos; }
79+
bool IsTestDisabled(const std::string& test_name) {
80+
return test_name.find("disabled") != std::string::npos;
81+
}
7882

7983
bool ShouldSkipNonMpiTask(const std::string& test_name) {
8084
auto contains_substring = [&](const std::string& substring) {

modules/util/include/util.hpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,20 @@ namespace ppc::util {
3535
class DestructorFailureFlag {
3636
public:
3737
/// @brief Marks that a destructor failure has occurred.
38-
static void Set() { failure_flag.store(true); }
38+
static void Set() {
39+
failure_flag.store(true);
40+
}
3941

4042
/// @brief Clears the destructor failure flag.
41-
static void Unset() { failure_flag.store(false); }
43+
static void Unset() {
44+
failure_flag.store(false);
45+
}
4246

4347
/// @brief Checks if a destructor failure was recorded.
4448
/// @return True if failure occurred, false otherwise.
45-
static bool Get() { return failure_flag.load(); }
49+
static bool Get() {
50+
return failure_flag.load();
51+
}
4652

4753
private:
4854
inline static std::atomic<bool> failure_flag{false};
@@ -79,7 +85,9 @@ std::string GetNamespace() {
7985
return (pos != std::string::npos) ? name.substr(0, pos) : std::string{};
8086
}
8187

82-
inline std::shared_ptr<nlohmann::json> InitJSONPtr() { return std::make_shared<nlohmann::json>(); }
88+
inline std::shared_ptr<nlohmann::json> InitJSONPtr() {
89+
return std::make_shared<nlohmann::json>();
90+
}
8391

8492
bool IsUnderMpirun();
8593

modules/util/src/func_test_util.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
#include "util/include/perf_test_util.hpp"
44

5-
double ppc::util::GetTimeMPI() { return MPI_Wtime(); }
5+
double ppc::util::GetTimeMPI() {
6+
return MPI_Wtime();
7+
}
68

79
int ppc::util::GetMPIRank() {
810
int rank = -1;
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
#include "runners/include/runners.hpp"
22

3-
int main(int argc, char** argv) { return ppc::runners::Init(argc, argv); }
3+
int main(int argc, char** argv) {
4+
return ppc::runners::Init(argc, argv);
5+
}

0 commit comments

Comments
 (0)