From 7c0baafc38713d68bd5b75d3954b1e06d5e595c3 Mon Sep 17 00:00:00 2001 From: Timm Fitschen <t.fitschen@indiscale.com> Date: Wed, 4 Aug 2021 15:30:46 +0200 Subject: [PATCH] REVIEW: ignore clang's cognitive-complexity for tests --- test/CMakeLists.txt | 2 +- test/test_configuration.cpp | 7 ++----- test/test_connection.cpp | 3 +-- test/test_entity.cpp | 12 ++++-------- test/test_protobuf.cpp | 6 ++---- test/test_transaction.cpp | 3 +-- 6 files changed, 11 insertions(+), 22 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index fc8e134..389d5d9 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -36,7 +36,7 @@ set(test_cases # special linting for tests set(_CMAKE_CXX_CLANG_TIDY_TEST_CHECKS - "${_CMAKE_CXX_CLANG_TIDY_CHECKS},-cert-err58-cpp,-cppcoreguidelines-avoid-non-const-global-variables,-cppcoreguidelines-owning-memory,-modernize-use-trailing-return-type,-google-readability-avoid-underscore-in-googletest-name,-cppcoreguidelines-avoid-magic-numbers,-readability-magic-numbers,-cppcoreguidelines-avoid-goto,-hicpp-avoid-goto" + "${_CMAKE_CXX_CLANG_TIDY_CHECKS},-cert-err58-cpp,-cppcoreguidelines-avoid-non-const-global-variables,-cppcoreguidelines-owning-memory,-modernize-use-trailing-return-type,-google-readability-avoid-underscore-in-googletest-name,-cppcoreguidelines-avoid-magic-numbers,-readability-magic-numbers,-cppcoreguidelines-avoid-goto,-hicpp-avoid-goto,-readability-function-cognitive-complexity" ) # add special cmake functions for gtest diff --git a/test/test_configuration.cpp b/test/test_configuration.cpp index 3c04785..abc797f 100644 --- a/test/test_configuration.cpp +++ b/test/test_configuration.cpp @@ -38,8 +38,7 @@ protected: void TearDown() override { ConfigurationManager::Clear(); } }; -// TODO(tf) cogintive complexity > 25 (threshold) -TEST_F(test_configuration, load_json) { // NOLINT +TEST_F(test_configuration, load_json) { ConfigurationManager::LoadSingleJSONConfiguration(TEST_DATA_DIR + "/test_caosdb_client.json"); EXPECT_THROW_MESSAGE( @@ -53,9 +52,7 @@ TEST_F(test_configuration, load_json) { // NOLINT ConfigurationManager::Clear(); } -// TODO(tf) cognitive complexity again -TEST_F(test_configuration, // NOLINT - get_default_connection_configuration_error) { // NOLINT +TEST_F(test_configuration, get_default_connection_configuration_error) { EXPECT_THROW_MESSAGE(ConfigurationManager::GetDefaultConnectionName(), ConfigurationError, "This CaosDB client has not been configured."); diff --git a/test/test_connection.cpp b/test/test_connection.cpp index 6c5fa0b..7c2efab 100644 --- a/test/test_connection.cpp +++ b/test/test_connection.cpp @@ -65,8 +65,7 @@ TEST_F(test_connection, configure_ssl_localhost_8080) { EXPECT_TRUE(sslcc != nullptr); } -// TODO(tf) cognitive complexity > 25 (threshold) -TEST_F(test_connection, connection_manager_unknown_connection) { // NOLINT +TEST_F(test_connection, connection_manager_unknown_connection) { EXPECT_THROW_MESSAGE(ConnectionManager::GetConnection("test"), caosdb::exceptions::UnknownConnectionError, "No connection named 'test' present."); diff --git a/test/test_entity.cpp b/test/test_entity.cpp index ec11796..6a24ab7 100644 --- a/test/test_entity.cpp +++ b/test/test_entity.cpp @@ -78,8 +78,7 @@ TEST(test_entity, test_property_setters) { EXPECT_EQ(prop.GetDatatype(), "prop_dtype"); } -// TODO(fspreck) cognitive complexity > 25 (threshold) -TEST(test_entity, test_append_property) { // NOLINT +TEST(test_entity, test_append_property) { auto entity = Entity(); auto prop = Property(); @@ -151,8 +150,7 @@ TEST(test_entity, test_insert_entity) { EXPECT_EQ(entity.GetVersionId(), "version_id"); } -// TODO(fspreck) cognitive complexity > 25 (threshold) -TEST(test_entity, test_insert_with_role) { // NOLINT +TEST(test_entity, test_insert_with_role) { auto transaction = caosdb::transaction::Transaction( std::shared_ptr<transaction::EntityTransactionService::Stub>(nullptr)); @@ -201,8 +199,7 @@ TEST(test_entity, test_insert_with_parent) { EXPECT_EQ(inserted_parent.GetName(), parent.GetName()); } -// TODO(fspreck) cognitive complexity > 25 (threshold) -TEST(test_entity, test_insert_with_property) { // NOLINT +TEST(test_entity, test_insert_with_property) { auto transaction = caosdb::transaction::Transaction( std::shared_ptr<transaction::EntityTransactionService::Stub>(nullptr)); @@ -233,8 +230,7 @@ TEST(test_entity, test_insert_with_property) { // NOLINT EXPECT_EQ(prop.GetDatatype(), inserted_prop.GetDatatype()); } -// TODO(tf) cognitive complexity > 25 (threshold) -TEST(test_entity, test_from_id_response) { // NOLINT +TEST(test_entity, test_from_id_response) { IdResponse idResponse; idResponse.set_id("entity_id"); auto *error = idResponse.add_entity_errors(); diff --git a/test/test_protobuf.cpp b/test/test_protobuf.cpp index 61b85c8..9dc957a 100644 --- a/test/test_protobuf.cpp +++ b/test/test_protobuf.cpp @@ -29,8 +29,7 @@ namespace caosdb { using caosdb::entity::v1alpha1::Entity; using caosdb::entity::v1alpha1::Message; -// TODO(tf) cognitive complexity > 25 (threshold) -TEST(test_protobuf, test_swap_trivial) { // NOLINT +TEST(test_protobuf, test_swap_trivial) { Message message_source; message_source.set_code(1234); message_source.set_description("desc"); @@ -50,8 +49,7 @@ TEST(test_protobuf, test_swap_trivial) { // NOLINT EXPECT_EQ(message_destination.description(), "desc"); } -// TODO(tf) cognitive complexity again -TEST(test_protobuf, test_swap_nested) { // NOLINT +TEST(test_protobuf, test_swap_nested) { Entity entity_source; entity_source.set_id("entity_id"); auto *version_source = entity_source.mutable_version(); diff --git a/test/test_transaction.cpp b/test/test_transaction.cpp index 6f27f61..ab1979f 100644 --- a/test/test_transaction.cpp +++ b/test/test_transaction.cpp @@ -40,8 +40,7 @@ using caosdb::exceptions::ConnectionError; using caosdb::transaction::UniqueResult; using ProtoEntity = caosdb::entity::v1alpha1::Entity; -// TODO(tf) cognitive complexity > 25 (threshold) -TEST(test_transaction, create_transaction) { // NOLINT +TEST(test_transaction, create_transaction) { const auto *host = "localhost"; auto configuration = InsecureConnectionConfiguration(host, 8000); Connection connection(configuration); -- GitLab