diff --git a/include/loot/metadata/conditional_metadata.h b/include/loot/metadata/conditional_metadata.h index 4c80e11a..e069720a 100644 --- a/include/loot/metadata/conditional_metadata.h +++ b/include/loot/metadata/conditional_metadata.h @@ -39,7 +39,7 @@ public: * Construct a ConditionalMetadata object with an empty condition string. * @return A ConditionalMetadata object. */ - LOOT_API ConditionalMetadata(); + LOOT_API explicit ConditionalMetadata(); /** * Construct a ConditionalMetadata object with a given condition string. @@ -48,7 +48,7 @@ public: * documentation. * @return A ConditionalMetadata object. */ - LOOT_API ConditionalMetadata(const std::string& condition); + LOOT_API explicit ConditionalMetadata(const std::string& condition); /** * Check if the condition string is non-empty. diff --git a/include/loot/metadata/file.h b/include/loot/metadata/file.h index 97537db5..ef51b1cf 100644 --- a/include/loot/metadata/file.h +++ b/include/loot/metadata/file.h @@ -39,7 +39,7 @@ public: * Construct a File with blank name, display and condition strings. * @return A File object. */ - LOOT_API File(); + LOOT_API explicit File(); /** * Construct a File with the given name, display name and condition strings. @@ -51,7 +51,7 @@ public: * The File's condition string. * @return A File object. */ - LOOT_API File(const std::string& name, + LOOT_API explicit File(const std::string& name, const std::string& display = "", const std::string& condition = ""); diff --git a/include/loot/metadata/group.h b/include/loot/metadata/group.h index bcfeed18..0e264c09 100644 --- a/include/loot/metadata/group.h +++ b/include/loot/metadata/group.h @@ -40,7 +40,7 @@ public: * load after. * @return A Group object. */ - LOOT_API Group(); + LOOT_API explicit Group(); /** * Construct a Group with the given name, description and set of groups to @@ -53,7 +53,7 @@ public: * A description of the group. * @return A Group object. */ - LOOT_API Group(const std::string& name, + LOOT_API explicit Group(const std::string& name, const std::unordered_set& afterGroups = {}, const std::string& description = ""); diff --git a/include/loot/metadata/location.h b/include/loot/metadata/location.h index 7326d61d..f39ed68e 100644 --- a/include/loot/metadata/location.h +++ b/include/loot/metadata/location.h @@ -39,7 +39,7 @@ public: * Construct a Location with empty URL and name strings. * @return A Location object. */ - LOOT_API Location(); + LOOT_API explicit Location(); /** * Construct a Location with the given URL and name. @@ -49,7 +49,7 @@ public: * A name for the URL, eg. the page or site name. * @return A Location object. */ - LOOT_API Location(const std::string& url, const std::string& name = ""); + LOOT_API explicit Location(const std::string& url, const std::string& name = ""); /** * A less-than operator implemented with no semantics so that Location objects diff --git a/include/loot/metadata/message.h b/include/loot/metadata/message.h index b282ba45..6df64fa1 100644 --- a/include/loot/metadata/message.h +++ b/include/loot/metadata/message.h @@ -44,7 +44,7 @@ public: * strings. * @return A Message object. */ - LOOT_API Message(); + LOOT_API explicit Message(); /** * Construct a Message object with the given type, English content and @@ -57,7 +57,7 @@ public: * A condition string. * @return A Message object. */ - LOOT_API Message(const MessageType type, + LOOT_API explicit Message(const MessageType type, const std::string& content, const std::string& condition = ""); @@ -72,7 +72,7 @@ public: * A condition string. * @return A Message object. */ - LOOT_API Message(const MessageType type, + LOOT_API explicit Message(const MessageType type, const std::vector& content, const std::string& condition = ""); diff --git a/include/loot/metadata/message_content.h b/include/loot/metadata/message_content.h index 238a01b1..aefd4546 100644 --- a/include/loot/metadata/message_content.h +++ b/include/loot/metadata/message_content.h @@ -45,7 +45,7 @@ public: * Construct a MessageContent object with an empty English message string. * @return A MessageContent object. */ - LOOT_API MessageContent(); + LOOT_API explicit MessageContent(); /** * Construct a Message object with the given text in the given language. @@ -55,7 +55,7 @@ public: * The language that the message is written in. * @return A MessageContent object. */ - LOOT_API MessageContent(const std::string& text, + LOOT_API explicit MessageContent(const std::string& text, const std::string& language = defaultLanguage); /** diff --git a/include/loot/metadata/plugin_cleaning_data.h b/include/loot/metadata/plugin_cleaning_data.h index f8d54596..d8045c1a 100644 --- a/include/loot/metadata/plugin_cleaning_data.h +++ b/include/loot/metadata/plugin_cleaning_data.h @@ -44,7 +44,7 @@ public: * and no info. * @return A PluginCleaningData object. */ - LOOT_API PluginCleaningData(); + LOOT_API explicit PluginCleaningData(); /** * Construct a PluginCleaningData object with the given CRC and utility, @@ -56,7 +56,7 @@ public: * The utility that the plugin cleanliness was checked with. * @return A PluginCleaningData object. */ - LOOT_API PluginCleaningData(uint32_t crc, const std::string& utility); + LOOT_API explicit PluginCleaningData(uint32_t crc, const std::string& utility); /** * Construct a PluginCleaningData object with the given values. @@ -75,7 +75,7 @@ public: * The number of deleted navmeshes found in the plugin. * @return A PluginCleaningData object. */ - LOOT_API PluginCleaningData(uint32_t crc, + LOOT_API explicit PluginCleaningData(uint32_t crc, const std::string& utility, const std::vector& info, unsigned int itm, diff --git a/include/loot/metadata/plugin_metadata.h b/include/loot/metadata/plugin_metadata.h index 88c819df..91191817 100644 --- a/include/loot/metadata/plugin_metadata.h +++ b/include/loot/metadata/plugin_metadata.h @@ -49,7 +49,7 @@ public: * Construct a PluginMetadata object with a blank plugin name and no metadata. * @return A PluginMetadata object. */ - LOOT_API PluginMetadata(); + LOOT_API explicit PluginMetadata(); /** * Construct a PluginMetadata object with no metadata for a plugin with the @@ -58,7 +58,7 @@ public: * The filename of the plugin that the object is constructed for. * @return A PluginMetadata object. */ - LOOT_API PluginMetadata(const std::string& name); + LOOT_API explicit PluginMetadata(const std::string& name); /** * Merge metadata from the given PluginMetadata object into this object. diff --git a/include/loot/metadata/tag.h b/include/loot/metadata/tag.h index f3b9fdc4..a586f0f2 100644 --- a/include/loot/metadata/tag.h +++ b/include/loot/metadata/tag.h @@ -40,7 +40,7 @@ public: * an empty condition string. * @return A Tag object. */ - LOOT_API Tag(); + LOOT_API explicit Tag(); /** * Construct a Tag object with the given name, for addition or removal, with @@ -53,7 +53,7 @@ public: * A condition string. * @return A Tag object. */ - LOOT_API Tag(const std::string& tag, + LOOT_API explicit Tag(const std::string& tag, const bool isAddition = true, const std::string& condition = ""); diff --git a/include/loot/struct/masterlist_info.h b/include/loot/struct/masterlist_info.h index a19582b8..c46fd942 100644 --- a/include/loot/struct/masterlist_info.h +++ b/include/loot/struct/masterlist_info.h @@ -32,7 +32,7 @@ namespace loot { * revision. */ struct MasterlistInfo { - inline MasterlistInfo() : is_modified(false) {} + inline explicit MasterlistInfo() : is_modified(false) {} /** * @brief The revision hash for the masterlist. If the masterlist doesn't diff --git a/include/loot/vertex.h b/include/loot/vertex.h index d0cdc60a..861d652c 100644 --- a/include/loot/vertex.h +++ b/include/loot/vertex.h @@ -42,14 +42,14 @@ public: * @brief Construct a Vertex with the given name and no out edge. * @param name The name of the plugin or group that this vertex represents. */ - LOOT_API Vertex(std::string name); + LOOT_API explicit Vertex(std::string name); /** * @brief Construct a Vertex with the given name and out edge type. * @param name The name of the plugin or group that this vertex represents. * @param outEdgeType The type of the edge going out from this vertex. */ - LOOT_API Vertex(std::string name, EdgeType outEdgeType); + LOOT_API explicit Vertex(std::string name, EdgeType outEdgeType); /** * @brief Get the name of the plugin or group. diff --git a/src/api/api_database.cpp b/src/api/api_database.cpp index d7ce3709..f056fb93 100644 --- a/src/api/api_database.cpp +++ b/src/api/api_database.cpp @@ -169,7 +169,7 @@ std::unordered_set ApiDatabase::GetGroups(bool includeUserMetadata) const auto userlistGroups = userlist_.Groups(); for (const auto& group : masterlist_.Groups()) { - auto userlistGroup = userlistGroups.find(group.GetName()); + auto userlistGroup = userlistGroups.find(group); if (userlistGroup != userlistGroups.end()) { auto afterGroups = group.GetAfterGroups(); auto userlistAfterGroups = userlistGroup->GetAfterGroups(); diff --git a/src/api/api_database.h b/src/api/api_database.h index b9ed7c3c..680bdbbc 100644 --- a/src/api/api_database.h +++ b/src/api/api_database.h @@ -40,7 +40,7 @@ namespace loot { struct ApiDatabase : public DatabaseInterface { - ApiDatabase(std::shared_ptr conditionEvaluator); + explicit ApiDatabase(std::shared_ptr conditionEvaluator); void LoadLists(const std::filesystem::path& masterlist_path, const std::filesystem::path& userlist_path = ""); diff --git a/src/api/game/game.h b/src/api/game/game.h index 85710dbf..a06998a2 100644 --- a/src/api/game/game.h +++ b/src/api/game/game.h @@ -36,7 +36,7 @@ namespace loot { class Game : public GameInterface { public: - Game(const GameType gameType, + explicit Game(const GameType gameType, const std::filesystem::path& gamePath, const std::filesystem::path& gameLocalDataPath = ""); diff --git a/src/api/game/game_cache.h b/src/api/game/game_cache.h index 6127776a..caf3a851 100644 --- a/src/api/game/game_cache.h +++ b/src/api/game/game_cache.h @@ -34,8 +34,8 @@ namespace loot { class GameCache { public: - GameCache(); - GameCache(const GameCache& cache); + explicit GameCache(); + explicit GameCache(const GameCache& cache); GameCache& operator=(const GameCache& cache); diff --git a/src/api/game/load_order_handler.h b/src/api/game/load_order_handler.h index c073d2b4..5073453c 100644 --- a/src/api/game/load_order_handler.h +++ b/src/api/game/load_order_handler.h @@ -38,7 +38,7 @@ namespace loot { class LoadOrderHandler { public: - LoadOrderHandler(); + explicit LoadOrderHandler(); ~LoadOrderHandler(); void Init(const GameType& game, diff --git a/src/api/helpers/git_helper.h b/src/api/helpers/git_helper.h index 9a242720..129ad113 100644 --- a/src/api/helpers/git_helper.h +++ b/src/api/helpers/git_helper.h @@ -34,7 +34,7 @@ namespace loot { class GitHelper { public: - GitHelper(); + explicit GitHelper(); void InitialiseOptions(const std::string& branch, const std::string& filenameToCheckout); diff --git a/src/api/helpers/logging.h b/src/api/helpers/logging.h index 0ea37323..19e52c56 100644 --- a/src/api/helpers/logging.h +++ b/src/api/helpers/logging.h @@ -40,7 +40,7 @@ inline std::shared_ptr getLogger() { class SpdLoggingSink : public spdlog::sinks::base_sink { public: - SpdLoggingSink(std::function callback) { + explicit SpdLoggingSink(std::function callback) { this->callback = callback; } diff --git a/src/api/metadata/condition_evaluator.h b/src/api/metadata/condition_evaluator.h index ff12483f..85117ffb 100644 --- a/src/api/metadata/condition_evaluator.h +++ b/src/api/metadata/condition_evaluator.h @@ -38,7 +38,7 @@ namespace loot { class ConditionEvaluator { public: - ConditionEvaluator(const GameType gameType, + explicit ConditionEvaluator(const GameType gameType, const std::filesystem::path& dataPath); bool Evaluate(const std::string& condition); diff --git a/src/api/plugin.h b/src/api/plugin.h index f08923ab..67944f45 100644 --- a/src/api/plugin.h +++ b/src/api/plugin.h @@ -43,7 +43,7 @@ class GameCache; class Plugin : public PluginInterface { public: - Plugin(const GameType gameType, + explicit Plugin(const GameType gameType, std::shared_ptr gameCache, std::filesystem::path pluginPath, const bool headerOnly); diff --git a/src/api/sorting/plugin_sorting_data.h b/src/api/sorting/plugin_sorting_data.h index 4aebf427..5a522621 100644 --- a/src/api/sorting/plugin_sorting_data.h +++ b/src/api/sorting/plugin_sorting_data.h @@ -31,7 +31,7 @@ namespace loot { class PluginSortingData { public: - PluginSortingData(const Plugin& plugin, + explicit PluginSortingData(const Plugin& plugin, const PluginMetadata& masterlistMetadata, const PluginMetadata& userMetadata, const std::vector& loadOrder, diff --git a/src/tests/api/internals/metadata/plugin_metadata_test.h b/src/tests/api/internals/metadata/plugin_metadata_test.h index 91984506..7dd73391 100644 --- a/src/tests/api/internals/metadata/plugin_metadata_test.h +++ b/src/tests/api/internals/metadata/plugin_metadata_test.h @@ -290,7 +290,8 @@ TEST_P(PluginMetadataTest, newMetadataShouldUseSourcePluginEnabledState) { EXPECT_FALSE(newMetadata.IsEnabled()); } -TEST_P(PluginMetadataTest, newMetadataShouldUseSourcePluginGroupExplicitlyIfItIsExplicit) { +TEST_P(PluginMetadataTest, + newMetadataShouldUseSourcePluginGroupExplicitlyIfItIsExplicit) { PluginMetadata plugin1; PluginMetadata plugin2; @@ -302,8 +303,9 @@ TEST_P(PluginMetadataTest, newMetadataShouldUseSourcePluginGroupExplicitlyIfItIs EXPECT_EQ("group1", newMetadata.GetGroup().value()); } -TEST_P(PluginMetadataTest, - newMetadataShouldUseGivenPluginGroupImplicitlyIfTheSourcePluginGroupIsNotExplicit) { +TEST_P( + PluginMetadataTest, + newMetadataShouldUseGivenPluginGroupImplicitlyIfTheSourcePluginGroupIsNotExplicit) { PluginMetadata plugin1; PluginMetadata plugin2; @@ -314,9 +316,8 @@ TEST_P(PluginMetadataTest, EXPECT_FALSE(newMetadata.GetGroup()); } -TEST_P( - PluginMetadataTest, - newMetadataShouldUseSourcePluginGroupImplicitlyIfTheGroupsAreTheSame) { +TEST_P(PluginMetadataTest, + newMetadataShouldUseSourcePluginGroupImplicitlyIfTheGroupsAreTheSame) { PluginMetadata plugin1; PluginMetadata plugin2; @@ -457,8 +458,10 @@ TEST_P(PluginMetadataTest, simpleMessagesShouldReturnMessagesAsSimpleMessages) { plugin.SetMessages({ Message(MessageType::say, "content1"), Message(MessageType::warn, - {{"content2", french}, - {"other content2", MessageContent::defaultLanguage}}), + std::vector( + {MessageContent("content2", french), + MessageContent("other content2", + MessageContent::defaultLanguage)})), Message(MessageType::error, "content3"), }); @@ -985,8 +988,7 @@ TEST_P(PluginMetadataTest, PluginMetadata plugin = node.as(); EXPECT_EQ("Blank\\.esp", plugin.GetName()); - EXPECT_EQ(std::set( - {PluginCleaningData(5, "utility")}), + EXPECT_EQ(std::set({PluginCleaningData(5, "utility")}), plugin.GetCleanInfo()); }