From cd22010288e66842bec876eea322234276a36a7a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 19 Jun 2025 14:37:35 +0000 Subject: [PATCH] Apply code formatting and fix style issues Co-authored-by: droidmonkey <2809491+droidmonkey@users.noreply.github.com> --- src/format/BitwardenReader.cpp | 11 ++++++----- tests/TestImports.cpp | 17 +++++++++-------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/format/BitwardenReader.cpp b/src/format/BitwardenReader.cpp index 8b5685077..17f5b5cbd 100644 --- a/src/format/BitwardenReader.cpp +++ b/src/format/BitwardenReader.cpp @@ -216,7 +216,8 @@ namespace * For example, "Socials/Forums" creates a "Socials" group with a "Forums" child group. * Returns the deepest (leaf) group in the hierarchy. */ - Group* createNestedFolderHierarchy(const QString& folderPath, Group* rootGroup, QMap& createdGroups) + Group* + createNestedFolderHierarchy(const QString& folderPath, Group* rootGroup, QMap& createdGroups) { if (folderPath.isEmpty()) { return rootGroup; @@ -239,7 +240,7 @@ namespace // Create each level of the hierarchy for (int i = 0; i < pathParts.size(); ++i) { const QString& partName = pathParts[i]; - + // Build the current path (e.g., "Socials", then "Socials/Forums") if (currentPath.isEmpty()) { currentPath = partName; @@ -273,7 +274,7 @@ namespace newGroup->setUuid(QUuid::createUuid()); newGroup->setName(partName); newGroup->setParent(currentParent); - + createdGroups.insert(currentPath, newGroup); currentParent = newGroup; } @@ -302,10 +303,10 @@ namespace for (const auto& folder : vault.value(folderField).toArray()) { const QString folderName = folder.toObject().value("name").toString(); const QString folderId = folder.toObject().value("id").toString(); - + // Create the nested folder hierarchy Group* targetGroup = createNestedFolderHierarchy(folderName, db->rootGroup(), createdGroups); - + // Map the folder ID to the target group folderMap.insert(folderId, targetGroup); } diff --git a/tests/TestImports.cpp b/tests/TestImports.cpp index 38c15a29c..ce26d628a 100644 --- a/tests/TestImports.cpp +++ b/tests/TestImports.cpp @@ -319,7 +319,8 @@ void TestImports::testBitwardenPasskey() void TestImports::testBitwardenNestedFolders() { - auto bitwardenPath = QStringLiteral("%1/%2").arg(KEEPASSX_TEST_DATA_DIR, QStringLiteral("/bitwarden_nested_export.json")); + auto bitwardenPath = + QStringLiteral("%1/%2").arg(KEEPASSX_TEST_DATA_DIR, QStringLiteral("/bitwarden_nested_export.json")); BitwardenReader reader; auto db = reader.convert(bitwardenPath); @@ -331,36 +332,36 @@ void TestImports::testBitwardenNestedFolders() QVERIFY(entry); QCOMPARE(entry->title(), QStringLiteral("Reddit Account")); QCOMPARE(entry->username(), QStringLiteral("myuser")); - + // Test deeper nesting: "Work/Projects/Client A" entry = db->rootGroup()->findEntryByPath("/Work/Projects/Client A/Client Portal"); QVERIFY(entry); QCOMPARE(entry->title(), QStringLiteral("Client Portal")); QCOMPARE(entry->username(), QStringLiteral("clientuser")); - + // Test simple folder (no nesting): "Personal" entry = db->rootGroup()->findEntryByPath("/Personal/Personal Email"); QVERIFY(entry); QCOMPARE(entry->title(), QStringLiteral("Personal Email")); QCOMPARE(entry->username(), QStringLiteral("personal@email.com")); - + // Verify the folder hierarchy exists auto socialsGroup = db->rootGroup()->findGroupByPath("/Socials"); QVERIFY(socialsGroup); QCOMPARE(socialsGroup->name(), QStringLiteral("Socials")); - + auto forumsGroup = socialsGroup->findGroupByPath("Forums"); QVERIFY(forumsGroup); QCOMPARE(forumsGroup->name(), QStringLiteral("Forums")); - + auto workGroup = db->rootGroup()->findGroupByPath("/Work"); QVERIFY(workGroup); QCOMPARE(workGroup->name(), QStringLiteral("Work")); - + auto projectsGroup = workGroup->findGroupByPath("Projects"); QVERIFY(projectsGroup); QCOMPARE(projectsGroup->name(), QStringLiteral("Projects")); - + auto clientAGroup = projectsGroup->findGroupByPath("Client A"); QVERIFY(clientAGroup); QCOMPARE(clientAGroup->name(), QStringLiteral("Client A"));