Skip to content

Commit ea58f97

Browse files
committed
Make clang-tidy rules more strict
1 parent 760d2d3 commit ea58f97

File tree

34 files changed

+1568
-1586
lines changed

34 files changed

+1568
-1586
lines changed

.clang-tidy

Lines changed: 18 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,31 @@
11
Checks: >
2+
bugprone-*,
3+
clang-diagnostic-*,
4+
llvm-include-order,
5+
llvm-namespace-comment,
6+
misc-*,
27
modernize-*,
38
performance-*,
49
portability-*,
510
readability-*,
11+
-bugprone-casting-through-void,
12+
-bugprone-exception-escape,
13+
-bugprone-implicit-widening-of-multiplication-result,
14+
-bugprone-narrowing-conversions,
15+
-clang-analyzer-optin.cplusplus.UninitializedObject,
16+
-misc-const-correctness,
17+
-misc-include-cleaner,
18+
-misc-no-recursion,
19+
-misc-non-private-member-variables-in-classes,
20+
-misc-unused-parameters,
21+
-misc-use-anonymous-namespace,
622
-modernize-avoid-c-arrays,
7-
-modernize-concat-nested-namespaces,
8-
-modernize-pass-by-value,
9-
-modernize-return-braced-init-list,
1023
-modernize-use-nodiscard,
1124
-modernize-use-trailing-return-type,
25+
-readability-function-cognitive-complexity,
1226
-readability-identifier-length,
1327
-readability-magic-numbers,
14-
-readability-named-parameter,
15-
-readability-redundant-declaration,
16-
bugprone-assignment-in-if-condition,
17-
bugprone-forward-declaration-namespace,
18-
bugprone-infinite-loop,
19-
bugprone-integer-division,
20-
bugprone-macro-parentheses,
21-
bugprone-macro-repeated-side-effects,
22-
bugprone-move-forwarding-reference,
23-
bugprone-redundant-branch-condition,
24-
bugprone-reserved-identifier,
25-
bugprone-suspicious-include,
26-
bugprone-suspicious-semicolon,
27-
bugprone-terminating-continue,
28-
bugprone-throw-keyword-missing,
29-
bugprone-unused-raii,
30-
bugprone-unused-return-value,
31-
clang-diagnostic-*,
32-
llvm-include-order,
33-
llvm-namespace-comment,
34-
misc-confusable-identifiers,
35-
misc-definitions-in-headers,
36-
misc-header-include-cycle,
37-
misc-include-cleaner,
38-
misc-misplaced-const,
39-
misc-non-copyable-objects,
40-
misc-redundant-expression,
41-
misc-static-assert,
42-
misc-throw-by-value-catch-by-reference,
43-
misc-unconventional-assign-operator,
44-
misc-unused-alias-decls,
45-
misc-unused-parameters,
46-
misc-unused-using-decls,
47-
misc-use-anonymous-namespace
28+
-readability-named-parameter
4829
4930
WarningsAsErrors: "*"
5031

1stsamples/mpi/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ int main(int argc, char** argv) {
1616
MPI_Get_processor_name(processor_name, &len_chars);
1717

1818
MPI_Barrier(MPI_COMM_WORLD);
19-
std::cout << "Processor = " << processor_name << std::endl;
20-
std::cout << "Rank = " << world_rank << std::endl;
21-
std::cout << "Number of processors = " << world_size << std::endl;
19+
std::cout << "Processor = " << processor_name << '\n';
20+
std::cout << "Rank = " << world_rank << '\n';
21+
std::cout << "Number of processors = " << world_size << '\n';
2222

2323
MPI_Finalize();
2424
return 0;

1stsamples/mpi_boost/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ int main(int argc, char** argv) {
1111
boost::mpi::communicator world;
1212

1313
world.barrier();
14-
std::cout << "Processor = " << boost::mpi::environment::processor_name() << std::endl;
15-
std::cout << "Rank = " << world.rank() << std::endl;
16-
std::cout << "Number of processors = " << world.size() << std::endl;
14+
std::cout << "Processor = " << boost::mpi::environment::processor_name() << '\n';
15+
std::cout << "Rank = " << world.rank() << '\n';
16+
std::cout << "Number of processors = " << world.size() << '\n';
1717

1818
return 0;
1919
}

1stsamples/omp/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
int main() {
66
#pragma omp parallel
77
{
8-
std::cout << "Thread number = " << omp_get_thread_num() << std::endl;
9-
std::cout << "Number of threads = " << omp_get_num_threads() << std::endl;
8+
std::cout << "Thread number = " << omp_get_thread_num() << '\n';
9+
std::cout << "Number of threads = " << omp_get_num_threads() << '\n';
1010
}
1111
return 0;
1212
}

1stsamples/stl/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
#include <thread>
44
#include <vector>
55

6-
void task(const std::string& msg) { std::cout << "thread number: " + msg << std::endl; }
6+
static void Task(const std::string& msg) { std::cout << "thread number: " + msg << '\n'; }
77

88
int main() {
99
const auto num_max_threads = std::thread::hardware_concurrency();
10-
std::cout << "Number of threads = " << num_max_threads << std::endl;
10+
std::cout << "Number of threads = " << num_max_threads << '\n';
1111
std::vector<std::thread> thr(num_max_threads);
1212

1313
for (unsigned int i = 0; i < num_max_threads; ++i) {
14-
thr[i] = std::thread(task, std::to_string(i));
14+
thr[i] = std::thread(Task, std::to_string(i));
1515
}
1616

1717
for (unsigned int i = 0; i < num_max_threads; ++i) {

1stsamples/tbb/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
#include <iostream>
44

5-
int fib_func(int n) {
5+
static int FibFunc(int n) {
66
if (n < 2) {
77
return n;
88
}
99
int x;
1010
int y;
1111
oneapi::tbb::task_group g;
12-
g.run([&] { x = fib_func(n - 1); });
13-
g.run([&] { y = fib_func(n - 2); });
12+
g.run([&] { x = FibFunc(n - 1); });
13+
g.run([&] { y = FibFunc(n - 2); });
1414
g.wait();
1515
return x + y;
1616
}
1717

18-
int main() { return fib_func(10) - 55; }
18+
int main() { return FibFunc(10) - 55; }

modules/core/perf/func_tests/perf_tests.cpp

Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,29 @@ TEST(perf_tests, check_perf_pipeline) {
1111
std::vector<uint32_t> out(1, 0);
1212

1313
// Create TaskData
14-
auto taskData = std::make_shared<ppc::core::TaskData>();
15-
taskData->inputs.emplace_back(reinterpret_cast<uint8_t *>(in.data()));
16-
taskData->inputs_count.emplace_back(in.size());
17-
taskData->outputs.emplace_back(reinterpret_cast<uint8_t *>(out.data()));
18-
taskData->outputs_count.emplace_back(out.size());
14+
auto task_data = std::make_shared<ppc::core::TaskData>();
15+
task_data->inputs.emplace_back(reinterpret_cast<uint8_t *>(in.data()));
16+
task_data->inputs_count.emplace_back(in.size());
17+
task_data->outputs.emplace_back(reinterpret_cast<uint8_t *>(out.data()));
18+
task_data->outputs_count.emplace_back(out.size());
1919

2020
// Create Task
21-
auto testTask = std::make_shared<ppc::test::perf::TestTask<uint32_t>>(taskData);
21+
auto test_task = std::make_shared<ppc::test::perf::TestTask<uint32_t>>(task_data);
2222

2323
// Create Perf attributes
24-
auto perfAttr = std::make_shared<ppc::core::PerfAttr>();
25-
perfAttr->num_running = 10;
24+
auto perf_attr = std::make_shared<ppc::core::PerfAttr>();
25+
perf_attr->num_running = 10;
2626

2727
// Create and init perf results
28-
auto perfResults = std::make_shared<ppc::core::PerfResults>();
28+
auto perf_results = std::make_shared<ppc::core::PerfResults>();
2929

3030
// Create Perf analyzer
31-
ppc::core::Perf perfAnalyzer(testTask);
32-
perfAnalyzer.pipeline_run(perfAttr, perfResults);
31+
ppc::core::Perf perf_analyzer(test_task);
32+
perf_analyzer.pipeline_run(perf_attr, perf_results);
3333

3434
// Get perf statistic
35-
ppc::core::Perf::print_perf_statistic(perfResults);
36-
ASSERT_LE(perfResults->time_sec, ppc::core::PerfResults::MAX_TIME);
35+
ppc::core::Perf::print_perf_statistic(perf_results);
36+
ASSERT_LE(perf_results->time_sec, ppc::core::PerfResults::MAX_TIME);
3737
EXPECT_EQ(out[0], in.size());
3838
}
3939

@@ -43,29 +43,29 @@ TEST(perf_tests, check_perf_pipeline_float) {
4343
std::vector<float> out(1, 0);
4444

4545
// Create TaskData
46-
auto taskData = std::make_shared<ppc::core::TaskData>();
47-
taskData->inputs.emplace_back(reinterpret_cast<uint8_t *>(in.data()));
48-
taskData->inputs_count.emplace_back(in.size());
49-
taskData->outputs.emplace_back(reinterpret_cast<uint8_t *>(out.data()));
50-
taskData->outputs_count.emplace_back(out.size());
46+
auto task_data = std::make_shared<ppc::core::TaskData>();
47+
task_data->inputs.emplace_back(reinterpret_cast<uint8_t *>(in.data()));
48+
task_data->inputs_count.emplace_back(in.size());
49+
task_data->outputs.emplace_back(reinterpret_cast<uint8_t *>(out.data()));
50+
task_data->outputs_count.emplace_back(out.size());
5151

5252
// Create Task
53-
auto testTask = std::make_shared<ppc::test::perf::TestTask<float>>(taskData);
53+
auto test_task = std::make_shared<ppc::test::perf::TestTask<float>>(task_data);
5454

5555
// Create Perf attributes
56-
auto perfAttr = std::make_shared<ppc::core::PerfAttr>();
57-
perfAttr->num_running = 10;
56+
auto perf_attr = std::make_shared<ppc::core::PerfAttr>();
57+
perf_attr->num_running = 10;
5858

5959
// Create and init perf results
60-
auto perfResults = std::make_shared<ppc::core::PerfResults>();
60+
auto perf_results = std::make_shared<ppc::core::PerfResults>();
6161

6262
// Create Perf analyzer
63-
ppc::core::Perf perfAnalyzer(testTask);
64-
perfAnalyzer.pipeline_run(perfAttr, perfResults);
63+
ppc::core::Perf perf_analyzer(test_task);
64+
perf_analyzer.pipeline_run(perf_attr, perf_results);
6565

6666
// Get perf statistic
67-
ppc::core::Perf::print_perf_statistic(perfResults);
68-
ASSERT_LE(perfResults->time_sec, ppc::core::PerfResults::MAX_TIME);
67+
ppc::core::Perf::print_perf_statistic(perf_results);
68+
ASSERT_LE(perf_results->time_sec, ppc::core::PerfResults::MAX_TIME);
6969
EXPECT_EQ(out[0], in.size());
7070
}
7171

@@ -75,34 +75,34 @@ TEST(perf_tests, check_perf_pipeline_uint8_t_slow_test) {
7575
std::vector<uint8_t> out(1, 0);
7676

7777
// Create TaskData
78-
auto taskData = std::make_shared<ppc::core::TaskData>();
79-
taskData->inputs.emplace_back(reinterpret_cast<uint8_t *>(in.data()));
80-
taskData->inputs_count.emplace_back(in.size());
81-
taskData->outputs.emplace_back(reinterpret_cast<uint8_t *>(out.data()));
82-
taskData->outputs_count.emplace_back(out.size());
78+
auto task_data = std::make_shared<ppc::core::TaskData>();
79+
task_data->inputs.emplace_back(reinterpret_cast<uint8_t *>(in.data()));
80+
task_data->inputs_count.emplace_back(in.size());
81+
task_data->outputs.emplace_back(reinterpret_cast<uint8_t *>(out.data()));
82+
task_data->outputs_count.emplace_back(out.size());
8383

8484
// Create Task
85-
auto testTask = std::make_shared<ppc::test::perf::FakePerfTask<uint8_t>>(taskData);
85+
auto test_task = std::make_shared<ppc::test::perf::FakePerfTask<uint8_t>>(task_data);
8686
// Create Perf attributes
87-
auto perfAttr = std::make_shared<ppc::core::PerfAttr>();
88-
perfAttr->num_running = 1;
87+
auto perf_attr = std::make_shared<ppc::core::PerfAttr>();
88+
perf_attr->num_running = 1;
8989
const auto t0 = std::chrono::high_resolution_clock::now();
90-
perfAttr->current_timer = [&] {
90+
perf_attr->current_timer = [&] {
9191
auto current_time_point = std::chrono::high_resolution_clock::now();
9292
auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(current_time_point - t0).count();
9393
return static_cast<double>(duration) * 1e-9;
9494
};
9595

9696
// Create and init perf results
97-
auto perfResults = std::make_shared<ppc::core::PerfResults>();
97+
auto perf_results = std::make_shared<ppc::core::PerfResults>();
9898

9999
// Create Perf analyzer
100-
ppc::core::Perf perfAnalyzer(testTask);
101-
perfAnalyzer.pipeline_run(perfAttr, perfResults);
100+
ppc::core::Perf perf_analyzer(test_task);
101+
perf_analyzer.pipeline_run(perf_attr, perf_results);
102102

103103
// Get perf statistic
104-
ASSERT_ANY_THROW(ppc::core::Perf::print_perf_statistic(perfResults));
105-
ASSERT_GE(perfResults->time_sec, ppc::core::PerfResults::MAX_TIME);
104+
ASSERT_ANY_THROW(ppc::core::Perf::print_perf_statistic(perf_results));
105+
ASSERT_GE(perf_results->time_sec, ppc::core::PerfResults::MAX_TIME);
106106
EXPECT_EQ(out[0], in.size());
107107
}
108108

@@ -112,30 +112,30 @@ TEST(perf_tests, check_perf_task) {
112112
std::vector<uint32_t> out(1, 0);
113113

114114
// Create TaskData
115-
auto taskData = std::make_shared<ppc::core::TaskData>();
116-
taskData->inputs.emplace_back(reinterpret_cast<uint8_t *>(in.data()));
117-
taskData->inputs_count.emplace_back(in.size());
118-
taskData->outputs.emplace_back(reinterpret_cast<uint8_t *>(out.data()));
119-
taskData->outputs_count.emplace_back(out.size());
115+
auto task_data = std::make_shared<ppc::core::TaskData>();
116+
task_data->inputs.emplace_back(reinterpret_cast<uint8_t *>(in.data()));
117+
task_data->inputs_count.emplace_back(in.size());
118+
task_data->outputs.emplace_back(reinterpret_cast<uint8_t *>(out.data()));
119+
task_data->outputs_count.emplace_back(out.size());
120120

121121
// Create Task
122-
auto testTask = std::make_shared<ppc::test::perf::TestTask<uint32_t>>(taskData);
122+
auto test_task = std::make_shared<ppc::test::perf::TestTask<uint32_t>>(task_data);
123123

124124
// Create Perf attributes
125-
auto perfAttr = std::make_shared<ppc::core::PerfAttr>();
126-
perfAttr->num_running = 10;
125+
auto perf_attr = std::make_shared<ppc::core::PerfAttr>();
126+
perf_attr->num_running = 10;
127127

128128
// Create and init perf results
129-
auto perfResults = std::make_shared<ppc::core::PerfResults>();
129+
auto perf_results = std::make_shared<ppc::core::PerfResults>();
130130

131131
// Create Perf analyzer
132-
ppc::core::Perf perfAnalyzer(testTask);
133-
perfAnalyzer.task_run(perfAttr, perfResults);
132+
ppc::core::Perf perf_analyzer(test_task);
133+
perf_analyzer.task_run(perf_attr, perf_results);
134134

135135
// Get perf statistic
136-
perfResults->type_of_running = ppc::core::PerfResults::NONE;
137-
ppc::core::Perf::print_perf_statistic(perfResults);
138-
ASSERT_LE(perfResults->time_sec, ppc::core::PerfResults::MAX_TIME);
136+
perf_results->type_of_running = ppc::core::PerfResults::NONE;
137+
ppc::core::Perf::print_perf_statistic(perf_results);
138+
ASSERT_LE(perf_results->time_sec, ppc::core::PerfResults::MAX_TIME);
139139
EXPECT_EQ(out[0], in.size());
140140
}
141141

@@ -145,29 +145,29 @@ TEST(perf_tests, check_perf_task_float) {
145145
std::vector<float> out(1, 0);
146146

147147
// Create TaskData
148-
auto taskData = std::make_shared<ppc::core::TaskData>();
149-
taskData->inputs.emplace_back(reinterpret_cast<uint8_t *>(in.data()));
150-
taskData->inputs_count.emplace_back(in.size());
151-
taskData->outputs.emplace_back(reinterpret_cast<uint8_t *>(out.data()));
152-
taskData->outputs_count.emplace_back(out.size());
148+
auto task_data = std::make_shared<ppc::core::TaskData>();
149+
task_data->inputs.emplace_back(reinterpret_cast<uint8_t *>(in.data()));
150+
task_data->inputs_count.emplace_back(in.size());
151+
task_data->outputs.emplace_back(reinterpret_cast<uint8_t *>(out.data()));
152+
task_data->outputs_count.emplace_back(out.size());
153153

154154
// Create Task
155-
auto testTask = std::make_shared<ppc::test::perf::TestTask<float>>(taskData);
155+
auto test_task = std::make_shared<ppc::test::perf::TestTask<float>>(task_data);
156156

157157
// Create Perf attributes
158-
auto perfAttr = std::make_shared<ppc::core::PerfAttr>();
159-
perfAttr->num_running = 10;
158+
auto perf_attr = std::make_shared<ppc::core::PerfAttr>();
159+
perf_attr->num_running = 10;
160160

161161
// Create and init perf results
162-
auto perfResults = std::make_shared<ppc::core::PerfResults>();
162+
auto perf_results = std::make_shared<ppc::core::PerfResults>();
163163

164164
// Create Perf analyzer
165-
ppc::core::Perf perfAnalyzer(testTask);
166-
perfAnalyzer.task_run(perfAttr, perfResults);
165+
ppc::core::Perf perf_analyzer(test_task);
166+
perf_analyzer.task_run(perf_attr, perf_results);
167167

168168
// Get perf statistic
169-
perfResults->type_of_running = ppc::core::PerfResults::PIPELINE;
170-
ppc::core::Perf::print_perf_statistic(perfResults);
171-
ASSERT_LE(perfResults->time_sec, ppc::core::PerfResults::MAX_TIME);
169+
perf_results->type_of_running = ppc::core::PerfResults::PIPELINE;
170+
ppc::core::Perf::print_perf_statistic(perf_results);
171+
ASSERT_LE(perf_results->time_sec, ppc::core::PerfResults::MAX_TIME);
172172
EXPECT_EQ(out[0], in.size());
173173
}

0 commit comments

Comments
 (0)