Skip to content

Commit 8f53edf

Browse files
authored
Remove NOLINTs (#457)
1 parent 5cc9422 commit 8f53edf

File tree

25 files changed

+211
-67
lines changed

25 files changed

+211
-67
lines changed

.clang-tidy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Checks: >
2626
-modernize-avoid-c-arrays,
2727
-modernize-loop-convert,
2828
-modernize-use-trailing-return-type,
29+
-portability-template-virtual-member-function,
2930
-readability-magic-numbers
3031
3132
WarningsAsErrors: "*"
@@ -81,7 +82,7 @@ CheckOptions:
8182
value: 1
8283
# Functions with scores beyond 15 are typically flagged as potentially problematic (empirically)
8384
- key: readability-function-cognitive-complexity.Threshold
84-
value: 20 # default: 25
85+
value: 15 # default: 25
8586
- key: readability-identifier-length.MinimumVariableNameLength
8687
value: 1
8788
- key: readability-identifier-length.MinimumParameterNameLength

.github/workflows/static-analysis-pr.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ jobs:
2929
cmake -S . -B build -G Ninja
3030
-D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache
3131
-D CMAKE_BUILD_TYPE=RELEASE -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
32-
config_file: .clang-tidy
3332
exclude: 3rdparty
33+
clang_tidy_checks: ""
3434
split_workflow: true
3535
clang_tidy_version: "19"
3636
lgtm_comment_body: ""
@@ -62,8 +62,8 @@ jobs:
6262
cmake -S . -B build -G Ninja
6363
-D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache
6464
-D CMAKE_BUILD_TYPE=RELEASE -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
65-
config_file: .clang-tidy
6665
exclude: 3rdparty
66+
clang_tidy_checks: ""
6767
split_workflow: true
6868
clang_tidy_version: "19"
6969
lgtm_comment_body: ""
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
InheritParentConfig: true
2+
3+
Checks: >
4+
bugprone-*,
5+
clang-diagnostic-*,
6+
concurrency-*,
7+
cppcoreguidelines-*,
8+
llvm-include-order,
9+
llvm-namespace-comment,
10+
misc-*,
11+
modernize-*,
12+
mpi-*,
13+
openmp-*,
14+
performance-*,
15+
portability-*,
16+
readability-*,
17+
-bugprone-casting-through-void,
18+
-bugprone-easily-swappable-parameters,
19+
-cppcoreguidelines-avoid-magic-numbers,
20+
-cppcoreguidelines-non-private-member-variables-in-classes,
21+
-cppcoreguidelines-owning-memory,
22+
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
23+
-cppcoreguidelines-pro-type-reinterpret-cast,
24+
-cppcoreguidelines-pro-type-vararg,
25+
-cppcoreguidelines-special-member-functions,
26+
-misc-const-correctness,
27+
-misc-non-private-member-variables-in-classes,
28+
-modernize-avoid-c-arrays,
29+
-modernize-loop-convert,
30+
-modernize-use-trailing-return-type,
31+
-portability-template-virtual-member-function,
32+
-readability-magic-numbers,
33+
-cppcoreguidelines-avoid-goto,
34+
-cppcoreguidelines-avoid-non-const-global-variables,
35+
-misc-use-anonymous-namespace,
36+
-modernize-use-std-print,
37+
-modernize-type-traits,
38+
39+
CheckOptions:
40+
- key: readability-function-cognitive-complexity.Threshold
41+
value: 50 # default: 25

modules/core/performance/tests/perf_tests.cpp

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ TEST(perf_tests, check_perf_pipeline_uint8_t_slow_test) {
6363
};
6464
perf_analyzer.PipelineRun(perf_attr);
6565

66-
ASSERT_ANY_THROW_NOLINT(perf_analyzer.PrintPerfStatistic("check_perf_pipeline_uint8_t_slow_test"));
66+
ASSERT_ANY_THROW(perf_analyzer.PrintPerfStatistic("check_perf_pipeline_uint8_t_slow_test"));
6767
}
6868

6969
TEST(perf_tests, check_perf_task_exception) {
@@ -73,7 +73,7 @@ TEST(perf_tests, check_perf_task_exception) {
7373

7474
ppc::core::Perf<std::vector<uint32_t>, uint32_t> perf_analyzer(test_task);
7575

76-
ASSERT_ANY_THROW_NOLINT(perf_analyzer.PrintPerfStatistic("check_perf_task_exception"));
76+
ASSERT_ANY_THROW(perf_analyzer.PrintPerfStatistic("check_perf_task_exception"));
7777

7878
ppc::core::PerfAttr perf_attr;
7979
perf_analyzer.TaskRun(perf_attr);
@@ -109,12 +109,13 @@ TEST_P(GetStringParamNameParamTest, ReturnsExpectedString) {
109109
EXPECT_EQ(ppc::core::GetStringParamName(param.input), param.expected_output);
110110
}
111111

112-
INSTANTIATE_TEST_SUITE_P_WITH_NAME(
113-
ParamTests, GetStringParamNameParamTest,
114-
::testing::Values(ParamTestCase{ppc::core::PerfResults::kTaskRun, "task_run"},
115-
ParamTestCase{ppc::core::PerfResults::kPipeline, "pipeline"},
116-
ParamTestCase{ppc::core::PerfResults::TypeOfRunning::kNone, "none"}),
117-
[](const ::testing::TestParamInfo<ParamTestCase>& info) { return info.param.expected_output; });
112+
INSTANTIATE_TEST_SUITE_P(ParamTests, GetStringParamNameParamTest,
113+
::testing::Values(ParamTestCase{ppc::core::PerfResults::kTaskRun, "task_run"},
114+
ParamTestCase{ppc::core::PerfResults::kPipeline, "pipeline"},
115+
ParamTestCase{ppc::core::PerfResults::TypeOfRunning::kNone, "none"}),
116+
[](const ::testing::TestParamInfo<ParamTestCase>& info) {
117+
return info.param.expected_output;
118+
});
118119

119120
struct TaskTypeTestCase {
120121
ppc::core::TypeOfTask type;
@@ -151,22 +152,22 @@ TEST_P(GetStringTaskTypeTest, ReturnsExpectedString) {
151152
EXPECT_EQ(GetStringTaskType(param.type, temp_path), param.expected) << "Failed on: " << param.label;
152153
}
153154

154-
INSTANTIATE_TEST_SUITE_P_NOLINT(AllTypeCases, GetStringTaskTypeTest,
155-
::testing::Values(TaskTypeTestCase{ppc::core::TypeOfTask::kALL, "all_ALL", "kALL"},
156-
TaskTypeTestCase{ppc::core::TypeOfTask::kSTL, "stl_STL", "kSTL"},
157-
TaskTypeTestCase{ppc::core::TypeOfTask::kOMP, "omp_OMP", "kOMP"},
158-
TaskTypeTestCase{ppc::core::TypeOfTask::kMPI, "mpi_MPI", "kMPI"},
159-
TaskTypeTestCase{ppc::core::TypeOfTask::kTBB, "tbb_TBB", "kTBB"},
160-
TaskTypeTestCase{ppc::core::TypeOfTask::kSEQ, "seq_SEQ", "kSEQ"}));
155+
INSTANTIATE_TEST_SUITE_P(AllTypeCases, GetStringTaskTypeTest,
156+
::testing::Values(TaskTypeTestCase{ppc::core::TypeOfTask::kALL, "all_ALL", "kALL"},
157+
TaskTypeTestCase{ppc::core::TypeOfTask::kSTL, "stl_STL", "kSTL"},
158+
TaskTypeTestCase{ppc::core::TypeOfTask::kOMP, "omp_OMP", "kOMP"},
159+
TaskTypeTestCase{ppc::core::TypeOfTask::kMPI, "mpi_MPI", "kMPI"},
160+
TaskTypeTestCase{ppc::core::TypeOfTask::kTBB, "tbb_TBB", "kTBB"},
161+
TaskTypeTestCase{ppc::core::TypeOfTask::kSEQ, "seq_SEQ", "kSEQ"}));
161162

162-
TEST_NOLINT(GetStringTaskTypeStandaloneTest, ThrowsIfFileMissing) {
163+
TEST(GetStringTaskTypeStandaloneTest, ThrowsIfFileMissing) {
163164
std::string missing_path = "non_existent_settings.json";
164-
EXPECT_THROW_NOLINT(GetStringTaskType(ppc::core::TypeOfTask::kSEQ, missing_path), std::runtime_error);
165+
EXPECT_THROW(GetStringTaskType(ppc::core::TypeOfTask::kSEQ, missing_path), std::runtime_error);
165166
}
166167

167-
TEST_NOLINT(GetStringTaskTypeStandaloneTest, ExceptionMessageContainsPath) {
168+
TEST(GetStringTaskTypeStandaloneTest, ExceptionMessageContainsPath) {
168169
const std::string missing_path = "non_existent_settings.json";
169-
EXPECT_THROW_NOLINT(
170+
EXPECT_THROW(
170171
try { GetStringTaskType(ppc::core::TypeOfTask::kSEQ, missing_path); } catch (const std::runtime_error& e) {
171172
EXPECT_NE(std::string(e.what()).find(missing_path), std::string::npos);
172173
throw;
@@ -184,23 +185,22 @@ TEST(GetStringTaskTypeStandaloneTest, ReturnsUnknownForInvalidEnum) {
184185
std::filesystem::remove(path);
185186
}
186187

187-
TEST_NOLINT(GetStringTaskTypeEdgeCases, ThrowsIfFileCannotBeOpened) {
188-
EXPECT_THROW_NOLINT(GetStringTaskType(ppc::core::TypeOfTask::kSEQ, "definitely_missing_file.json"),
189-
std::runtime_error);
188+
TEST(GetStringTaskTypeEdgeCases, ThrowsIfFileCannotBeOpened) {
189+
EXPECT_THROW(GetStringTaskType(ppc::core::TypeOfTask::kSEQ, "definitely_missing_file.json"), std::runtime_error);
190190
}
191191

192-
TEST_NOLINT(GetStringTaskTypeEdgeCases, ThrowsIfJsonIsMalformed) {
192+
TEST(GetStringTaskTypeEdgeCases, ThrowsIfJsonIsMalformed) {
193193
std::string path = (std::filesystem::temp_directory_path() / "bad_json.json").string();
194194
std::ofstream(path) << "{ this is not valid json ";
195-
EXPECT_THROW_NOLINT(GetStringTaskType(ppc::core::TypeOfTask::kSEQ, path), NlohmannJsonParseError);
195+
EXPECT_THROW(GetStringTaskType(ppc::core::TypeOfTask::kSEQ, path), NlohmannJsonParseError);
196196
std::filesystem::remove(path);
197197
}
198198

199-
TEST_NOLINT(GetStringTaskTypeEdgeCases, ThrowsIfJsonValueIsNull) {
199+
TEST(GetStringTaskTypeEdgeCases, ThrowsIfJsonValueIsNull) {
200200
std::string path = (std::filesystem::temp_directory_path() / "null_value.json").string();
201201
std::ofstream(path) << R"({"tasks": { "seq": null }})";
202202

203-
EXPECT_THROW_NOLINT(GetStringTaskType(ppc::core::TypeOfTask::kSEQ, path), NlohmannJsonTypeError);
203+
EXPECT_THROW(GetStringTaskType(ppc::core::TypeOfTask::kSEQ, path), NlohmannJsonTypeError);
204204

205205
std::filesystem::remove(path);
206206
}
@@ -237,9 +237,9 @@ TEST(TaskTest, GetDynamicTypeReturnsCorrectEnum) {
237237
EXPECT_EQ(task.GetDynamicTypeOfTask(), ppc::core::TypeOfTask::kOMP);
238238
}
239239

240-
TEST_NOLINT(TaskTest, DestructorTerminatesIfWrongOrder) {
240+
TEST(TaskTest, DestructorTerminatesIfWrongOrder) {
241241
testing::FLAGS_gtest_death_test_style = "threadsafe";
242-
ASSERT_DEATH_IF_SUPPORTED_NOLINT(
242+
ASSERT_DEATH_IF_SUPPORTED(
243243
{
244244
DummyTask task;
245245
task.Run();
@@ -262,7 +262,7 @@ using TestTypes = ::testing::Types<my::nested::Type, my::Another, int>;
262262

263263
TYPED_TEST_SUITE(GetNamespaceTest, TestTypes);
264264

265-
TYPED_TEST_NOLINT(GetNamespaceTest, ExtractsNamespaceCorrectly) {
265+
TYPED_TEST(GetNamespaceTest, ExtractsNamespaceCorrectly) {
266266
constexpr std::string_view kNs = ppc::util::GetNamespace<TypeParam>();
267267

268268
if constexpr (std::is_same_v<TypeParam, my::nested::Type>) {

modules/core/runners/src/runners.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
#include <gtest/gtest.h>
44
#include <mpi.h>
5-
#include <omp.h>
65

7-
#include <cstdio>
86
#include <cstdlib>
97
#include <format>
108
#include <iostream>

modules/core/task/include/task.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <sstream>
1515
#include <stdexcept>
1616
#include <string>
17+
#include <vector>
1718

1819
namespace ppc::core {
1920

modules/core/task/tests/.clang-tidy

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
InheritParentConfig: true
2+
3+
Checks: >
4+
bugprone-*,
5+
clang-diagnostic-*,
6+
concurrency-*,
7+
cppcoreguidelines-*,
8+
llvm-include-order,
9+
llvm-namespace-comment,
10+
misc-*,
11+
modernize-*,
12+
mpi-*,
13+
openmp-*,
14+
performance-*,
15+
portability-*,
16+
readability-*,
17+
-bugprone-casting-through-void,
18+
-bugprone-easily-swappable-parameters,
19+
-cppcoreguidelines-avoid-magic-numbers,
20+
-cppcoreguidelines-non-private-member-variables-in-classes,
21+
-cppcoreguidelines-owning-memory,
22+
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
23+
-cppcoreguidelines-pro-type-reinterpret-cast,
24+
-cppcoreguidelines-pro-type-vararg,
25+
-cppcoreguidelines-special-member-functions,
26+
-misc-const-correctness,
27+
-misc-non-private-member-variables-in-classes,
28+
-modernize-avoid-c-arrays,
29+
-modernize-loop-convert,
30+
-modernize-use-trailing-return-type,
31+
-portability-template-virtual-member-function,
32+
-readability-magic-numbers,
33+
-cppcoreguidelines-avoid-goto,
34+
-cppcoreguidelines-avoid-non-const-global-variables,
35+
-misc-use-anonymous-namespace,
36+
-modernize-use-std-print,
37+
-modernize-type-traits,
38+
39+
CheckOptions:
40+
- key: readability-function-cognitive-complexity.Threshold
41+
value: 50 # default: 25

modules/core/task/tests/task_tests.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include <vector>
66

77
#include "core/task/tests/test_task.hpp"
8-
#include "core/util/include/util.hpp"
98

109
TEST(task_tests, check_int32_t) {
1110
// Create data
@@ -128,7 +127,7 @@ TEST(task_tests, check_float) {
128127
EXPECT_NEAR(test_task.GetOutput(), in.size(), 1e-3);
129128
}
130129

131-
TEST_NOLINT(task_tests, check_wrong_order_disabled_valgrind) {
130+
TEST(task_tests, check_wrong_order_disabled_valgrind) {
132131
auto destroy_function = [] {
133132
// Create data
134133
std::vector<float> in(20, 1);
@@ -143,7 +142,7 @@ TEST_NOLINT(task_tests, check_wrong_order_disabled_valgrind) {
143142
EXPECT_DEATH_IF_SUPPORTED(destroy_function(), ".*ORDER OF FUNCTIONS IS NOT RIGHT.*");
144143
}
145144

146-
TEST_NOLINT(task_tests, check_empty_order_disabled_valgrind) {
145+
TEST(task_tests, check_empty_order_disabled_valgrind) {
147146
auto destroy_function = [] {
148147
// Create data
149148
std::vector<float> in(20, 1);

modules/core/task/tests/test_task.hpp

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

33
#include <chrono>
44
#include <thread>
5-
#include <vector>
65

76
#include "core/task/include/task.hpp"
87

modules/core/util/include/func_test_util.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#pragma once
22

33
#include <gtest/gtest.h>
4-
#include <omp.h>
54
#include <tbb/tick_count.h>
65

76
#include <concepts>

modules/core/util/include/perf_test_util.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ auto MakePerfTaskTuples(const std::string& settings_path) {
115115
}
116116

117117
template <typename Tuple, std::size_t... I>
118-
auto TupleToGTestValuesImpl(Tuple&& tup, std::index_sequence<I...> /*unused*/) {
119-
return ::testing::Values(std::get<I>(std::forward<Tuple>(tup))...);
118+
auto TupleToGTestValuesImpl(const Tuple& tup, std::index_sequence<I...> /*unused*/) {
119+
return ::testing::Values(std::get<I>(tup)...);
120120
}
121121

122122
template <typename Tuple>

modules/core/util/include/util.hpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,25 @@
66
#include <string>
77
#include <string_view>
88

9+
#include "nlohmann/json_fwd.hpp"
10+
911
#define PPC_FUNC_NAME __func__
1012

1113
#ifdef _MSC_VER
1214
#pragma warning(push)
1315
#pragma warning(disable : 4459)
1416
#endif
1517

16-
#include <nlohmann/json.hpp> // NOLINT(misc-include-cleaner)
18+
#include <nlohmann/json.hpp>
1719

1820
/// @brief JSON namespace used for settings and config parsing.
19-
using NlohmannJsonParseError = nlohmann::json::parse_error; // NOLINT(misc-include-cleaner)
21+
using NlohmannJsonParseError = nlohmann::json::parse_error;
2022
/// @brief JSON namespace used for settings and config typing.
21-
using NlohmannJsonTypeError = nlohmann::json::type_error; // NOLINT(misc-include-cleaner)
23+
using NlohmannJsonTypeError = nlohmann::json::type_error;
2224
#ifdef _MSC_VER
2325
#pragma warning(pop)
2426
#endif
2527

26-
#define ASSERT_ANY_THROW_NOLINT(stmt) ASSERT_ANY_THROW(stmt) // NOLINT
27-
#define EXPECT_THROW_NOLINT(stmt, error) EXPECT_THROW(stmt, error) // NOLINT
28-
#define TEST_NOLINT(test_suite_name, test_name) TEST(test_suite_name, test_name) // NOLINT
29-
#define ASSERT_DEATH_IF_SUPPORTED_NOLINT(stmt, name) ASSERT_DEATH_IF_SUPPORTED(stmt, name) // NOLINT
30-
#define TYPED_TEST_NOLINT(test_suite_name, test_name) TYPED_TEST(test_suite_name, test_name) // NOLINT
31-
#define INSTANTIATE_TEST_SUITE_P_WITH_NAME(n, t, g, ng) INSTANTIATE_TEST_SUITE_P(n, t, g, ng) // NOLINT
32-
#define INSTANTIATE_TEST_SUITE_P_NOLINT(n, t, g) INSTANTIATE_TEST_SUITE_P(n, t, g) // NOLINT
33-
// INSTANTIATE_TEST_SUITE_P | n, t, g, ng == name, test_case_name, generator, name_generator
34-
3528
namespace ppc::util {
3629

3730
enum GTestParamIndex : uint8_t { kTaskGetter, kNameTest, kTestParams };
@@ -97,7 +90,6 @@ constexpr std::string_view GetNamespace() {
9790
#endif
9891
}
9992

100-
// NOLINTNEXTLINE(misc-include-cleaner)
10193
inline std::shared_ptr<nlohmann::json> InitJSONPtr() { return std::make_shared<nlohmann::json>(); }
10294

10395
bool IsUnderMpirun();

tasks/example_processes/mpi/src/ops_mpi.cpp

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

33
#include <mpi.h>
44

5-
#include <cmath>
65
#include <numeric>
76
#include <vector>
87

tasks/example_processes/seq/src/ops_seq.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "example_processes/seq/include/ops_seq.hpp"
22

3-
#include <cmath>
43
#include <numeric>
54
#include <vector>
65

0 commit comments

Comments
 (0)