chore: fix some codeql warnings (#3840)

This commit is contained in:
Tayou 2025-06-06 14:19:27 +02:00 committed by GitHub
commit a17ea196c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 72 additions and 26 deletions

View file

@ -121,6 +121,7 @@ bool ModpackListModel::setData(const QModelIndex& index, const QVariant& value,
if (pos >= modpacks.size() || pos < 0 || !index.isValid())
return false;
Q_ASSERT(value.canConvert<Modrinth::Modpack>());
modpacks[pos] = value.value<Modrinth::Modpack>();
return true;
@ -137,7 +138,7 @@ void ModpackListModel::performPaginatedSearch()
ResourceAPI::ProjectInfoCallbacks callbacks;
callbacks.on_fail = [this](QString reason) { searchRequestFailed(reason); };
callbacks.on_succeed = [this](auto& doc, auto& pack) { searchRequestForOneSucceeded(doc); };
callbacks.on_succeed = [this](auto& doc, auto&) { searchRequestForOneSucceeded(doc); };
callbacks.on_abort = [this] {
qCritical() << "Search task aborted by an unknown reason!";
searchRequestFailed("Aborted");
@ -345,7 +346,7 @@ void ModpackListModel::searchRequestForOneSucceeded(QJsonDocument& doc)
endInsertRows();
}
void ModpackListModel::searchRequestFailed(QString reason)
void ModpackListModel::searchRequestFailed(QString)
{
auto failed_action = dynamic_cast<NetJob*>(jobPtr.get())->getFailedActions().at(0);
if (failed_action->replyStatusCode() == -1) {

View file

@ -150,7 +150,9 @@ void ModrinthPage::onSelectionChanged(QModelIndex curr, [[maybe_unused]] QModelI
return;
}
current = m_model->data(curr, Qt::UserRole).value<Modrinth::Modpack>();
QVariant raw = m_model->data(curr, Qt::UserRole);
Q_ASSERT(raw.canConvert<Modrinth::Modpack>());
current = raw.value<Modrinth::Modpack>();
auto name = current.name;
if (!current.extraInfoLoaded) {