chore: clean up after new compiler warnings

Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
Rachel Powers 2023-06-04 14:59:37 -07:00
parent 7e0e1ec51d
commit cc41b039e6
25 changed files with 74 additions and 78 deletions

View File

@ -88,7 +88,7 @@ public: /* types */
public: public:
/// virtual destructor to make sure the destruction is COMPLETE /// virtual destructor to make sure the destruction is COMPLETE
virtual ~BaseInstance() {}; virtual ~BaseInstance() {}
virtual void saveNow() = 0; virtual void saveNow() = 0;
@ -154,7 +154,7 @@ public:
virtual MessageLevel::Enum guessLevel([[maybe_unused]] const QString &line, MessageLevel::Enum level) virtual MessageLevel::Enum guessLevel([[maybe_unused]] const QString &line, MessageLevel::Enum level)
{ {
return level; return level;
}; }
virtual QStringList extraArguments(); virtual QStringList extraArguments();
@ -291,7 +291,7 @@ public:
protected: protected:
void changeStatus(Status newStatus); 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; } bool isSpecificSettingsLoaded() const { return m_specific_settings_loaded; }
void setSpecificSettingsLoaded(bool loaded) { m_specific_settings_loaded = loaded; } void setSpecificSettingsLoaded(bool loaded) { m_specific_settings_loaded = loaded; }

View File

@ -48,11 +48,11 @@ public:
virtual bool operator<(BaseVersion &a) virtual bool operator<(BaseVersion &a)
{ {
return name() < a.name(); return name() < a.name();
}; }
virtual bool operator>(BaseVersion &a) virtual bool operator>(BaseVersion &a)
{ {
return name() > a.name(); return name() > a.name();
}; }
}; };
Q_DECLARE_METATYPE(BaseVersion::Ptr) Q_DECLARE_METATYPE(BaseVersion::Ptr)

View File

@ -1,5 +1,8 @@
#pragma once #pragma once
#include <QList>
#include <QString>
enum class ProblemSeverity enum class ProblemSeverity
{ {
None, None,
@ -16,7 +19,7 @@ struct PatchProblem
class ProblemProvider class ProblemProvider
{ {
public: public:
virtual ~ProblemProvider() {}; virtual ~ProblemProvider() {}
virtual const QList<PatchProblem> getProblems() const = 0; virtual const QList<PatchProblem> getProblems() const = 0;
virtual ProblemSeverity getProblemSeverity() const = 0; virtual ProblemSeverity getProblemSeverity() const = 0;
}; };

View File

@ -12,28 +12,20 @@ class Usable;
* *
* @see UseLock * @see UseLock
*/ */
class Usable class Usable {
{
friend class UseLock; friend class UseLock;
public:
std::size_t useCount() const public:
{ virtual ~Usable() {}
return m_useCount;
} std::size_t useCount() const { return m_useCount; }
bool isInUse() const bool isInUse() const { return m_useCount > 0; }
{
return m_useCount > 0; protected:
} virtual void decrementUses() { m_useCount--; }
protected: virtual void incrementUses() { m_useCount++; }
virtual void decrementUses()
{ private:
m_useCount--;
}
virtual void incrementUses()
{
m_useCount++;
}
private:
std::size_t m_useCount = 0; std::size_t m_useCount = 0;
}; };

View File

@ -27,7 +27,8 @@ public:
Component(PackProfile * parent, std::shared_ptr<Meta::Version> version); Component(PackProfile * parent, std::shared_ptr<Meta::Version> version);
Component(PackProfile * parent, const QString & uid, std::shared_ptr<VersionFile> file); Component(PackProfile * parent, const QString & uid, std::shared_ptr<VersionFile> file);
virtual ~Component(){}; virtual ~Component(){}
void applyTo(LaunchProfile *profile); void applyTo(LaunchProfile *profile);
bool isEnabled(); bool isEnabled();

View File

@ -42,7 +42,7 @@
class LaunchProfile: public ProblemProvider class LaunchProfile: public ProblemProvider
{ {
public: public:
virtual ~LaunchProfile() {}; virtual ~LaunchProfile() {}
public: /* application of profile variables from patches */ public: /* application of profile variables from patches */
void applyMinecraftVersion(const QString& id); void applyMinecraftVersion(const QString& id);

View File

@ -23,8 +23,8 @@ struct MojangDownloadInfo
struct MojangLibraryDownloadInfo struct MojangLibraryDownloadInfo
{ {
MojangLibraryDownloadInfo(MojangDownloadInfo::Ptr artifact): artifact(artifact) {}; MojangLibraryDownloadInfo(MojangDownloadInfo::Ptr artifact): artifact(artifact) {}
MojangLibraryDownloadInfo() {}; MojangLibraryDownloadInfo() {}
// types // types
typedef std::shared_ptr<MojangLibraryDownloadInfo> Ptr; typedef std::shared_ptr<MojangLibraryDownloadInfo> Ptr;

View File

@ -63,7 +63,7 @@ public:
Rule(RuleAction result) : m_result(result) Rule(RuleAction result) : m_result(result)
{ {
} }
virtual ~Rule() {}; virtual ~Rule() {}
virtual QJsonObject toJson() = 0; virtual QJsonObject toJson() = 0;
RuleAction apply(const Library *parent, const RuntimeContext & runtimeContext) RuleAction apply(const Library *parent, const RuntimeContext & runtimeContext)
{ {

View File

@ -44,8 +44,8 @@ class ResourceFolderModel : public QAbstractListModel {
bool stopWatching(const QStringList paths); bool stopWatching(const QStringList paths);
/* Helper methods for subclasses, using a predetermined list of paths. */ /* Helper methods for subclasses, using a predetermined list of paths. */
virtual bool startWatching() { return startWatching({ m_dir.absolutePath() }); }; virtual bool startWatching() { return startWatching({ m_dir.absolutePath() }); }
virtual bool stopWatching() { return stopWatching({ 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 /** Given a path in the system, install that resource, moving it to its place in the
* instance file hierarchy. * instance file hierarchy.
@ -73,7 +73,7 @@ class ResourceFolderModel : public QAbstractListModel {
/** Creates a new parse task, if needed, for 'res' and start it.*/ /** Creates a new parse task, if needed, for 'res' and start it.*/
virtual void resolveResource(Resource* res); 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]] bool empty() const { return size() == 0; }
[[nodiscard]] Resource& at(int index) { return *m_resources.at(index); } [[nodiscard]] Resource& at(int index) { return *m_resources.at(index); }
[[nodiscard]] Resource const& at(int index) const { 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 }; 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<int>(size()); } [[nodiscard]] int rowCount(const QModelIndex& parent = {}) const override { return parent.isValid() ? 0 : static_cast<int>(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; [[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 * 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. * 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. /** 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 */ /* A macro to define useful functions to handle Resource* -> T* more easily on derived classes */
#define RESOURCE_HELPERS(T) \ #define RESOURCE_HELPERS(T) \
[[nodiscard]] T* operator[](size_t index) \ [[nodiscard]] T* operator[](int index) \
{ \ { \
return static_cast<T*>(m_resources[index].get()); \ return static_cast<T*>(m_resources[index].get()); \
} \ } \
[[nodiscard]] T* at(size_t index) \ [[nodiscard]] T* at(int index) \
{ \ { \
return static_cast<T*>(m_resources[index].get()); \ return static_cast<T*>(m_resources[index].get()); \
} \ } \
[[nodiscard]] const T* at(size_t index) const \ [[nodiscard]] const T* at(int index) const \
{ \ { \
return static_cast<const T*>(m_resources.at(index).get()); \ return static_cast<const T*>(m_resources.at(index).get()); \
} \ } \

View File

@ -104,7 +104,7 @@ struct IndexedPack {
ExtraPackData extraData; ExtraPackData extraData;
// For internal use, not provided by APIs // For internal use, not provided by APIs
[[nodiscard]] bool isVersionSelected(size_t index) const [[nodiscard]] bool isVersionSelected(int index) const
{ {
if (!versionsLoaded) if (!versionsLoaded)
return false; return false;

View File

@ -118,28 +118,30 @@ class ResourceAPI {
public slots: public slots:
[[nodiscard]] virtual Task::Ptr searchProjects(SearchArgs&&, SearchCallbacks&&) const [[nodiscard]] virtual Task::Ptr searchProjects(SearchArgs&&, SearchCallbacks&&) const
{ {
qWarning() << "TODO"; qWarning() << "TODO: ResourceAPI::searchProjects";
return nullptr; 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; 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; return nullptr;
} }
[[nodiscard]] virtual Task::Ptr getProjectInfo(ProjectInfoArgs&&, ProjectInfoCallbacks&&) const [[nodiscard]] virtual Task::Ptr getProjectInfo(ProjectInfoArgs&&, ProjectInfoCallbacks&&) const
{ {
qWarning() << "TODO"; qWarning() << "TODO: ResourceAPI::getProjectInfo";
return nullptr; return nullptr;
} }
[[nodiscard]] virtual Task::Ptr getProjectVersions(VersionSearchArgs&&, VersionSearchCallbacks&&) const [[nodiscard]] virtual Task::Ptr getProjectVersions(VersionSearchArgs&&, VersionSearchCallbacks&&) const
{ {
qWarning() << "TODO"; qWarning() << "TODO: ResourceAPI::getProjectVersions";
return nullptr; return nullptr;
} }

View File

@ -66,7 +66,7 @@ class Download : public NetAction {
public: public:
void addValidator(Validator* v); void addValidator(Validator* v);
auto abort() -> bool override; auto abort() -> bool override;
auto canAbort() const -> bool override { return true; }; auto canAbort() const -> bool override { return true; }
private: private:
auto handleRedirect() -> bool; auto handleRedirect() -> bool;

View File

@ -74,7 +74,7 @@ class MetaEntry {
auto getMaximumAge() -> qint64 { return m_max_age; } auto getMaximumAge() -> qint64 { return m_max_age; }
void setMaximumAge(qint64 age) { m_max_age = 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: protected:
QString m_baseId; QString m_baseId;

View File

@ -45,7 +45,7 @@
class NetAction : public Task { class NetAction : public Task {
Q_OBJECT Q_OBJECT
protected: protected:
explicit NetAction() : Task(){}; explicit NetAction() : Task(){}
public: public:
using Ptr = shared_qobject_ptr<NetAction>; using Ptr = shared_qobject_ptr<NetAction>;
@ -71,7 +71,7 @@ class NetAction : public Task {
i++; i++;
} }
}; }
public slots: public slots:
void startAction(shared_qobject_ptr<QNetworkAccessManager> network) void startAction(shared_qobject_ptr<QNetworkAccessManager> network)
@ -81,7 +81,7 @@ class NetAction : public Task {
} }
protected: protected:
void executeTask() override{}; void executeTask() override{}
public: public:
shared_qobject_ptr<QNetworkAccessManager> m_network; shared_qobject_ptr<QNetworkAccessManager> m_network;

View File

@ -40,8 +40,9 @@ namespace Net {
class Validator class Validator
{ {
public: /* con/des */ public: /* con/des */
Validator() {}; Validator() {}
virtual ~Validator() {};
virtual ~Validator() {}
public: /* methods */ public: /* methods */
virtual bool init(QNetworkRequest & request) = 0; virtual bool init(QNetworkRequest & request) = 0;

View File

@ -8,6 +8,6 @@ public:
typedef std::shared_ptr<IPathMatcher> Ptr; typedef std::shared_ptr<IPathMatcher> Ptr;
public: public:
virtual ~IPathMatcher(){}; virtual ~IPathMatcher() {}
virtual bool matches(const QString &string) const = 0; virtual bool matches(const QString &string) const = 0;
}; };

View File

@ -4,7 +4,7 @@
class RegexpMatcher : public IPathMatcher class RegexpMatcher : public IPathMatcher
{ {
public: public:
virtual ~RegexpMatcher() {}; virtual ~RegexpMatcher() {}
RegexpMatcher(const QString &regexp) RegexpMatcher(const QString &regexp)
{ {
m_regexp.setPattern(regexp); m_regexp.setPattern(regexp);

View File

@ -53,7 +53,7 @@ class ConcurrentTask : public Task {
bool canAbort() const override { return true; } 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; auto getStepProgress() const -> TaskStepProgressList override;
void addTask(Task::Ptr task); void addTask(Task::Ptr task);
@ -80,7 +80,7 @@ class ConcurrentTask : public Task {
protected: protected:
// NOTE: This is not thread-safe. // 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<unsigned int>(m_queue.size() + m_doing.size() + m_done.size()); }
enum class Operation { ADDED, REMOVED, CHANGED }; enum class Operation { ADDED, REMOVED, CHANGED };
void updateStepProgress(TaskStepProgress const& changed_progress, Operation); void updateStepProgress(TaskStepProgress const& changed_progress, Operation);

View File

@ -71,12 +71,12 @@ struct TaskStepProgress {
this->uid = uid; this->uid = uid;
} }
bool isDone() const { return (state == TaskStepState::Failed) || (state == TaskStepState::Succeeded); } 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_current = this->current;
this->old_total = this->total; this->old_total = this->total;
this->current = current; this->current = new_current;
this->total = total; this->total = new_total;
this->state = TaskStepState::Running; this->state = TaskStepState::Running;
} }
}; };
@ -155,7 +155,7 @@ class Task : public QObject, public QRunnable {
void run() override { start(); } void run() override { start(); }
virtual void 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); } void setAbortable(bool can_abort) { m_can_abort = can_abort; emit abortStatusChanged(can_abort); }

View File

@ -274,7 +274,6 @@ void readIndex(const QString & path, QMap<QString, Language>& languages)
return; return;
} }
int index = 1;
try try
{ {
auto toplevel_doc = Json::requireDocument(data); auto toplevel_doc = Json::requireDocument(data);
@ -307,7 +306,6 @@ void readIndex(const QString & path, QMap<QString, Language>& languages)
lang.file_size = Json::requireInteger(langObj, "size"); lang.file_size = Json::requireInteger(langObj, "size");
languages.insert(lang.key, lang); languages.insert(lang.key, lang);
index++;
} }
} }
catch (Json::JsonException & e) catch (Json::JsonException & e)

View File

@ -32,7 +32,7 @@ class DummyResourceAPI : public ResourceAPI {
} }
DummyResourceAPI() : ResourceAPI() {} DummyResourceAPI() : ResourceAPI() {}
[[nodiscard]] auto getSortingMethods() const -> QList<SortingMethod> override { return {}; }; [[nodiscard]] auto getSortingMethods() const -> QList<SortingMethod> override { return {}; }
[[nodiscard]] Task::Ptr searchProjects(SearchArgs&&, SearchCallbacks&& callbacks) const override [[nodiscard]] Task::Ptr searchProjects(SearchArgs&&, SearchCallbacks&& callbacks) const override
{ {

View File

@ -91,10 +91,9 @@ class LinkTask : public Task {
emitSucceeded(); emitSucceeded();
} }
}; }
FS::create_link *m_lnk; FS::create_link *m_lnk;
bool m_useHard = false;
bool m_linkRecursive = true; bool m_linkRecursive = true;
}; };
@ -346,7 +345,7 @@ slots:
void test_link() void test_link()
{ {
QString folder = QFINDTESTDATA("testdata/FileSystem/test_folder"); QString folder = QFINDTESTDATA("testdata/FileSystem/test_folder");
auto f = [&folder, this]() auto f = [&folder]()
{ {
QTemporaryDir tempDir; QTemporaryDir tempDir;
tempDir.setAutoRemove(true); tempDir.setAutoRemove(true);
@ -640,7 +639,7 @@ slots:
void test_link_with_max_depth() void test_link_with_max_depth()
{ {
QString folder = QFINDTESTDATA("testdata/FileSystem/test_folder"); QString folder = QFINDTESTDATA("testdata/FileSystem/test_folder");
auto f = [&folder, this]() auto f = [&folder]()
{ {
QTemporaryDir tempDir; QTemporaryDir tempDir;
tempDir.setAutoRemove(true); tempDir.setAutoRemove(true);

View File

@ -29,7 +29,7 @@ slots:
// initialize random buffer // initialize random buffer
for(int i = 0; i < size; i++) for(int i = 0; i < size; i++)
{ {
random.append((char)idis(eng)); random.append(static_cast<char>(idis(eng)));
} }
// initialize fibonacci // initialize fibonacci

View File

@ -39,17 +39,17 @@ class DummyResourceModel : public ResourceModel {
public: public:
DummyResourceModel() : ResourceModel(new DummyResourceAPI) {} DummyResourceModel() : ResourceModel(new DummyResourceAPI) {}
[[nodiscard]] auto metaEntryBase() const -> QString override { return ""; }; [[nodiscard]] auto metaEntryBase() const -> QString override { return ""; }
ResourceAPI::SearchArgs createSearchArguments() override { return {}; }; ResourceAPI::SearchArgs createSearchArguments() override { return {}; }
ResourceAPI::VersionSearchArgs createVersionsArguments(QModelIndex&) override { return {}; }; ResourceAPI::VersionSearchArgs createVersionsArguments(QModelIndex&) override { return {}; }
ResourceAPI::ProjectInfoArgs createInfoArguments(QModelIndex&) override { return {}; }; ResourceAPI::ProjectInfoArgs createInfoArguments(QModelIndex&) override { return {}; }
QJsonArray documentToArray(QJsonDocument& doc) const override { return doc.object().value("hits").toArray(); } QJsonArray documentToArray(QJsonDocument& doc) const override { return doc.object().value("hits").toArray(); }
void loadIndexedPack(ModPlatform::IndexedPack& pack, QJsonObject& obj) override 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.description = Json::requireString(obj, "description");
pack.addonId = Json::requireString(obj, "project_id"); pack.addonId = Json::requireString(obj, "project_id");
} }

View File

@ -22,7 +22,7 @@ class BasicTask : public Task {
void executeTask() override void executeTask() override
{ {
emitSucceeded(); emitSucceeded();
}; }
}; };
/* Does nothing. Only used for testing. */ /* Does nothing. Only used for testing. */
@ -34,7 +34,7 @@ class BasicTask_MultiStep : public Task {
private: private:
auto isMultiStep() const -> bool override { return true; } auto isMultiStep() const -> bool override { return true; }
void executeTask() override {}; void executeTask() override {}
}; };
class BigConcurrentTask : public ConcurrentTask { class BigConcurrentTask : public ConcurrentTask {