aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmake/CompilerWarnings.cmake161
-rw-r--r--launcher/BaseInstance.h6
-rw-r--r--launcher/BaseVersion.h4
-rw-r--r--launcher/CMakeLists.txt13
-rw-r--r--launcher/ProblemProvider.h5
-rw-r--r--launcher/Usable.h34
-rw-r--r--launcher/java/JavaVersion.h2
-rw-r--r--launcher/minecraft/Component.h3
-rw-r--r--launcher/minecraft/LaunchProfile.h2
-rw-r--r--launcher/minecraft/MojangDownloadInfo.h4
-rw-r--r--launcher/minecraft/Rule.h2
-rw-r--r--launcher/minecraft/mod/ResourceFolderModel.h16
-rw-r--r--launcher/modplatform/ModIndex.h2
-rw-r--r--launcher/modplatform/ResourceAPI.h10
-rw-r--r--launcher/net/Download.h2
-rw-r--r--launcher/net/HttpMetaCache.h2
-rw-r--r--launcher/net/NetAction.h6
-rw-r--r--launcher/net/Validator.h5
-rw-r--r--launcher/pathmatcher/IPathMatcher.h2
-rw-r--r--launcher/pathmatcher/RegexpMatcher.h2
-rw-r--r--launcher/tasks/ConcurrentTask.h4
-rw-r--r--launcher/tasks/Task.h8
-rw-r--r--launcher/translations/TranslationsModel.cpp2
-rw-r--r--tests/DummyResourceAPI.h2
-rw-r--r--tests/FileSystem_test.cpp8
-rw-r--r--tests/GZip_test.cpp2
-rw-r--r--tests/ResourceModel_test.cpp10
-rw-r--r--tests/Task_test.cpp4
28 files changed, 246 insertions, 77 deletions
diff --git a/cmake/CompilerWarnings.cmake b/cmake/CompilerWarnings.cmake
new file mode 100644
index 00000000..b0366401
--- /dev/null
+++ b/cmake/CompilerWarnings.cmake
@@ -0,0 +1,161 @@
+#
+# Function to set compiler warnings with reasonable defaults at the project level.
+# Taken from https://github.com/aminya/project_options/blob/main/src/CompilerWarnings.cmake
+# under the folowing license:
+#
+# MIT License
+#
+# Copyright (c) 2022-2100 Amin Yahyaabadi
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in all
+# copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+#
+
+include_guard()
+
+function(_set_project_warnings_add_target_link_option TARGET OPTIONS)
+ target_link_options(${_project_name} INTERFACE ${OPTIONS})
+endfunction()
+
+# Set the compiler warnings
+#
+# https://clang.llvm.org/docs/DiagnosticsReference.html
+# https://github.com/lefticus/cppbestpractices/blob/master/02-Use_the_Tools_Available.md
+function(
+ set_project_warnings
+ _project_name
+ WARNINGS_AS_ERRORS
+ MSVC_WARNINGS
+ CLANG_WARNINGS
+ GCC_WARNINGS
+)
+ if("${MSVC_WARNINGS}" STREQUAL "")
+ set(MSVC_WARNINGS
+ /W4 # Baseline reasonable warnings
+ /w14242 # 'identifier': conversion from 'type1' to 'type1', possible loss of data
+ /w14254 # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data
+ /w14263 # 'function': member function does not override any base class virtual member function
+ /w14265 # 'classname': class has virtual functions, but destructor is not virtual instances of this class may not
+ # be destructed correctly
+ /w14287 # 'operator': unsigned/negative constant mismatch
+ /we4289 # nonstandard extension used: 'variable': loop control variable declared in the for-loop is used outside
+ # the for-loop scope
+ /w14296 # 'operator': expression is always 'boolean_value'
+ /w14311 # 'variable': pointer truncation from 'type1' to 'type2'
+ /w14545 # expression before comma evaluates to a function which is missing an argument list
+ /w14546 # function call before comma missing argument list
+ /w14547 # 'operator': operator before comma has no effect; expected operator with side-effect
+ /w14549 # 'operator': operator before comma has no effect; did you intend 'operator'?
+ /w14555 # expression has no effect; expected expression with side- effect
+ /w14619 # pragma warning: there is no warning number 'number'
+ /w14640 # Enable warning on thread un-safe static member initialization
+ /w14826 # Conversion from 'type1' to 'type_2' is sign-extended. This may cause unexpected runtime behavior.
+ /w14905 # wide string literal cast to 'LPSTR'
+ /w14906 # string literal cast to 'LPWSTR'
+ /w14928 # illegal copy-initialization; more than one user-defined conversion has been implicitly applied
+ /permissive- # standards conformance mode for MSVC compiler.
+ )
+ endif()
+
+ if("${CLANG_WARNINGS}" STREQUAL "")
+ set(CLANG_WARNINGS
+ -Wall
+ -Wextra # reasonable and standard
+ -Wextra-semi # Warn about semicolon after in-class function definition.
+ -Wshadow # warn the user if a variable declaration shadows one from a parent context
+ -Wnon-virtual-dtor # warn the user if a class with virtual functions has a non-virtual destructor. This helps
+ # catch hard to track down memory errors
+ -Wold-style-cast # warn for c-style casts
+ -Wcast-align # warn for potential performance problem casts
+ -Wunused # warn on anything being unused
+ -Woverloaded-virtual # warn if you overload (not override) a virtual function
+ -Wpedantic # warn if non-standard C++ is used
+ -Wconversion # warn on type conversions that may lose data
+ -Wsign-conversion # warn on sign conversions
+ -Wnull-dereference # warn if a null dereference is detected
+ -Wdouble-promotion # warn if float is implicit promoted to double
+ -Wformat=2 # warn on security issues around functions that format output (ie printf)
+ -Wimplicit-fallthrough # warn on statements that fallthrough without an explicit annotation
+ )
+ endif()
+
+ if("${GCC_WARNINGS}" STREQUAL "")
+ set(GCC_WARNINGS
+ ${CLANG_WARNINGS}
+ -Wmisleading-indentation # warn if indentation implies blocks where blocks do not exist
+ -Wduplicated-cond # warn if if / else chain has duplicated conditions
+ -Wduplicated-branches # warn if if / else branches have duplicated code
+ -Wlogical-op # warn about logical operations being used where bitwise were probably wanted
+ -Wuseless-cast # warn if you perform a cast to the same type
+ )
+ endif()
+
+
+ if(WARNINGS_AS_ERRORS)
+ message(TRACE "Warnings are treated as errors")
+ list(APPEND CLANG_WARNINGS -Werror)
+ list(APPEND GCC_WARNINGS -Werror)
+ list(APPEND MSVC_WARNINGS /WX)
+ endif()
+
+ if(MSVC)
+ set(PROJECT_WARNINGS_CXX ${MSVC_WARNINGS})
+ elseif(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
+ set(PROJECT_WARNINGS_CXX ${CLANG_WARNINGS})
+ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+ set(PROJECT_WARNINGS_CXX ${GCC_WARNINGS})
+ else()
+ message(AUTHOR_WARNING "No compiler warnings set for CXX compiler: '${CMAKE_CXX_COMPILER_ID}'")
+ # TODO support Intel compiler
+ endif()
+
+ # Add C warnings
+ set(PROJECT_WARNINGS_C "${PROJECT_WARNINGS_CXX}")
+ list(
+ REMOVE_ITEM
+ PROJECT_WARNINGS_C
+ -Wnon-virtual-dtor
+ -Wold-style-cast
+ -Woverloaded-virtual
+ -Wuseless-cast
+ -Wextra-semi
+ )
+
+ target_compile_options(
+ ${_project_name}
+ INTERFACE # C++ warnings
+ $<$<COMPILE_LANGUAGE:CXX>:${PROJECT_WARNINGS_CXX}>
+ # C warnings
+ $<$<COMPILE_LANGUAGE:C>:${PROJECT_WARNINGS_C}>
+ )
+
+ # If we are using the compiler as a linker driver pass the warnings to it
+ # (most useful when using LTO or warnings as errors)
+ if(CMAKE_CXX_LINK_EXECUTABLE MATCHES "^<CMAKE_CXX_COMPILER>")
+ _set_project_warnings_add_target_link_option(
+ ${_project_name} "$<$<COMPILE_LANGUAGE:CXX>:${PROJECT_WARNINGS_CXX}>"
+ )
+ endif()
+
+ if(CMAKE_C_LINK_EXECUTABLE MATCHES "^<CMAKE_C_COMPILER>")
+ _set_project_warnings_add_target_link_option(
+ ${_project_name} "$<$<COMPILE_LANGUAGE:C>:${PROJECT_WARNINGS_C}>"
+ )
+ endif()
+
+ endfunction()
diff --git a/launcher/BaseInstance.h b/launcher/BaseInstance.h
index 83a8064f..f6b5a7a5 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 ca0e4502..7bfc51e3 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/CMakeLists.txt b/launcher/CMakeLists.txt
index 312288a1..9bb46572 100644
--- a/launcher/CMakeLists.txt
+++ b/launcher/CMakeLists.txt
@@ -1090,8 +1090,15 @@ if(WIN32)
set(LAUNCHER_RCS ${CMAKE_CURRENT_BINARY_DIR}/../${Launcher_Branding_WindowsRC})
endif()
+include(CompilerWarnings)
+
# Add executable
add_library(Launcher_logic STATIC ${LOGIC_SOURCES} ${LAUNCHER_SOURCES} ${LAUNCHER_UI} ${LAUNCHER_RESOURCES})
+set_project_warnings(Launcher_logic
+ "${WARNINGS_AS_ERRORS}"
+ "${Launcher_MSVC_WARNINGS}"
+ "${Launcher_CLANG_WARNINGS}"
+ "${Launcher_GCC_WARNINGS}")
target_include_directories(Launcher_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(Launcher_logic
systeminfo
@@ -1170,6 +1177,12 @@ install(TARGETS ${Launcher_Name}
if(WIN32)
add_library(filelink_logic STATIC ${LINKEXE_SOURCES})
+ set_project_warnings(filelink_logic
+ "${WARNINGS_AS_ERRORS}"
+ "${Launcher_MSVC_WARNINGS}"
+ "${Launcher_CLANG_WARNINGS}"
+ "${Launcher_GCC_WARNINGS}")
+
target_include_directories(filelink_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(filelink_logic
systeminfo
diff --git a/launcher/ProblemProvider.h b/launcher/ProblemProvider.h
index cd4745fa..d7d4c4e5 100644
--- a/launcher/ProblemProvider.h
+++ b/launcher/ProblemProvider.h
@@ -1,5 +1,8 @@
#pragma once
+#include <QList>
+#include <QString>
+
enum class ProblemSeverity
{
None,
@@ -16,7 +19,7 @@ struct PatchProblem
class ProblemProvider
{
public:
- virtual ~ProblemProvider() {};
+ virtual ~ProblemProvider() {}
virtual const QList<PatchProblem> getProblems() const = 0;
virtual ProblemSeverity getProblemSeverity() const = 0;
};
diff --git a/launcher/Usable.h b/launcher/Usable.h
index a3e880f3..f5818cbb 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/java/JavaVersion.h b/launcher/java/JavaVersion.h
index 9bbf0642..6b92d401 100644
--- a/launcher/java/JavaVersion.h
+++ b/launcher/java/JavaVersion.h
@@ -14,7 +14,7 @@ class JavaVersion
{
friend class JavaVersionTest;
public:
- JavaVersion() {};
+ JavaVersion() {}
JavaVersion(const QString & rhs);
JavaVersion & operator=(const QString & rhs);
diff --git a/launcher/minecraft/Component.h b/launcher/minecraft/Component.h
index ef7c9947..e7419c41 100644
--- a/launcher/minecraft/Component.h
+++ b/launcher/minecraft/Component.h
@@ -27,7 +27,8 @@ public:
Component(PackProfile * parent, std::shared_ptr<Meta::Version> version);
Component(PackProfile * parent, const QString & uid, std::shared_ptr<VersionFile> file);
- virtual ~Component(){};
+ virtual ~Component(){}
+
void applyTo(LaunchProfile *profile);
bool isEnabled();
diff --git a/launcher/minecraft/LaunchProfile.h b/launcher/minecraft/LaunchProfile.h
index 49c1217d..79e68824 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 13e27e15..784374c8 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<MojangLibraryDownloadInfo> Ptr;
diff --git a/launcher/minecraft/Rule.h b/launcher/minecraft/Rule.h
index 846e8e42..70fd70b6 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 eb1d7c4f..016679dd 100644
--- a/launcher/minecraft/mod/ResourceFolderModel.h
+++ b/launcher/minecraft/mod/ResourceFolderModel.h
@@ -49,8 +49,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.
@@ -78,7 +78,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); }
@@ -100,7 +100,7 @@ class ResourceFolderModel : public QAbstractListModel {
QStringList columnNames(bool translated = true) const { return translated ? m_column_names_translated : m_column_names; };
[[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;
@@ -163,7 +163,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.
*
@@ -225,15 +225,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<T*>(m_resources[index].get()); \
} \
- [[nodiscard]] T* at(size_t index) \
+ [[nodiscard]] T* at(int index) \
{ \
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()); \
} \
diff --git a/launcher/modplatform/ModIndex.h b/launcher/modplatform/ModIndex.h
index 3b0a03a1..b7670051 100644
--- a/launcher/modplatform/ModIndex.h
+++ b/launcher/modplatform/ModIndex.h
@@ -113,7 +113,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 d3277761..a8f300b4 100644
--- a/launcher/modplatform/ResourceAPI.h
+++ b/launcher/modplatform/ResourceAPI.h
@@ -128,28 +128,28 @@ 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, std::shared_ptr<QByteArray> response) const
{
- qWarning() << "TODO";
+ qWarning() << "TODO: ResourceAPI::getProject";
return nullptr;
}
[[nodiscard]] virtual Task::Ptr getProjects(QStringList addonIds, std::shared_ptr<QByteArray> response) 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 2e861732..0f11c52f 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 0dcb5668..036a8dd9 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 ab9322c2..c22eaf9f 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<NetAction>;
@@ -71,7 +71,7 @@ class NetAction : public Task {
i++;
}
- };
+ }
public slots:
void startAction(shared_qobject_ptr<QNetworkAccessManager> network)
@@ -81,7 +81,7 @@ class NetAction : public Task {
}
protected:
- void executeTask() override{};
+ void executeTask() override{}
public:
shared_qobject_ptr<QNetworkAccessManager> m_network;
diff --git a/launcher/net/Validator.h b/launcher/net/Validator.h
index 6b3d4635..c8ce7922 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 192782d7..1457d3e5 100644
--- a/launcher/pathmatcher/IPathMatcher.h
+++ b/launcher/pathmatcher/IPathMatcher.h
@@ -8,6 +8,6 @@ public:
typedef std::shared_ptr<IPathMatcher> 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 825d488c..6da651ef 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 &regexp)
{
m_regexp.setPattern(regexp);
diff --git a/launcher/tasks/ConcurrentTask.h b/launcher/tasks/ConcurrentTask.h
index 6325fc9e..481ebf85 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<unsigned int>(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 6d8bbbb4..d3bcc84f 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 23e55c51..6054b4b6 100644
--- a/launcher/translations/TranslationsModel.cpp
+++ b/launcher/translations/TranslationsModel.cpp
@@ -274,7 +274,6 @@ void readIndex(const QString & path, QMap<QString, Language>& languages)
return;
}
- int index = 1;
try
{
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");
languages.insert(lang.key, lang);
- index++;
}
}
catch (Json::JsonException & e)
diff --git a/tests/DummyResourceAPI.h b/tests/DummyResourceAPI.h
index 0cc90958..35de9515 100644
--- a/tests/DummyResourceAPI.h
+++ b/tests/DummyResourceAPI.h
@@ -32,7 +32,7 @@ class DummyResourceAPI : public 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
{
diff --git a/tests/FileSystem_test.cpp b/tests/FileSystem_test.cpp
index ec1f0bcf..49397e07 100644
--- a/tests/FileSystem_test.cpp
+++ b/tests/FileSystem_test.cpp
@@ -91,10 +91,10 @@ class LinkTask : public Task {
emitSucceeded();
}
- };
+ }
FS::create_link *m_lnk;
- bool m_useHard = false;
+ [[maybe_unused]] bool m_useHard = false;
bool m_linkRecursive = true;
};
@@ -346,7 +346,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 +640,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 82503d81..ccaa3610 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<char>(idis(eng)));
}
// initialize fibonacci
diff --git a/tests/ResourceModel_test.cpp b/tests/ResourceModel_test.cpp
index c0d9cd95..ecaea524 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 dabe5da2..04f2abcc 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 {