From cc41b039e6ba2a24c0ded9fb573bee6050aa2ac9 Mon Sep 17 00:00:00 2001 From: Rachel Powers <508861+Ryex@users.noreply.github.com> Date: Sun, 4 Jun 2023 14:59:37 -0700 Subject: [PATCH] chore: clean up after new compiler warnings Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com> --- launcher/BaseInstance.h | 6 ++-- launcher/BaseVersion.h | 4 +-- launcher/ProblemProvider.h | 5 ++- launcher/Usable.h | 34 ++++++++------------ launcher/minecraft/Component.h | 3 +- launcher/minecraft/LaunchProfile.h | 2 +- launcher/minecraft/MojangDownloadInfo.h | 4 +-- launcher/minecraft/Rule.h | 2 +- launcher/minecraft/mod/ResourceFolderModel.h | 16 ++++----- launcher/modplatform/ModIndex.h | 2 +- launcher/modplatform/ResourceAPI.h | 16 +++++---- launcher/net/Download.h | 2 +- launcher/net/HttpMetaCache.h | 2 +- launcher/net/NetAction.h | 6 ++-- launcher/net/Validator.h | 5 +-- launcher/pathmatcher/IPathMatcher.h | 2 +- launcher/pathmatcher/RegexpMatcher.h | 2 +- launcher/tasks/ConcurrentTask.h | 4 +-- launcher/tasks/Task.h | 8 ++--- launcher/translations/TranslationsModel.cpp | 2 -- tests/DummyResourceAPI.h | 2 +- tests/FileSystem_test.cpp | 7 ++-- tests/GZip_test.cpp | 2 +- tests/ResourceModel_test.cpp | 10 +++--- tests/Task_test.cpp | 4 +-- 25 files changed, 74 insertions(+), 78 deletions(-) diff --git a/launcher/BaseInstance.h b/launcher/BaseInstance.h index 83a8064fa..f6b5a7a56 100644 --- a/launcher/BaseInstance.h +++ b/launcher/BaseInstance.h @@ -88,7 +88,7 @@ public: /* types */ public: /// virtual destructor to make sure the destruction is COMPLETE - virtual ~BaseInstance() {}; + virtual ~BaseInstance() {} virtual void saveNow() = 0; @@ -154,7 +154,7 @@ public: virtual MessageLevel::Enum guessLevel([[maybe_unused]] const QString &line, MessageLevel::Enum level) { return level; - }; + } virtual QStringList extraArguments(); @@ -291,7 +291,7 @@ public: protected: void changeStatus(Status newStatus); - SettingsObjectPtr globalSettings() const { return m_global_settings.lock(); }; + SettingsObjectPtr globalSettings() const { return m_global_settings.lock(); } bool isSpecificSettingsLoaded() const { return m_specific_settings_loaded; } void setSpecificSettingsLoaded(bool loaded) { m_specific_settings_loaded = loaded; } diff --git a/launcher/BaseVersion.h b/launcher/BaseVersion.h index ca0e45027..7bfc51e3b 100644 --- a/launcher/BaseVersion.h +++ b/launcher/BaseVersion.h @@ -48,11 +48,11 @@ public: virtual bool operator<(BaseVersion &a) { return name() < a.name(); - }; + } virtual bool operator>(BaseVersion &a) { return name() > a.name(); - }; + } }; Q_DECLARE_METATYPE(BaseVersion::Ptr) diff --git a/launcher/ProblemProvider.h b/launcher/ProblemProvider.h index cd4745fa1..d7d4c4e57 100644 --- a/launcher/ProblemProvider.h +++ b/launcher/ProblemProvider.h @@ -1,5 +1,8 @@ #pragma once +#include +#include + enum class ProblemSeverity { None, @@ -16,7 +19,7 @@ struct PatchProblem class ProblemProvider { public: - virtual ~ProblemProvider() {}; + virtual ~ProblemProvider() {} virtual const QList getProblems() const = 0; virtual ProblemSeverity getProblemSeverity() const = 0; }; diff --git a/launcher/Usable.h b/launcher/Usable.h index a3e880f38..f5818cbb4 100644 --- a/launcher/Usable.h +++ b/launcher/Usable.h @@ -12,28 +12,20 @@ class Usable; * * @see UseLock */ -class Usable -{ +class Usable { friend class UseLock; -public: - std::size_t useCount() const - { - return m_useCount; - } - bool isInUse() const - { - return m_useCount > 0; - } -protected: - virtual void decrementUses() - { - m_useCount--; - } - virtual void incrementUses() - { - m_useCount++; - } -private: + + public: + virtual ~Usable() {} + + std::size_t useCount() const { return m_useCount; } + bool isInUse() const { return m_useCount > 0; } + + protected: + virtual void decrementUses() { m_useCount--; } + virtual void incrementUses() { m_useCount++; } + + private: std::size_t m_useCount = 0; }; diff --git a/launcher/minecraft/Component.h b/launcher/minecraft/Component.h index ef7c99470..e7419c41a 100644 --- a/launcher/minecraft/Component.h +++ b/launcher/minecraft/Component.h @@ -27,7 +27,8 @@ public: Component(PackProfile * parent, std::shared_ptr version); Component(PackProfile * parent, const QString & uid, std::shared_ptr file); - virtual ~Component(){}; + virtual ~Component(){} + void applyTo(LaunchProfile *profile); bool isEnabled(); diff --git a/launcher/minecraft/LaunchProfile.h b/launcher/minecraft/LaunchProfile.h index 49c1217d3..79e688246 100644 --- a/launcher/minecraft/LaunchProfile.h +++ b/launcher/minecraft/LaunchProfile.h @@ -42,7 +42,7 @@ class LaunchProfile: public ProblemProvider { public: - virtual ~LaunchProfile() {}; + virtual ~LaunchProfile() {} public: /* application of profile variables from patches */ void applyMinecraftVersion(const QString& id); diff --git a/launcher/minecraft/MojangDownloadInfo.h b/launcher/minecraft/MojangDownloadInfo.h index 13e27e15e..784374c87 100644 --- a/launcher/minecraft/MojangDownloadInfo.h +++ b/launcher/minecraft/MojangDownloadInfo.h @@ -23,8 +23,8 @@ struct MojangDownloadInfo struct MojangLibraryDownloadInfo { - MojangLibraryDownloadInfo(MojangDownloadInfo::Ptr artifact): artifact(artifact) {}; - MojangLibraryDownloadInfo() {}; + MojangLibraryDownloadInfo(MojangDownloadInfo::Ptr artifact): artifact(artifact) {} + MojangLibraryDownloadInfo() {} // types typedef std::shared_ptr Ptr; diff --git a/launcher/minecraft/Rule.h b/launcher/minecraft/Rule.h index 846e8e428..70fd70b68 100644 --- a/launcher/minecraft/Rule.h +++ b/launcher/minecraft/Rule.h @@ -63,7 +63,7 @@ public: Rule(RuleAction result) : m_result(result) { } - virtual ~Rule() {}; + virtual ~Rule() {} virtual QJsonObject toJson() = 0; RuleAction apply(const Library *parent, const RuntimeContext & runtimeContext) { diff --git a/launcher/minecraft/mod/ResourceFolderModel.h b/launcher/minecraft/mod/ResourceFolderModel.h index 0a35e1bca..7b5256e03 100644 --- a/launcher/minecraft/mod/ResourceFolderModel.h +++ b/launcher/minecraft/mod/ResourceFolderModel.h @@ -44,8 +44,8 @@ class ResourceFolderModel : public QAbstractListModel { bool stopWatching(const QStringList paths); /* Helper methods for subclasses, using a predetermined list of paths. */ - virtual bool startWatching() { return startWatching({ m_dir.absolutePath() }); }; - virtual bool stopWatching() { return stopWatching({ m_dir.absolutePath() }); }; + virtual bool startWatching() { return startWatching({ m_dir.absolutePath() }); } + virtual bool stopWatching() { return stopWatching({ m_dir.absolutePath() }); } /** Given a path in the system, install that resource, moving it to its place in the * instance file hierarchy. @@ -73,7 +73,7 @@ class ResourceFolderModel : public QAbstractListModel { /** Creates a new parse task, if needed, for 'res' and start it.*/ virtual void resolveResource(Resource* res); - [[nodiscard]] size_t size() const { return m_resources.size(); }; + [[nodiscard]] int size() const { return m_resources.size(); } [[nodiscard]] bool empty() const { return size() == 0; } [[nodiscard]] Resource& at(int index) { return *m_resources.at(index); } [[nodiscard]] Resource const& at(int index) const { return *m_resources.at(index); } @@ -94,7 +94,7 @@ class ResourceFolderModel : public QAbstractListModel { enum Columns { ACTIVE_COLUMN = 0, NAME_COLUMN, DATE_COLUMN, NUM_COLUMNS }; [[nodiscard]] int rowCount(const QModelIndex& parent = {}) const override { return parent.isValid() ? 0 : static_cast(size()); } - [[nodiscard]] int columnCount(const QModelIndex& parent = {}) const override { return parent.isValid() ? 0 : NUM_COLUMNS; }; + [[nodiscard]] int columnCount(const QModelIndex& parent = {}) const override { return parent.isValid() ? 0 : NUM_COLUMNS; } [[nodiscard]] Qt::DropActions supportedDropActions() const override; @@ -151,7 +151,7 @@ class ResourceFolderModel : public QAbstractListModel { * This task should load and parse all heavy info needed by a resource, such as parsing a manifest. It gets executed * in the background, so it slowly updates the UI as tasks get done. */ - [[nodiscard]] virtual Task* createParseTask(Resource&) { return nullptr; }; + [[nodiscard]] virtual Task* createParseTask(Resource&) { return nullptr; } /** Standard implementation of the model update logic. * @@ -210,15 +210,15 @@ class ResourceFolderModel : public QAbstractListModel { /* A macro to define useful functions to handle Resource* -> T* more easily on derived classes */ #define RESOURCE_HELPERS(T) \ - [[nodiscard]] T* operator[](size_t index) \ + [[nodiscard]] T* operator[](int index) \ { \ return static_cast(m_resources[index].get()); \ } \ - [[nodiscard]] T* at(size_t index) \ + [[nodiscard]] T* at(int index) \ { \ return static_cast(m_resources[index].get()); \ } \ - [[nodiscard]] const T* at(size_t index) const \ + [[nodiscard]] const T* at(int index) const \ { \ return static_cast(m_resources.at(index).get()); \ } \ diff --git a/launcher/modplatform/ModIndex.h b/launcher/modplatform/ModIndex.h index 8d0223f91..a4d431e30 100644 --- a/launcher/modplatform/ModIndex.h +++ b/launcher/modplatform/ModIndex.h @@ -104,7 +104,7 @@ struct IndexedPack { ExtraPackData extraData; // For internal use, not provided by APIs - [[nodiscard]] bool isVersionSelected(size_t index) const + [[nodiscard]] bool isVersionSelected(int index) const { if (!versionsLoaded) return false; diff --git a/launcher/modplatform/ResourceAPI.h b/launcher/modplatform/ResourceAPI.h index 34f337791..d4c9af8ad 100644 --- a/launcher/modplatform/ResourceAPI.h +++ b/launcher/modplatform/ResourceAPI.h @@ -118,28 +118,30 @@ class ResourceAPI { public slots: [[nodiscard]] virtual Task::Ptr searchProjects(SearchArgs&&, SearchCallbacks&&) const { - qWarning() << "TODO"; + qWarning() << "TODO: ResourceAPI::searchProjects"; return nullptr; } - [[nodiscard]] virtual Task::Ptr getProject(QString addonId, QByteArray* response) const + /** getProject(QString addonId, QByteArray* responce)*/ + [[nodiscard]] virtual Task::Ptr getProject(QString, QByteArray*) const { - qWarning() << "TODO"; + qWarning() << "TODO: ResourceAPI::getProject"; return nullptr; } - [[nodiscard]] virtual Task::Ptr getProjects(QStringList addonIds, QByteArray* response) const + /** getProjects(QStringList addonIds, QByteArray* responce) */ + [[nodiscard]] virtual Task::Ptr getProjects(QStringList, QByteArray*) const { - qWarning() << "TODO"; + qWarning() << "TODO: ResourceAPI::getProjects"; return nullptr; } [[nodiscard]] virtual Task::Ptr getProjectInfo(ProjectInfoArgs&&, ProjectInfoCallbacks&&) const { - qWarning() << "TODO"; + qWarning() << "TODO: ResourceAPI::getProjectInfo"; return nullptr; } [[nodiscard]] virtual Task::Ptr getProjectVersions(VersionSearchArgs&&, VersionSearchCallbacks&&) const { - qWarning() << "TODO"; + qWarning() << "TODO: ResourceAPI::getProjectVersions"; return nullptr; } diff --git a/launcher/net/Download.h b/launcher/net/Download.h index 920164a30..afa0eb5ce 100644 --- a/launcher/net/Download.h +++ b/launcher/net/Download.h @@ -66,7 +66,7 @@ class Download : public NetAction { public: void addValidator(Validator* v); auto abort() -> bool override; - auto canAbort() const -> bool override { return true; }; + auto canAbort() const -> bool override { return true; } private: auto handleRedirect() -> bool; diff --git a/launcher/net/HttpMetaCache.h b/launcher/net/HttpMetaCache.h index 0dcb5668d..036a8dd94 100644 --- a/launcher/net/HttpMetaCache.h +++ b/launcher/net/HttpMetaCache.h @@ -74,7 +74,7 @@ class MetaEntry { auto getMaximumAge() -> qint64 { return m_max_age; } void setMaximumAge(qint64 age) { m_max_age = age; } - bool isExpired(qint64 offset) { return !m_is_eternal && (m_current_age >= m_max_age - offset); }; + bool isExpired(qint64 offset) { return !m_is_eternal && (m_current_age >= m_max_age - offset); } protected: QString m_baseId; diff --git a/launcher/net/NetAction.h b/launcher/net/NetAction.h index ab9322c26..c22eaf9f3 100644 --- a/launcher/net/NetAction.h +++ b/launcher/net/NetAction.h @@ -45,7 +45,7 @@ class NetAction : public Task { Q_OBJECT protected: - explicit NetAction() : Task(){}; + explicit NetAction() : Task(){} public: using Ptr = shared_qobject_ptr; @@ -71,7 +71,7 @@ class NetAction : public Task { i++; } - }; + } public slots: void startAction(shared_qobject_ptr network) @@ -81,7 +81,7 @@ class NetAction : public Task { } protected: - void executeTask() override{}; + void executeTask() override{} public: shared_qobject_ptr m_network; diff --git a/launcher/net/Validator.h b/launcher/net/Validator.h index 6b3d46352..c8ce79223 100644 --- a/launcher/net/Validator.h +++ b/launcher/net/Validator.h @@ -40,8 +40,9 @@ namespace Net { class Validator { public: /* con/des */ - Validator() {}; - virtual ~Validator() {}; + Validator() {} + + virtual ~Validator() {} public: /* methods */ virtual bool init(QNetworkRequest & request) = 0; diff --git a/launcher/pathmatcher/IPathMatcher.h b/launcher/pathmatcher/IPathMatcher.h index 192782d7c..1457d3e5b 100644 --- a/launcher/pathmatcher/IPathMatcher.h +++ b/launcher/pathmatcher/IPathMatcher.h @@ -8,6 +8,6 @@ public: typedef std::shared_ptr Ptr; public: - virtual ~IPathMatcher(){}; + virtual ~IPathMatcher() {} virtual bool matches(const QString &string) const = 0; }; diff --git a/launcher/pathmatcher/RegexpMatcher.h b/launcher/pathmatcher/RegexpMatcher.h index 825d488c3..6da651ef1 100644 --- a/launcher/pathmatcher/RegexpMatcher.h +++ b/launcher/pathmatcher/RegexpMatcher.h @@ -4,7 +4,7 @@ class RegexpMatcher : public IPathMatcher { public: - virtual ~RegexpMatcher() {}; + virtual ~RegexpMatcher() {} RegexpMatcher(const QString ®exp) { m_regexp.setPattern(regexp); diff --git a/launcher/tasks/ConcurrentTask.h b/launcher/tasks/ConcurrentTask.h index 6325fc9e7..481ebf852 100644 --- a/launcher/tasks/ConcurrentTask.h +++ b/launcher/tasks/ConcurrentTask.h @@ -53,7 +53,7 @@ class ConcurrentTask : public Task { bool canAbort() const override { return true; } - inline auto isMultiStep() const -> bool override { return totalSize() > 1; }; + inline auto isMultiStep() const -> bool override { return totalSize() > 1; } auto getStepProgress() const -> TaskStepProgressList override; void addTask(Task::Ptr task); @@ -80,7 +80,7 @@ class ConcurrentTask : public Task { protected: // NOTE: This is not thread-safe. - [[nodiscard]] unsigned int totalSize() const { return m_queue.size() + m_doing.size() + m_done.size(); } + [[nodiscard]] unsigned int totalSize() const { return static_cast(m_queue.size() + m_doing.size() + m_done.size()); } enum class Operation { ADDED, REMOVED, CHANGED }; void updateStepProgress(TaskStepProgress const& changed_progress, Operation); diff --git a/launcher/tasks/Task.h b/launcher/tasks/Task.h index 6d8bbbb46..d3bcc84f7 100644 --- a/launcher/tasks/Task.h +++ b/launcher/tasks/Task.h @@ -71,12 +71,12 @@ struct TaskStepProgress { this->uid = uid; } bool isDone() const { return (state == TaskStepState::Failed) || (state == TaskStepState::Succeeded); } - void update(qint64 current, qint64 total) { + void update(qint64 new_current, qint64 new_total) { this->old_current = this->current; this->old_total = this->total; - this->current = current; - this->total = total; + this->current = new_current; + this->total = new_total; this->state = TaskStepState::Running; } }; @@ -155,7 +155,7 @@ class Task : public QObject, public QRunnable { void run() override { start(); } virtual void start(); - virtual bool abort() { if(canAbort()) emitAborted(); return canAbort(); }; + virtual bool abort() { if(canAbort()) emitAborted(); return canAbort(); } void setAbortable(bool can_abort) { m_can_abort = can_abort; emit abortStatusChanged(can_abort); } diff --git a/launcher/translations/TranslationsModel.cpp b/launcher/translations/TranslationsModel.cpp index 46db48049..8a0043152 100644 --- a/launcher/translations/TranslationsModel.cpp +++ b/launcher/translations/TranslationsModel.cpp @@ -274,7 +274,6 @@ void readIndex(const QString & path, QMap& languages) return; } - int index = 1; try { auto toplevel_doc = Json::requireDocument(data); @@ -307,7 +306,6 @@ void readIndex(const QString & path, QMap& languages) lang.file_size = Json::requireInteger(langObj, "size"); languages.insert(lang.key, lang); - index++; } } catch (Json::JsonException & e) diff --git a/tests/DummyResourceAPI.h b/tests/DummyResourceAPI.h index 0cc909584..35de95151 100644 --- a/tests/DummyResourceAPI.h +++ b/tests/DummyResourceAPI.h @@ -32,7 +32,7 @@ class DummyResourceAPI : public ResourceAPI { } DummyResourceAPI() : ResourceAPI() {} - [[nodiscard]] auto getSortingMethods() const -> QList override { return {}; }; + [[nodiscard]] auto getSortingMethods() const -> QList override { return {}; } [[nodiscard]] Task::Ptr searchProjects(SearchArgs&&, SearchCallbacks&& callbacks) const override { diff --git a/tests/FileSystem_test.cpp b/tests/FileSystem_test.cpp index ec1f0bcff..9bb681aef 100644 --- a/tests/FileSystem_test.cpp +++ b/tests/FileSystem_test.cpp @@ -91,10 +91,9 @@ class LinkTask : public Task { emitSucceeded(); } - }; + } FS::create_link *m_lnk; - bool m_useHard = false; bool m_linkRecursive = true; }; @@ -346,7 +345,7 @@ slots: void test_link() { QString folder = QFINDTESTDATA("testdata/FileSystem/test_folder"); - auto f = [&folder, this]() + auto f = [&folder]() { QTemporaryDir tempDir; tempDir.setAutoRemove(true); @@ -640,7 +639,7 @@ slots: void test_link_with_max_depth() { QString folder = QFINDTESTDATA("testdata/FileSystem/test_folder"); - auto f = [&folder, this]() + auto f = [&folder]() { QTemporaryDir tempDir; tempDir.setAutoRemove(true); diff --git a/tests/GZip_test.cpp b/tests/GZip_test.cpp index 82503d81d..ccaa36101 100644 --- a/tests/GZip_test.cpp +++ b/tests/GZip_test.cpp @@ -29,7 +29,7 @@ slots: // initialize random buffer for(int i = 0; i < size; i++) { - random.append((char)idis(eng)); + random.append(static_cast(idis(eng))); } // initialize fibonacci diff --git a/tests/ResourceModel_test.cpp b/tests/ResourceModel_test.cpp index c0d9cd95d..ecaea5245 100644 --- a/tests/ResourceModel_test.cpp +++ b/tests/ResourceModel_test.cpp @@ -39,17 +39,17 @@ class DummyResourceModel : public ResourceModel { public: DummyResourceModel() : ResourceModel(new DummyResourceAPI) {} - [[nodiscard]] auto metaEntryBase() const -> QString override { return ""; }; + [[nodiscard]] auto metaEntryBase() const -> QString override { return ""; } - ResourceAPI::SearchArgs createSearchArguments() override { return {}; }; - ResourceAPI::VersionSearchArgs createVersionsArguments(QModelIndex&) override { return {}; }; - ResourceAPI::ProjectInfoArgs createInfoArguments(QModelIndex&) override { return {}; }; + ResourceAPI::SearchArgs createSearchArguments() override { return {}; } + ResourceAPI::VersionSearchArgs createVersionsArguments(QModelIndex&) override { return {}; } + ResourceAPI::ProjectInfoArgs createInfoArguments(QModelIndex&) override { return {}; } QJsonArray documentToArray(QJsonDocument& doc) const override { return doc.object().value("hits").toArray(); } void loadIndexedPack(ModPlatform::IndexedPack& pack, QJsonObject& obj) override { - pack.authors.append({ Json::requireString(obj, "author") }); + pack.authors.append({ Json::requireString(obj, "author"), "" }); pack.description = Json::requireString(obj, "description"); pack.addonId = Json::requireString(obj, "project_id"); } diff --git a/tests/Task_test.cpp b/tests/Task_test.cpp index dabe5da26..04f2abcc1 100644 --- a/tests/Task_test.cpp +++ b/tests/Task_test.cpp @@ -22,7 +22,7 @@ class BasicTask : public Task { void executeTask() override { emitSucceeded(); - }; + } }; /* Does nothing. Only used for testing. */ @@ -34,7 +34,7 @@ class BasicTask_MultiStep : public Task { private: auto isMultiStep() const -> bool override { return true; } - void executeTask() override {}; + void executeTask() override {} }; class BigConcurrentTask : public ConcurrentTask {