Commit 94cf64af authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix some cppcheck warnings

parent 2c790067
Pipeline #84821 failed with stage
in 1 minute and 5 seconds
......@@ -39,8 +39,8 @@ class ActionStateManagerTest : public QObject
public:
ActionStateManagerTest()
: rootCollection(Collection::root())
{
rootCollection = Collection::root();
const QString dummyMimeType(QStringLiteral("text/dummy"));
resourceCollectionOne.setId(1);
......
......@@ -364,10 +364,10 @@ void CollectionJobTest::testCreateDeleteFolder()
// fetch parent to compare inherited collection properties
Collection parentCol = Collection::root();
if (collection.parentCollection().isValid()) {
auto listJob = new CollectionFetchJob(collection.parentCollection(), CollectionFetchJob::Base, this);
AKVERIFYEXEC(listJob);
QCOMPARE(listJob->collections().count(), 1);
parentCol = listJob->collections().first();
auto newListJob = new CollectionFetchJob(collection.parentCollection(), CollectionFetchJob::Base, this);
AKVERIFYEXEC(newListJob);
QCOMPARE(newListJob->collections().count(), 1);
parentCol = newListJob->collections().first();
}
if (collection.contentMimeTypes().isEmpty()) {
......
......@@ -88,8 +88,8 @@ private Q_SLOTS:
AKVERIFYEXEC(fetch);
QCOMPARE(fetch->items().count(), 3);
const Item::List fetchedItems = fetch->items();
for (const Item &item : fetchedItems) {
QVERIFY(items.contains(item));
for (const Item &fetchedItem : fetchedItems) {
QVERIFY(items.contains(fetchedItem));
}
auto unlink = new UnlinkJob(col, items, this);
......
......@@ -20,7 +20,7 @@ class FakeIntervalCheck : public IntervalCheck
{
Q_OBJECT
public:
FakeIntervalCheck(ItemRetrievalManager &retrievalManager);
explicit FakeIntervalCheck(ItemRetrievalManager &retrievalManager);
void waitForInit();
protected:
......
......@@ -144,17 +144,17 @@ class SubscriptionDialogTest : public QObject
QModelIndex indexForCollection(const Collection &col) const
{
auto model = collectionView->model();
auto collectionViewModel = collectionView->model();
std::deque<QModelIndex> idxQueue;
idxQueue.push_back(QModelIndex{});
while (!idxQueue.empty()) {
const auto idx = idxQueue.front();
idxQueue.pop_front();
if (model->data(idx, EntityTreeModel::CollectionIdRole).value<qint64>() == col.id()) {
if (collectionViewModel->data(idx, EntityTreeModel::CollectionIdRole).value<qint64>() == col.id()) {
return idx;
}
for (int i = 0; i < model->rowCount(idx); ++i) {
idxQueue.push_back(model->index(i, 0, idx));
for (int i = 0; i < collectionViewModel->rowCount(idx); ++i) {
idxQueue.push_back(collectionViewModel->index(i, 0, idx));
}
}
return {};
......
......@@ -92,9 +92,9 @@ class TagEditWidgetTest : public QObject
bool checkSelectionIsEmpty() const
{
auto *const model = tagsView->model();
for (int i = 0; i < model->rowCount(); ++i) {
if (model->data(model->index(i, 0), Qt::CheckStateRole).value<Qt::CheckState>() != Qt::Unchecked) {
auto *const tagViewModel = tagsView->model();
for (int i = 0; i < tagViewModel->rowCount(); ++i) {
if (tagViewModel->data(tagViewModel->index(i, 0), Qt::CheckStateRole).value<Qt::CheckState>() != Qt::Unchecked) {
return false;
}
}
......
......@@ -557,7 +557,7 @@ Protocol::ChangeNotificationPtr ChangeRecorderJournalReader::loadCollectionNotif
collection.setSearchCollections(vb);
stream >> entityCnt;
QVector<Protocol::Ancestor> ancestors;
for (int i = 0; i < entityCnt; ++i) {
for (int j = 0; j < entityCnt; ++j) {
Protocol::Ancestor ancestor;
stream >> i64;
ancestor.setId(i64);
......
......@@ -267,15 +267,15 @@ void DefaultResourceJobPrivate::tryFetchResource()
// without updating the config file, in this case search for a resource
// of the same type and the default name
const AgentInstance::List resources = AgentManager::self()->instances();
for (const AgentInstance &resource : resources) {
if (resource.type().identifier() == mDefaultResourceType) {
if (resource.name() == mDefaultResourceOptions.value(QStringLiteral("Name")).toString()) {
for (const AgentInstance &resourceInstance : resources) {
if (resourceInstance.type().identifier() == mDefaultResourceType) {
if (resourceInstance.name() == mDefaultResourceOptions.value(QStringLiteral("Name")).toString()) {
// found a matching one...
setDefaultResourceId(mSettings, resource.identifier());
setDefaultResourceId(mSettings, resourceInstance.identifier());
mSettings->save();
mResourceWasPreexisting = true;
qCDebug(AKONADICORE_LOG) << "Found resource" << resource.identifier();
q->setResourceId(resource.identifier());
qCDebug(AKONADICORE_LOG) << "Found resource" << resourceInstance.identifier();
q->setResourceId(resourceInstance.identifier());
q->ResourceScanJob::doStart();
return;
}
......
......@@ -127,9 +127,9 @@ bool AgentFilterProxyModel::filterAcceptsRow(int row, const QModelIndex & /*sour
return false;
}
if (found && !d->excludeCapabilities.isEmpty()) {
const QStringList lst = index.data(AgentTypeModel::CapabilitiesRole).toStringList();
for (const QString &capability : lst) {
if (!d->excludeCapabilities.isEmpty()) {
const QStringList lstCapabilities = index.data(AgentTypeModel::CapabilitiesRole).toStringList();
for (const QString &capability : lstCapabilities) {
if (d->excludeCapabilities.contains(capability)) {
found = false;
break;
......
......@@ -99,8 +99,8 @@ QString ExternalPartStorage::resolveAbsolutePath(const QString &filename, bool *
}
return legacyPath;
} else {
QFileInfo finfo(path);
QDir().mkpath(finfo.path());
QFileInfo legacyFinfo(path);
QDir().mkpath(legacyFinfo.path());
// If neither legacy or new path exists, return the new path, so that
// new items are created in the correct location
return path;
......
......@@ -232,8 +232,8 @@ bool CollectionModifyHandler::parseStream()
return failureResponse("Unable to retrieve collection attribute");
}
const CollectionAttribute::List attrs = qb.result();
if (attrs.isEmpty()) {
const CollectionAttribute::List attrsList = qb.result();
if (attrsList.isEmpty()) {
CollectionAttribute newAttr;
newAttr.setCollectionId(collection.id());
newAttr.setType(iter.key());
......@@ -242,8 +242,8 @@ bool CollectionModifyHandler::parseStream()
return failureResponse("Unable to add collection attribute");
}
changes.append(iter.key());
} else if (attrs.size() == 1) {
CollectionAttribute currAttr = attrs.first();
} else if (attrsList.size() == 1) {
CollectionAttribute currAttr = attrsList.first();
if (currAttr.value() == iter.value()) {
continue;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment