Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix most of the remaining code warnings
authorMaxwell Pirtle <maxwellpirtle@gmail.com>
Mon, 27 Feb 2023 08:20:49 +0000 (09:20 +0100)
committerMaxwell Pirtle <maxwellpirtle@gmail.com>
Mon, 27 Feb 2023 08:24:17 +0000 (09:24 +0100)
This commit fixes the majority of the code
warnings pointed out by SonarSource. There
are some others that will disappear with other
phases once e.g. the functions in UdporChecker
are actually implemented

src/mc/explo/UdporChecker.cpp
src/mc/explo/UdporChecker.hpp
src/mc/explo/udpor/Configuration.cpp
src/mc/explo/udpor/Configuration_test.cpp
src/mc/explo/udpor/EventSet.hpp
src/mc/explo/udpor/EventSet_test.cpp
src/mc/explo/udpor/History.cpp
src/mc/explo/udpor/History_test.cpp

index c5d596d..cb6f522 100644 (file)
@@ -57,8 +57,7 @@ void UdporChecker::explore(const Configuration& C, EventSet D, EventSet A, std::
   if (enC.is_subset_of(D)) {
 
     if (not C.get_events().empty()) {
-
-      // g_var::nb_traces++;
+      // Report information...
     }
 
     // When `en(C)` is empty, intuitively this means that there
index f19c8c6..30407c4 100644 (file)
@@ -42,14 +42,6 @@ public:
   inline std::unique_ptr<State> get_current_state() { return std::make_unique<State>(get_remote_app()); }
 
 private:
-  /**
-   * The total number of events created whilst exploring the unfolding
-   */
-  /* FIXME: private fields are not used
-    uint32_t nb_events = 0;
-    uint32_t nb_traces = 0;
-  */
-
   /**
    * @brief The "relevant" portions of the unfolding that must be kept around to ensure that
    * UDPOR properly searches the state space
@@ -88,7 +80,6 @@ private:
   std::unordered_map<Transition::Type, ExtensionFunction> incremental_extension_functions =
       std::unordered_map<Transition::Type, ExtensionFunction>();
 
-private:
   /**
    * @brief Explores the unfolding of the concurrent system
    * represented by the ModelChecker instance "mcmodel_checker"
index c4bdd79..1923345 100644 (file)
@@ -54,7 +54,9 @@ std::vector<UnfoldingEvent*> Configuration::get_topologically_sorted_events() co
 
   std::stack<UnfoldingEvent*> event_stack;
   std::vector<UnfoldingEvent*> topological_ordering;
-  EventSet unknown_events = events_, temporarily_marked_events, permanently_marked_events;
+  EventSet unknown_events = events_;
+  EventSet temporarily_marked_events;
+  EventSet permanently_marked_events;
 
   while (not unknown_events.empty()) {
     EventSet discovered_events;
index 5232a05..9a5a756 100644 (file)
@@ -24,7 +24,8 @@ TEST_CASE("simgrid::mc::udpor::Configuration: Constructing Configurations")
   UnfoldingEvent e1;
   UnfoldingEvent e2{&e1};
   UnfoldingEvent e3{&e2};
-  UnfoldingEvent e4{&e3}, e5{&e3};
+  UnfoldingEvent e4{&e3};
+  UnfoldingEvent e5{&e3};
 
   SECTION("Creating a configuration without events")
   {
@@ -191,8 +192,9 @@ TEST_CASE("simgrid::mc::udpor::Configuration: Topological Sort Order More Compli
   UnfoldingEvent e1;
   UnfoldingEvent e2{&e1};
   UnfoldingEvent e3{&e2};
-  UnfoldingEvent e4{&e3}, e6{&e3};
+  UnfoldingEvent e4{&e3};
   UnfoldingEvent e5{&e4};
+  UnfoldingEvent e6{&e3};
 
   SECTION("Topological ordering for subsets")
   {
@@ -293,12 +295,16 @@ TEST_CASE("simgrid::mc::udpor::Configuration: Topological Sort Order Very Compli
   //         /  /   /
   //         [   e12    ]
   UnfoldingEvent e1;
-  UnfoldingEvent e2{&e1}, e8{&e1};
+  UnfoldingEvent e2{&e1};
+  UnfoldingEvent e8{&e1};
   UnfoldingEvent e3{&e2};
   UnfoldingEvent e4{&e3};
-  UnfoldingEvent e5{&e4}, e6{&e4};
-  UnfoldingEvent e7{&e2, &e8}, e11{&e8};
-  UnfoldingEvent e10{&e7}, e9{&e6, &e7};
+  UnfoldingEvent e5{&e4};
+  UnfoldingEvent e6{&e4};
+  UnfoldingEvent e7{&e2, &e8};
+  UnfoldingEvent e9{&e6, &e7};
+  UnfoldingEvent e10{&e7};
+  UnfoldingEvent e11{&e8};
   UnfoldingEvent e12{&e5, &e9, &e10};
   Configuration C{&e1, &e2, &e3, &e4, &e5, &e6, &e7, &e8, &e9, &e10, &e11, &e12};
 
@@ -307,12 +313,10 @@ TEST_CASE("simgrid::mc::udpor::Configuration: Topological Sort Order Very Compli
     // To test this, we ensure that for the `i`th event
     // in `ordered_events`, each event in `ordered_events[0...<i]
     // is contained in the history of `ordered_events[i]`.
-    const auto ordered_events = C.get_topologically_sorted_events();
-
     EventSet events_seen;
-    for (size_t i = 0; i < ordered_events.size(); i++) {
-      UnfoldingEvent* e = ordered_events[i];
+    const auto ordered_events = C.get_topologically_sorted_events();
 
+    std::for_each(ordered_events.begin(), ordered_events.end(), [&events_seen](UnfoldingEvent* e) {
       History history(e);
       for (auto* e_hist : history) {
         // In this demo, we want to make sure that
@@ -328,7 +332,7 @@ TEST_CASE("simgrid::mc::udpor::Configuration: Topological Sort Order Very Compli
         REQUIRE(events_seen.contains(e_hist));
       }
       events_seen.insert(e);
-    }
+    });
   }
 
   SECTION("Test every combination of the maximal configuration (reverse graph)")
@@ -336,11 +340,10 @@ TEST_CASE("simgrid::mc::udpor::Configuration: Topological Sort Order Very Compli
     // To test this, we ensure that for the `i`th event
     // in `ordered_events`, no event in `ordered_events[0...<i]
     // is contained in the history of `ordered_events[i]`.
+    EventSet events_seen;
     const auto ordered_events = C.get_topologically_sorted_events_of_reverse_graph();
 
-    EventSet events_seen;
-    for (size_t i = 0; i < ordered_events.size(); i++) {
-      UnfoldingEvent* e = ordered_events[i];
+    std::for_each(ordered_events.begin(), ordered_events.end(), [&events_seen](UnfoldingEvent* e) {
       History history(e);
 
       for (auto* e_hist : history) {
@@ -353,6 +356,6 @@ TEST_CASE("simgrid::mc::udpor::Configuration: Topological Sort Order Very Compli
         REQUIRE_FALSE(events_seen.contains(e_hist));
       }
       events_seen.insert(e);
-    }
+    });
   }
 }
\ No newline at end of file
index db42ff2..26a910a 100644 (file)
@@ -25,7 +25,7 @@ public:
   EventSet& operator=(EventSet&&)      = default;
   EventSet(EventSet&&)                 = default;
   explicit EventSet(Configuration&& config);
-  explicit EventSet(std::unordered_set<UnfoldingEvent*>&& raw_events) : events_(std::move(raw_events)) {}
+  explicit EventSet(std::unordered_set<UnfoldingEvent*>&& raw_events) : events_(raw_events) {}
   explicit EventSet(std::initializer_list<UnfoldingEvent*> event_list) : events_(std::move(event_list)) {}
 
   auto begin() const { return this->events_.begin(); }
@@ -56,7 +56,6 @@ public:
   bool operator==(const EventSet& other) const { return this->events_ == other.events_; }
   bool operator!=(const EventSet& other) const { return this->events_ != other.events_; }
 
-public:
   /**
    * @brief Whether or not this set of events could
    * represent a configuration
index 14fb162..d7342b3 100644 (file)
@@ -109,7 +109,10 @@ TEST_CASE("simgrid::mc::udpor::EventSet: Insertions")
 
 TEST_CASE("simgrid::mc::udpor::EventSet: Deletions")
 {
-  UnfoldingEvent e1, e2, e3, e4;
+  UnfoldingEvent e1;
+  UnfoldingEvent e2;
+  UnfoldingEvent e3;
+  UnfoldingEvent e4;
   EventSet event_set({&e1, &e2, &e3});
 
   SECTION("Remove an element already present")
@@ -181,7 +184,10 @@ TEST_CASE("simgrid::mc::udpor::EventSet: Deletions")
 
 TEST_CASE("simgrid::mc::udpor::EventSet: Set Equality")
 {
-  UnfoldingEvent e1, e2, e3, e4;
+  UnfoldingEvent e1;
+  UnfoldingEvent e2;
+  UnfoldingEvent e3;
+  UnfoldingEvent e4;
   EventSet A{&e1, &e2, &e3}, B{&e1, &e2, &e3}, C{&e1, &e2, &e3};
 
   SECTION("Equality implies containment")
@@ -515,8 +521,10 @@ TEST_CASE("simgrid::mc::udpor::EventSet: Testing Configurations")
   // in the structure and test whether those subsets are
   // maximal and/or valid configurations
   UnfoldingEvent e1;
-  UnfoldingEvent e2{&e1}, e5{&e1};
-  UnfoldingEvent e3{&e2}, e4{&e2};
+  UnfoldingEvent e2{&e1};
+  UnfoldingEvent e3{&e2};
+  UnfoldingEvent e4{&e2};
+  UnfoldingEvent e5{&e1};
   UnfoldingEvent e6{&e5};
 
   SECTION("Valid Configurations")
index bb24494..e6a6405 100644 (file)
@@ -80,7 +80,7 @@ bool History::contains(const UnfoldingEvent* e) const
 EventSet History::get_event_diff_with(const Configuration& config) const
 {
   auto wrapped_config = std::optional<std::reference_wrapper<const Configuration>>{config};
-  auto first          = Iterator(events_, std::move(wrapped_config));
+  auto first          = Iterator(events_, wrapped_config);
   const auto last     = this->end();
 
   for (; first != last; ++first)
index 0cbe878..55065a3 100644 (file)
@@ -18,9 +18,12 @@ TEST_CASE("simgrid::mc::udpor::History: History generation")
   //  | \  \  /   /
   // e3 e4 e5      e7
   UnfoldingEvent e1;
-  UnfoldingEvent e2{&e1}, e6{&e1};
-  UnfoldingEvent e3{&e2}, e4{&e2};
-  UnfoldingEvent e5{&e2, &e6}, e7{&e6};
+  UnfoldingEvent e2{&e1};
+  UnfoldingEvent e6{&e1};
+  UnfoldingEvent e3{&e2};
+  UnfoldingEvent e4{&e2};
+  UnfoldingEvent e5{&e2, &e6};
+  UnfoldingEvent e7{&e6};
 
   SECTION("History with no events")
   {