diff --git a/src/cli/Clip.cpp b/src/cli/Clip.cpp index 2b1dfdc1b..482ad8a13 100644 --- a/src/cli/Clip.cpp +++ b/src/cli/Clip.cpp @@ -46,7 +46,7 @@ Clip::Clip() int Clip::executeWithDatabase(QSharedPointer database, QSharedPointer parser) { const QStringList args = parser->positionalArguments(); - QString entryPath = args.at(1); + const QString& entryPath = args.at(1); QString timeout; if (args.size() == 3) { timeout = args.at(2); diff --git a/src/cli/Import.cpp b/src/cli/Import.cpp index ff6fb266b..0907f00ab 100644 --- a/src/cli/Import.cpp +++ b/src/cli/Import.cpp @@ -60,8 +60,8 @@ int Import::execute(const QStringList& arguments) TextStream errorTextStream(Utils::STDERR, QIODevice::WriteOnly); const QStringList args = parser->positionalArguments(); - const QString xmlExportPath = args.at(0); - const QString dbPath = args.at(1); + const QString& xmlExportPath = args.at(0); + const QString& dbPath = args.at(1); if (QFileInfo::exists(dbPath)) { errorTextStream << QObject::tr("File %1 already exists.").arg(dbPath) << endl; diff --git a/src/cli/List.cpp b/src/cli/List.cpp index 62e67aed8..d068cdf53 100644 --- a/src/cli/List.cpp +++ b/src/cli/List.cpp @@ -60,7 +60,7 @@ int List::executeWithDatabase(QSharedPointer database, QSharedPointer< return EXIT_SUCCESS; } - QString groupPath = args.at(1); + const QString& groupPath = args.at(1); Group* group = database->rootGroup()->findGroupByPath(groupPath); if (!group) { errorTextStream << QObject::tr("Cannot find group %1.").arg(groupPath) << endl; diff --git a/src/cli/Locate.cpp b/src/cli/Locate.cpp index eeb37d803..9b574852d 100644 --- a/src/cli/Locate.cpp +++ b/src/cli/Locate.cpp @@ -40,7 +40,7 @@ int Locate::executeWithDatabase(QSharedPointer database, QSharedPointe { const QStringList args = parser->positionalArguments(); - QString searchTerm = args.at(1); + const QString& searchTerm = args.at(1); TextStream outputTextStream(Utils::STDOUT, QIODevice::WriteOnly); TextStream errorTextStream(Utils::STDERR, QIODevice::WriteOnly); diff --git a/src/core/IconDownloader.cpp b/src/core/IconDownloader.cpp index 36047ce2a..fe346becd 100644 --- a/src/core/IconDownloader.cpp +++ b/src/core/IconDownloader.cpp @@ -90,7 +90,7 @@ void IconDownloader::setUrl(const QString& entryUrl) // searching for a match with the returned address(es). bool hostIsIp = false; QList hostAddressess = QHostInfo::fromName(fullyQualifiedDomain).addresses(); - for (auto addr : hostAddressess) { + for (const auto& addr : hostAddressess) { if (addr.toString() == fullyQualifiedDomain) { hostIsIp = true; } diff --git a/src/format/OpVaultReader.cpp b/src/format/OpVaultReader.cpp index 49d62b624..cc72653fd 100644 --- a/src/format/OpVaultReader.cpp +++ b/src/format/OpVaultReader.cpp @@ -341,6 +341,8 @@ OpVaultReader::decodeB64CompositeKeys(const QString& b64, const QByteArray& encK result->errorStr = tr("Unable to decode masterKey: %1").arg(keyKey01.errorString()); return result; } + delete result; + const QByteArray keyKey = keyKey01.getClearText(); return decodeCompositeKeys(keyKey); diff --git a/tests/TestCsvParser.cpp b/tests/TestCsvParser.cpp index 46d254098..f31e30414 100644 --- a/tests/TestCsvParser.cpp +++ b/tests/TestCsvParser.cpp @@ -111,7 +111,7 @@ void TestCsvParser::testEmptySimple() out << ""; QVERIFY(parser->parse(file.data())); t = parser->getCsvTable(); - QVERIFY(t.size() == 0); + QVERIFY(t.isEmpty()); } void TestCsvParser::testEmptyQuoted() @@ -120,7 +120,7 @@ void TestCsvParser::testEmptyQuoted() out << "\"\""; QVERIFY(parser->parse(file.data())); t = parser->getCsvTable(); - QVERIFY(t.size() == 0); + QVERIFY(t.isEmpty()); } void TestCsvParser::testEmptyNewline() @@ -129,14 +129,14 @@ void TestCsvParser::testEmptyNewline() out << "\"\n\""; QVERIFY(parser->parse(file.data())); t = parser->getCsvTable(); - QVERIFY(t.size() == 0); + QVERIFY(t.isEmpty()); } void TestCsvParser::testEmptyFile() { QVERIFY(parser->parse(file.data())); t = parser->getCsvTable(); - QVERIFY(t.size() == 0); + QVERIFY(t.isEmpty()); } void TestCsvParser::testNewline() @@ -281,7 +281,7 @@ void TestCsvParser::testEmptyReparsing() parser->parse(nullptr); QVERIFY(parser->reparse()); t = parser->getCsvTable(); - QVERIFY(t.size() == 0); + QVERIFY(t.isEmpty()); } void TestCsvParser::testReparsing() diff --git a/tests/TestEntryModel.cpp b/tests/TestEntryModel.cpp index e32de2466..670e43aab 100644 --- a/tests/TestEntryModel.cpp +++ b/tests/TestEntryModel.cpp @@ -296,7 +296,7 @@ void TestEntryModel::testProxyModel() QSignalSpy spyColumnRemove(modelProxy, SIGNAL(columnsAboutToBeRemoved(QModelIndex, int, int))); modelProxy->hideColumn(0, true); QCOMPARE(modelProxy->columnCount(), 12); - QVERIFY(spyColumnRemove.size() >= 1); + QVERIFY(!spyColumnRemove.isEmpty()); int oldSpyColumnRemoveSize = spyColumnRemove.size(); modelProxy->hideColumn(0, true); @@ -318,7 +318,7 @@ void TestEntryModel::testProxyModel() QSignalSpy spyColumnInsert(modelProxy, SIGNAL(columnsAboutToBeInserted(QModelIndex, int, int))); modelProxy->hideColumn(0, false); QCOMPARE(modelProxy->columnCount(), 13); - QVERIFY(spyColumnInsert.size() >= 1); + QVERIFY(!spyColumnInsert.isEmpty()); int oldSpyColumnInsertSize = spyColumnInsert.size(); modelProxy->hideColumn(0, false); diff --git a/tests/TestGroup.cpp b/tests/TestGroup.cpp index ae9c59894..9fc39dc64 100644 --- a/tests/TestGroup.cpp +++ b/tests/TestGroup.cpp @@ -1070,7 +1070,7 @@ void TestGroup::testHierarchy() QVERIFY(hierarchy.contains("group3")); hierarchy = group3->hierarchy(0); - QVERIFY(hierarchy.size() == 0); + QVERIFY(hierarchy.isEmpty()); hierarchy = group3->hierarchy(1); QVERIFY(hierarchy.size() == 1);