From a0b8871b36a90170b69f6f1bd73d742c074e0657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boris=20Ta=C5=A1evski?= <36607228+BorisTasevski@users.noreply.github.com> Date: Thu, 15 Sep 2022 15:51:35 +0200 Subject: [PATCH] Fix cland tidy errors and other warning (#555) --- include/mgp.hpp | 20 +++++++++---------- src/query/procedure/mg_procedure_impl.cpp | 16 +++++++++------ tests/benchmark/query/planner.cpp | 2 +- tests/unit/query_plan_match_filter_return.cpp | 18 ++++++++--------- 4 files changed, 30 insertions(+), 26 deletions(-) diff --git a/include/mgp.hpp b/include/mgp.hpp index 484e679aa..bf2e27c50 100644 --- a/include/mgp.hpp +++ b/include/mgp.hpp @@ -555,7 +555,7 @@ class List { friend class Value; friend class Record; friend class Result; - friend struct Parameter; + friend class Parameter; public: /// @brief Creates a List from the copy of the given @ref mgp_list. @@ -653,7 +653,7 @@ class Map { friend class Value; friend class Record; friend class Result; - friend struct Parameter; + friend class Parameter; public: /// @brief Creates a Map from the copy of the given @ref mgp_map. @@ -788,7 +788,7 @@ class Node { friend class Value; friend class Record; friend class Result; - friend struct Parameter; + friend class Parameter; /// @brief Creates a Node from the copy of the given @ref mgp_vertex. explicit Node(mgp_vertex *ptr) : ptr_(mgp::vertex_copy(ptr, memory)) {} @@ -846,7 +846,7 @@ class Relationship { friend class Value; friend class Record; friend class Result; - friend struct Parameter; + friend class Parameter; public: /// @brief Creates a Relationship from the copy of the given @ref mgp_edge. @@ -897,7 +897,7 @@ class Path { friend class Value; friend class Record; friend class Result; - friend struct Parameter; + friend class Parameter; public: /// @brief Creates a Path from the copy of the given @ref mgp_path. @@ -949,7 +949,7 @@ class Date { friend class Value; friend class Record; friend class Result; - friend struct Parameter; + friend class Parameter; public: /// @brief Creates a Date object from the copy of the given @ref mgp_date. @@ -1003,7 +1003,7 @@ class LocalTime { friend class Value; friend class Record; friend class Result; - friend struct Parameter; + friend class Parameter; public: /// @brief Creates a LocalTime object from the copy of the given @ref mgp_local_time. @@ -1063,7 +1063,7 @@ class LocalDateTime { friend class Value; friend class Record; friend class Result; - friend struct Parameter; + friend class Parameter; public: /// @brief Creates a LocalDateTime object from the copy of the given @ref mgp_local_date_time. @@ -1131,7 +1131,7 @@ class Duration { friend class Value; friend class Record; friend class Result; - friend struct Parameter; + friend class Parameter; public: /// @brief Creates a Duration from the copy of the given @ref mgp_duration. @@ -2743,7 +2743,7 @@ void AddFunction(mgp_func_cb callback, std::string_view name, std::vectorexecution_stats[memgraph::query::ExecutionStats::Key::CREATED_LABELS] += 1; + if (ctx) { + ctx->execution_stats[memgraph::query::ExecutionStats::Key::CREATED_LABELS] += 1; - if (ctx->trigger_context_collector) { - ctx->trigger_context_collector->RegisterSetVertexLabel(v->getImpl(), label_id); + if (ctx->trigger_context_collector) { + ctx->trigger_context_collector->RegisterSetVertexLabel(v->getImpl(), label_id); + } } }); } @@ -1774,10 +1776,12 @@ mgp_error mgp_vertex_remove_label(struct mgp_vertex *v, mgp_label label) { } } - ctx->execution_stats[memgraph::query::ExecutionStats::Key::DELETED_LABELS] += 1; + if (ctx) { + ctx->execution_stats[memgraph::query::ExecutionStats::Key::DELETED_LABELS] += 1; - if (ctx->trigger_context_collector) { - ctx->trigger_context_collector->RegisterRemovedVertexLabel(v->getImpl(), label_id); + if (ctx->trigger_context_collector) { + ctx->trigger_context_collector->RegisterRemovedVertexLabel(v->getImpl(), label_id); + } } }); } diff --git a/tests/benchmark/query/planner.cpp b/tests/benchmark/query/planner.cpp index d7157fb31..7cd473f82 100644 --- a/tests/benchmark/query/planner.cpp +++ b/tests/benchmark/query/planner.cpp @@ -95,7 +95,7 @@ static memgraph::query::CypherQuery *AddIndexedMatches(int num_matches, const st static auto CreateIndexedVertices(int index_count, int vertex_count, memgraph::storage::Storage *db) { auto label = db->NameToLabel("label"); auto prop = db->NameToProperty("prop"); - db->CreateIndex(label, prop); + [[maybe_unused]] auto _ = db->CreateIndex(label, prop); auto dba = db->Access(); for (int vi = 0; vi < vertex_count; ++vi) { for (int index = 0; index < index_count; ++index) { diff --git a/tests/unit/query_plan_match_filter_return.cpp b/tests/unit/query_plan_match_filter_return.cpp index 43596dfe6..d970ac2c7 100644 --- a/tests/unit/query_plan_match_filter_return.cpp +++ b/tests/unit/query_plan_match_filter_return.cpp @@ -3028,7 +3028,7 @@ TEST(QueryPlan, Distinct) { TEST(QueryPlan, ScanAllByLabel) { memgraph::storage::Storage db; auto label = db.NameToLabel("label"); - db.CreateIndex(label); + [[maybe_unused]] auto _ = db.CreateIndex(label); auto storage_dba = db.Access(); memgraph::query::DbAccessor dba(&storage_dba); // Add a vertex with a label and one without. @@ -3086,7 +3086,7 @@ TEST(QueryPlan, ScanAllByLabelProperty) { } ASSERT_FALSE(dba.Commit().HasError()); } - db.CreateIndex(label, prop); + [[maybe_unused]] auto _ = db.CreateIndex(label, prop); auto storage_dba = db.Access(); memgraph::query::DbAccessor dba(&storage_dba); @@ -3180,7 +3180,7 @@ TEST(QueryPlan, ScanAllByLabelPropertyEqualityNoError) { ASSERT_TRUE(string_vertex.SetProperty(prop, memgraph::storage::PropertyValue("string")).HasValue()); ASSERT_FALSE(dba.Commit().HasError()); } - db.CreateIndex(label, prop); + [[maybe_unused]] auto _ = db.CreateIndex(label, prop); auto storage_dba = db.Access(); memgraph::query::DbAccessor dba(&storage_dba); @@ -3217,7 +3217,7 @@ TEST(QueryPlan, ScanAllByLabelPropertyValueError) { } ASSERT_FALSE(dba.Commit().HasError()); } - db.CreateIndex(label, prop); + [[maybe_unused]] auto _ = db.CreateIndex(label, prop); auto storage_dba = db.Access(); memgraph::query::DbAccessor dba(&storage_dba); @@ -3248,7 +3248,7 @@ TEST(QueryPlan, ScanAllByLabelPropertyRangeError) { } ASSERT_FALSE(dba.Commit().HasError()); } - db.CreateIndex(label, prop); + [[maybe_unused]] auto _ = db.CreateIndex(label, prop); auto storage_dba = db.Access(); memgraph::query::DbAccessor dba(&storage_dba); @@ -3301,7 +3301,7 @@ TEST(QueryPlan, ScanAllByLabelPropertyEqualNull) { ASSERT_TRUE(vertex_with_prop.SetProperty(prop, memgraph::storage::PropertyValue(42)).HasValue()); ASSERT_FALSE(dba.Commit().HasError()); } - db.CreateIndex(label, prop); + [[maybe_unused]] auto _ = db.CreateIndex(label, prop); auto storage_dba = db.Access(); memgraph::query::DbAccessor dba(&storage_dba); @@ -3336,7 +3336,7 @@ TEST(QueryPlan, ScanAllByLabelPropertyRangeNull) { ASSERT_TRUE(vertex_with_prop.SetProperty(prop, memgraph::storage::PropertyValue(42)).HasValue()); ASSERT_FALSE(dba.Commit().HasError()); } - db.CreateIndex(label, prop); + [[maybe_unused]] auto _ = db.CreateIndex(label, prop); auto storage_dba = db.Access(); memgraph::query::DbAccessor dba(&storage_dba); @@ -3367,7 +3367,7 @@ TEST(QueryPlan, ScanAllByLabelPropertyNoValueInIndexContinuation) { ASSERT_TRUE(v.SetProperty(prop, memgraph::storage::PropertyValue(2)).HasValue()); ASSERT_FALSE(dba.Commit().HasError()); } - db.CreateIndex(label, prop); + [[maybe_unused]] auto _ = db.CreateIndex(label, prop); auto storage_dba = db.Access(); memgraph::query::DbAccessor dba(&storage_dba); @@ -3409,7 +3409,7 @@ TEST(QueryPlan, ScanAllEqualsScanAllByLabelProperty) { ASSERT_FALSE(dba.Commit().HasError()); } - db.CreateIndex(label, prop); + [[maybe_unused]] auto _ = db.CreateIndex(label, prop); // Make sure there are `vertex_count` vertices {