Răsfoiți Sursa

Address SonarLint findings in Narrator class

Patrick-Christopher Mattulat 1 an în urmă
părinte
comite
6e31883892

+ 3 - 3
include/ls-std/event/Narrator.hpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-11-14
- * Changed:         2023-02-22
+ * Changed:         2023-05-16
  *
  * */
 
@@ -27,9 +27,9 @@ namespace ls::std::event
 
       bool addListener(const ::std::shared_ptr<ls::std::core::interface_type::IListener> &_listener); // nodiscard is optional here
       void clear();
-      [[nodiscard]] ::std::list<::std::shared_ptr<ls::std::core::interface_type::IListener>> getListeners();
+      [[nodiscard]] ::std::list<::std::shared_ptr<ls::std::core::interface_type::IListener>> getListeners() const;
       bool removeListener(const ::std::shared_ptr<ls::std::core::interface_type::IListener> &_listener); // nodiscard is optional here
-      void tell(const ls::std::core::Class &_info);
+      void tell(const ls::std::core::Class &_info) const;
 
     private:
 

+ 3 - 3
source/ls-std/event/Narrator.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-11-14
- * Changed:         2023-02-23
+ * Changed:         2023-05-16
  *
  * */
 
@@ -43,7 +43,7 @@ void Narrator::clear()
   this->listeners.clear();
 }
 
-list<shared_ptr<IListener>> Narrator::getListeners()
+list<shared_ptr<IListener>> Narrator::getListeners() const
 {
   return this->listeners;
 }
@@ -62,7 +62,7 @@ bool Narrator::removeListener(const shared_ptr<IListener> &_listener)
   return wasRemoved;
 }
 
-void Narrator::tell(const Class &_info)
+void Narrator::tell(const Class &_info) const
 {
   for (const auto &listener : this->listeners)
   {

+ 2 - 2
test/cases/event/NarratorTest.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-11-14
- * Changed:         2023-05-15
+ * Changed:         2023-05-16
  *
  * */
 
@@ -151,7 +151,7 @@ namespace
     ASSERT_STREQ("blue", this->mercedes2->getColor().data());
     ASSERT_STREQ("red", this->mercedes3->getColor().data());
 
-    Colour newColor = Colour{"black"};
+    auto newColor = Colour{"black"};
     paintingMachine.tell(static_cast<const Class &>(newColor));
 
     ASSERT_STREQ("black", this->mercedes1->getColor().data());