]> Nutra Git (v2) - nutratech/gui.git/commitdiff
lint fixes
authorShane Jaroch <chown_tee@proton.me>
Sat, 24 Jan 2026 07:03:59 +0000 (02:03 -0500)
committerShane Jaroch <chown_tee@proton.me>
Sat, 24 Jan 2026 07:07:29 +0000 (02:07 -0500)
CMakeLists.txt
Makefile
src/db/reciperepository.cpp
src/widgets/recipewidget.cpp
tests/test_databasemanager.cpp

index 4398ff3b0865657fa3d1816e88ceecb4f7d98a24..08ba242520f84e2c05055529ad3096c3332c1e14 100644 (file)
@@ -96,4 +96,5 @@ if(LINUXDEPLOY)
         COMMENT "Generating AppImage..."
         VERBATIM
     )
+    add_dependencies(appimage nutra)
 endif()
index 07dfbe7a168a3c5deda404dec6f08818f6a26358..dc5d837b1c7934aca26f76794fffc700ad542fa0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -66,7 +66,7 @@ lint: config
        cppcheck --enable=warning,performance,portability \
                --language=c++ --std=c++17 \
                --suppress=missingIncludeSystem \
-               -Dslots= -Dsignals= -Demit= \
+               -Dslots= -Dsignals= -Demit= -DQT_VERSION_CHECK\(major,minor,patch\)=0 \
                --quiet --error-exitcode=1 \
                $(SRC_DIRS) include tests
        @if [ ! -f $(BUILD_DIR)/compile_commands.json ]; then \
index 09d51a058f59c1e48903609d878900ac7e57de34..bfc715f123efa0bd10324726195d8983436e5cf6 100644 (file)
@@ -8,7 +8,7 @@
 
 #include "db/databasemanager.h"
 
-RecipeRepository::RecipeRepository() {}
+RecipeRepository::RecipeRepository() = default;
 
 int RecipeRepository::createRecipe(const QString& name, const QString& instructions) {
     QSqlDatabase db = DatabaseManager::instance().userDatabase();
@@ -21,10 +21,9 @@ int RecipeRepository::createRecipe(const QString& name, const QString& instructi
 
     if (query.exec()) {
         return query.lastInsertId().toInt();
-    } else {
-        qCritical() << "Failed to create recipe:" << query.lastError().text();
-        return -1;
     }
+    qCritical() << "Failed to create recipe:" << query.lastError().text();
+    return -1;
 }
 
 bool RecipeRepository::updateRecipe(int id, const QString& name, const QString& instructions) {
@@ -37,7 +36,11 @@ bool RecipeRepository::updateRecipe(int id, const QString& name, const QString&
     query.addBindValue(instructions);
     query.addBindValue(id);
 
-    return query.exec();
+    if (query.exec()) {
+        return true;
+    }
+    qCritical() << "Failed to update recipe:" << query.lastError().text();
+    return false;
 }
 
 bool RecipeRepository::deleteRecipe(int id) {
index 6784edfedb2e489494cee3799e30f17e623acc36..f97e6e17a744264db93677d5c461eb14c02a1f59 100644 (file)
@@ -156,7 +156,7 @@ void RecipeWidget::loadRecipeDetails(int recipeId) {
     // Load ingredients
     ingredientsTable->setRowCount(0);
     auto ingredients = repository.getIngredients(recipeId);
-    ingredientsTable->setRowCount(ingredients.size());
+    ingredientsTable->setRowCount(static_cast<int>(ingredients.size()));
     for (int i = 0; i < ingredients.size(); ++i) {
         const auto& ing = ingredients[i];
         ingredientsTable->setItem(i, 0, new QTableWidgetItem(QString::number(ing.foodId)));
@@ -277,7 +277,9 @@ void RecipeWidget::onRemoveIngredient() {
     int row = ingredientsTable->currentRow();
     if (row < 0) return;
 
-    int foodId = ingredientsTable->item(row, 0)->text().toInt();
+    auto* item = ingredientsTable->item(row, 0);
+    if (item == nullptr) return;
+    int foodId = item->text().toInt();
 
     if (repository.removeIngredient(currentRecipeId, foodId)) {
         ingredientsTable->removeRow(row);
index a4b7538f27890dcc9f56b172e28312d632e542c3..a57712e11348fbc9c2c4768418c16c915662492a 100644 (file)
@@ -25,6 +25,7 @@ void TestDatabaseManager::testUserDatabaseInit() {
     q.exec("CREATE TABLE log_food (id int)");
 
     db.close();
+    db = QSqlDatabase();  // Clear the object so it doesn't hold reference
 
     auto info = DatabaseManager::instance().getDatabaseInfo(dbPath);
     QCOMPARE(info.type, QString("User"));
@@ -44,6 +45,7 @@ void TestDatabaseManager::testInvalidDatabase() {
     QVERIFY(db.open());
     // Empty DB
     db.close();
+    db = QSqlDatabase();  // Clear the object so it doesn't hold reference
 
     auto info = DatabaseManager::instance().getDatabaseInfo(dbPath);
     QVERIFY(info.isValid == false);