]> git.ipfire.org Git - pakfire.git/commitdiff
linter: Keep stats about how many warnings/errors/etc.
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 26 Oct 2024 10:48:10 +0000 (10:48 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 26 Oct 2024 10:48:10 +0000 (10:48 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/linter.c

index 0e9cac5ec8abeba9b819f86db6c1f7d915009b1c..f380fff4e84aa748a23d1e6159a6b67b6a0ad13d 100644 (file)
@@ -71,6 +71,15 @@ struct pakfire_linter {
        // Results
        TAILQ_HEAD(results, pakfire_linter_result) results;
 
+       // Stats
+       struct pakfire_linter_stats {
+               unsigned int results;
+
+               // Count errors and warnings
+               unsigned int errors;
+               unsigned int warnings;
+       } stats;
+
        // Result Callback
        pakfire_linter_result_callback result_callback;
        void* result_data;
@@ -149,6 +158,22 @@ int pakfire_linter_result(struct pakfire_linter* linter, struct pakfire_file* fi
        // Store the result
        TAILQ_INSERT_TAIL(&linter->results, result, nodes);
 
+       // Update stats
+       linter->stats.results++;
+
+       switch (priority) {
+               case PAKFIRE_LINTER_WARNING:
+                       linter->stats.warnings++;
+                       break;
+
+               case PAKFIRE_LINTER_ERROR:
+                       linter->stats.errors++;
+                       break;
+
+               default:
+                       break;
+       }
+
        // Call the callback
        if (linter->result_callback) {
                r = linter->result_callback(linter->ctx, linter->archive, linter->pkg,