Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Checks: >
-modernize-avoid-c-arrays,
-modernize-loop-convert,
-modernize-use-trailing-return-type,
-portability-template-virtual-member-function,
-readability-magic-numbers

WarningsAsErrors: "*"
Expand Down Expand Up @@ -81,7 +82,7 @@ CheckOptions:
value: 1
# Functions with scores beyond 15 are typically flagged as potentially problematic (empirically)
- key: readability-function-cognitive-complexity.Threshold
value: 20 # default: 25
value: 15 # default: 25
- key: readability-identifier-length.MinimumVariableNameLength
value: 1
- key: readability-identifier-length.MinimumParameterNameLength
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/static-analysis-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ jobs:
cmake -S . -B build -G Ninja
-D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache
-D CMAKE_BUILD_TYPE=RELEASE -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
config_file: .clang-tidy
exclude: 3rdparty
clang_tidy_checks: ""
split_workflow: true
clang_tidy_version: "19"
lgtm_comment_body: ""
Expand Down Expand Up @@ -62,8 +62,8 @@ jobs:
cmake -S . -B build -G Ninja
-D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache
-D CMAKE_BUILD_TYPE=RELEASE -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
config_file: .clang-tidy
exclude: 3rdparty
clang_tidy_checks: ""
split_workflow: true
clang_tidy_version: "19"
lgtm_comment_body: ""
Expand Down
41 changes: 41 additions & 0 deletions modules/core/performance/tests/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
InheritParentConfig: true

Checks: >
bugprone-*,
clang-diagnostic-*,
concurrency-*,
cppcoreguidelines-*,
llvm-include-order,
llvm-namespace-comment,
misc-*,
modernize-*,
mpi-*,
openmp-*,
performance-*,
portability-*,
readability-*,
-bugprone-casting-through-void,
-bugprone-easily-swappable-parameters,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-owning-memory,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-cppcoreguidelines-pro-type-reinterpret-cast,
-cppcoreguidelines-pro-type-vararg,
-cppcoreguidelines-special-member-functions,
-misc-const-correctness,
-misc-non-private-member-variables-in-classes,
-modernize-avoid-c-arrays,
-modernize-loop-convert,
-modernize-use-trailing-return-type,
-portability-template-virtual-member-function,
-readability-magic-numbers,
-cppcoreguidelines-avoid-goto,
-cppcoreguidelines-avoid-non-const-global-variables,
-misc-use-anonymous-namespace,
-modernize-use-std-print,
-modernize-type-traits,

CheckOptions:
- key: readability-function-cognitive-complexity.Threshold
value: 50 # default: 25
58 changes: 29 additions & 29 deletions modules/core/performance/tests/perf_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ TEST(perf_tests, check_perf_pipeline_uint8_t_slow_test) {
};
perf_analyzer.PipelineRun(perf_attr);

ASSERT_ANY_THROW_NOLINT(perf_analyzer.PrintPerfStatistic("check_perf_pipeline_uint8_t_slow_test"));
ASSERT_ANY_THROW(perf_analyzer.PrintPerfStatistic("check_perf_pipeline_uint8_t_slow_test"));
}

TEST(perf_tests, check_perf_task_exception) {
Expand All @@ -73,7 +73,7 @@ TEST(perf_tests, check_perf_task_exception) {

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

ASSERT_ANY_THROW_NOLINT(perf_analyzer.PrintPerfStatistic("check_perf_task_exception"));
ASSERT_ANY_THROW(perf_analyzer.PrintPerfStatistic("check_perf_task_exception"));

ppc::core::PerfAttr perf_attr;
perf_analyzer.TaskRun(perf_attr);
Expand Down Expand Up @@ -109,12 +109,13 @@ TEST_P(GetStringParamNameParamTest, ReturnsExpectedString) {
EXPECT_EQ(ppc::core::GetStringParamName(param.input), param.expected_output);
}

INSTANTIATE_TEST_SUITE_P_WITH_NAME(
ParamTests, GetStringParamNameParamTest,
::testing::Values(ParamTestCase{ppc::core::PerfResults::kTaskRun, "task_run"},
ParamTestCase{ppc::core::PerfResults::kPipeline, "pipeline"},
ParamTestCase{ppc::core::PerfResults::TypeOfRunning::kNone, "none"}),
[](const ::testing::TestParamInfo<ParamTestCase>& info) { return info.param.expected_output; });
INSTANTIATE_TEST_SUITE_P(ParamTests, GetStringParamNameParamTest,
::testing::Values(ParamTestCase{ppc::core::PerfResults::kTaskRun, "task_run"},
ParamTestCase{ppc::core::PerfResults::kPipeline, "pipeline"},
ParamTestCase{ppc::core::PerfResults::TypeOfRunning::kNone, "none"}),
[](const ::testing::TestParamInfo<ParamTestCase>& info) {
return info.param.expected_output;
});

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

INSTANTIATE_TEST_SUITE_P_NOLINT(AllTypeCases, GetStringTaskTypeTest,
::testing::Values(TaskTypeTestCase{ppc::core::TypeOfTask::kALL, "all_ALL", "kALL"},
TaskTypeTestCase{ppc::core::TypeOfTask::kSTL, "stl_STL", "kSTL"},
TaskTypeTestCase{ppc::core::TypeOfTask::kOMP, "omp_OMP", "kOMP"},
TaskTypeTestCase{ppc::core::TypeOfTask::kMPI, "mpi_MPI", "kMPI"},
TaskTypeTestCase{ppc::core::TypeOfTask::kTBB, "tbb_TBB", "kTBB"},
TaskTypeTestCase{ppc::core::TypeOfTask::kSEQ, "seq_SEQ", "kSEQ"}));
INSTANTIATE_TEST_SUITE_P(AllTypeCases, GetStringTaskTypeTest,
::testing::Values(TaskTypeTestCase{ppc::core::TypeOfTask::kALL, "all_ALL", "kALL"},
TaskTypeTestCase{ppc::core::TypeOfTask::kSTL, "stl_STL", "kSTL"},
TaskTypeTestCase{ppc::core::TypeOfTask::kOMP, "omp_OMP", "kOMP"},
TaskTypeTestCase{ppc::core::TypeOfTask::kMPI, "mpi_MPI", "kMPI"},
TaskTypeTestCase{ppc::core::TypeOfTask::kTBB, "tbb_TBB", "kTBB"},
TaskTypeTestCase{ppc::core::TypeOfTask::kSEQ, "seq_SEQ", "kSEQ"}));

TEST_NOLINT(GetStringTaskTypeStandaloneTest, ThrowsIfFileMissing) {
TEST(GetStringTaskTypeStandaloneTest, ThrowsIfFileMissing) {
std::string missing_path = "non_existent_settings.json";
EXPECT_THROW_NOLINT(GetStringTaskType(ppc::core::TypeOfTask::kSEQ, missing_path), std::runtime_error);
EXPECT_THROW(GetStringTaskType(ppc::core::TypeOfTask::kSEQ, missing_path), std::runtime_error);
}

TEST_NOLINT(GetStringTaskTypeStandaloneTest, ExceptionMessageContainsPath) {
TEST(GetStringTaskTypeStandaloneTest, ExceptionMessageContainsPath) {
const std::string missing_path = "non_existent_settings.json";
EXPECT_THROW_NOLINT(
EXPECT_THROW(
try { GetStringTaskType(ppc::core::TypeOfTask::kSEQ, missing_path); } catch (const std::runtime_error& e) {
EXPECT_NE(std::string(e.what()).find(missing_path), std::string::npos);
throw;
Expand All @@ -184,23 +185,22 @@ TEST(GetStringTaskTypeStandaloneTest, ReturnsUnknownForInvalidEnum) {
std::filesystem::remove(path);
}

TEST_NOLINT(GetStringTaskTypeEdgeCases, ThrowsIfFileCannotBeOpened) {
EXPECT_THROW_NOLINT(GetStringTaskType(ppc::core::TypeOfTask::kSEQ, "definitely_missing_file.json"),
std::runtime_error);
TEST(GetStringTaskTypeEdgeCases, ThrowsIfFileCannotBeOpened) {
EXPECT_THROW(GetStringTaskType(ppc::core::TypeOfTask::kSEQ, "definitely_missing_file.json"), std::runtime_error);
}

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

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

EXPECT_THROW_NOLINT(GetStringTaskType(ppc::core::TypeOfTask::kSEQ, path), NlohmannJsonTypeError);
EXPECT_THROW(GetStringTaskType(ppc::core::TypeOfTask::kSEQ, path), NlohmannJsonTypeError);

std::filesystem::remove(path);
}
Expand Down Expand Up @@ -237,9 +237,9 @@ TEST(TaskTest, GetDynamicTypeReturnsCorrectEnum) {
EXPECT_EQ(task.GetDynamicTypeOfTask(), ppc::core::TypeOfTask::kOMP);
}

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

TYPED_TEST_SUITE(GetNamespaceTest, TestTypes);

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

if constexpr (std::is_same_v<TypeParam, my::nested::Type>) {
Expand Down
2 changes: 0 additions & 2 deletions modules/core/runners/src/runners.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

#include <gtest/gtest.h>
#include <mpi.h>
#include <omp.h>

#include <cstdio>
#include <cstdlib>
#include <format>
#include <iostream>
Expand Down
1 change: 1 addition & 0 deletions modules/core/task/include/task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <sstream>
#include <stdexcept>
#include <string>
#include <vector>

namespace ppc::core {

Expand Down
41 changes: 41 additions & 0 deletions modules/core/task/tests/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
InheritParentConfig: true

Checks: >
bugprone-*,
clang-diagnostic-*,
concurrency-*,
cppcoreguidelines-*,
llvm-include-order,
llvm-namespace-comment,
misc-*,
modernize-*,
mpi-*,
openmp-*,
performance-*,
portability-*,
readability-*,
-bugprone-casting-through-void,
-bugprone-easily-swappable-parameters,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-owning-memory,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-cppcoreguidelines-pro-type-reinterpret-cast,
-cppcoreguidelines-pro-type-vararg,
-cppcoreguidelines-special-member-functions,
-misc-const-correctness,
-misc-non-private-member-variables-in-classes,
-modernize-avoid-c-arrays,
-modernize-loop-convert,
-modernize-use-trailing-return-type,
-portability-template-virtual-member-function,
-readability-magic-numbers,
-cppcoreguidelines-avoid-goto,
-cppcoreguidelines-avoid-non-const-global-variables,
-misc-use-anonymous-namespace,
-modernize-use-std-print,
-modernize-type-traits,

CheckOptions:
- key: readability-function-cognitive-complexity.Threshold
value: 50 # default: 25
5 changes: 2 additions & 3 deletions modules/core/task/tests/task_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <vector>

#include "core/task/tests/test_task.hpp"
#include "core/util/include/util.hpp"

TEST(task_tests, check_int32_t) {
// Create data
Expand Down Expand Up @@ -128,7 +127,7 @@ TEST(task_tests, check_float) {
EXPECT_NEAR(test_task.GetOutput(), in.size(), 1e-3);
}

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

TEST_NOLINT(task_tests, check_empty_order_disabled_valgrind) {
TEST(task_tests, check_empty_order_disabled_valgrind) {
auto destroy_function = [] {
// Create data
std::vector<float> in(20, 1);
Expand Down
1 change: 0 additions & 1 deletion modules/core/task/tests/test_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <chrono>
#include <thread>
#include <vector>

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

Expand Down
1 change: 0 additions & 1 deletion modules/core/util/include/func_test_util.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include <gtest/gtest.h>
#include <omp.h>
#include <tbb/tick_count.h>

#include <concepts>
Expand Down
4 changes: 2 additions & 2 deletions modules/core/util/include/perf_test_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ auto MakePerfTaskTuples(const std::string& settings_path) {
}

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

template <typename Tuple>
Expand Down
18 changes: 5 additions & 13 deletions modules/core/util/include/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,25 @@
#include <string>
#include <string_view>

#include "nlohmann/json_fwd.hpp"

#define PPC_FUNC_NAME __func__

#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4459)
#endif

#include <nlohmann/json.hpp> // NOLINT(misc-include-cleaner)
#include <nlohmann/json.hpp>

/// @brief JSON namespace used for settings and config parsing.
using NlohmannJsonParseError = nlohmann::json::parse_error; // NOLINT(misc-include-cleaner)
using NlohmannJsonParseError = nlohmann::json::parse_error;
/// @brief JSON namespace used for settings and config typing.
using NlohmannJsonTypeError = nlohmann::json::type_error; // NOLINT(misc-include-cleaner)
using NlohmannJsonTypeError = nlohmann::json::type_error;
#ifdef _MSC_VER
#pragma warning(pop)
#endif

#define ASSERT_ANY_THROW_NOLINT(stmt) ASSERT_ANY_THROW(stmt) // NOLINT
#define EXPECT_THROW_NOLINT(stmt, error) EXPECT_THROW(stmt, error) // NOLINT
#define TEST_NOLINT(test_suite_name, test_name) TEST(test_suite_name, test_name) // NOLINT
#define ASSERT_DEATH_IF_SUPPORTED_NOLINT(stmt, name) ASSERT_DEATH_IF_SUPPORTED(stmt, name) // NOLINT
#define TYPED_TEST_NOLINT(test_suite_name, test_name) TYPED_TEST(test_suite_name, test_name) // NOLINT
#define INSTANTIATE_TEST_SUITE_P_WITH_NAME(n, t, g, ng) INSTANTIATE_TEST_SUITE_P(n, t, g, ng) // NOLINT
#define INSTANTIATE_TEST_SUITE_P_NOLINT(n, t, g) INSTANTIATE_TEST_SUITE_P(n, t, g) // NOLINT
// INSTANTIATE_TEST_SUITE_P | n, t, g, ng == name, test_case_name, generator, name_generator

namespace ppc::util {

enum GTestParamIndex : uint8_t { kTaskGetter, kNameTest, kTestParams };
Expand Down Expand Up @@ -97,7 +90,6 @@ constexpr std::string_view GetNamespace() {
#endif
}

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

bool IsUnderMpirun();
Expand Down
1 change: 0 additions & 1 deletion tasks/example_processes/mpi/src/ops_mpi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <mpi.h>

#include <cmath>
#include <numeric>
#include <vector>

Expand Down
1 change: 0 additions & 1 deletion tasks/example_processes/seq/src/ops_seq.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "example_processes/seq/include/ops_seq.hpp"

#include <cmath>
#include <numeric>
#include <vector>

Expand Down
Loading
Loading