aboutsummaryrefslogtreecommitdiffhomepage
path: root/gobject-linter.toml
diff options
context:
space:
mode:
authorTrung Lê <8@tle.id.au>2026-06-10 10:04:30 +1000
committerTrung Lê <8@tle.id.au>2026-06-10 10:04:30 +1000
commitf6009527636f8a8017d5b9192efe96a1d03d2028 (patch)
treee9d1a229cb32e08534f10cbf0ae489840add73ac /gobject-linter.toml
parent76ff689850c160e7eca27ee51852dcf17cc1938a (diff)
ci: adopt gobject-linter as a blocking static-analysis gate
Add gobject-linter (github.com/bilelmoussaoui/gobject-linter) to CI to catch GObject/GLib correctness and idiom issues. Config (gobject-linter.toml): - min_glib_version = 2.80 (libadwaita >= 1.8) - default_level = error: every enabled rule blocks CI - type_style ignored: the project deliberately uses plain C scalar types - untranslated_string ignored: app is not internationalized yet - use_auto_cleanup downgraded to warn: it mis-fires on floating GVariant references (consumed by g_variant_new_tuple/builders) and on objects kept alive past the function (the GlobalShortcuts GDBusProxy); converting those to g_autoptr would over-unref and crash, so it advises rather than blocks Workflow (.github/workflows/gobject-linter.yml): runs the official container image on push/PR, uploads SARIF to code scanning (non-fatal for fork PRs), and fails the build on any error-level finding. Code is brought to a green baseline by applying the auto-fixable findings: - strcmp -> g_strcmp0 (NULL-safe) - manual g_free/g_strdup -> g_set_str - manual source removal -> g_clear_handle_id / g_clear_object / g_clear_pointer - g_string_free(.., FALSE) -> g_string_free_and_steal - g_idle_add one-shot -> g_idle_add_once (id now stored and cleared in finalize, also closing a latent use-after-free if the window is finalized first) - include ordering and #pragma once The 37 remaining use_auto_cleanup findings are reported as warnings for incremental manual review.
Diffstat (limited to 'gobject-linter.toml')
-rw-r--r--gobject-linter.toml32
1 files changed, 32 insertions, 0 deletions
diff --git a/gobject-linter.toml b/gobject-linter.toml
new file mode 100644
index 0000000..5fe6bb6
--- /dev/null
+++ b/gobject-linter.toml
@@ -0,0 +1,32 @@
+# gobject-linter configuration
+# https://github.com/bilelmoussaoui/gobject-linter
+#
+# Run locally with: gobject-linter .
+# Auto-fix: gobject-linter . --fix
+#
+# CI runs this as a blocking gate (see .github/workflows/gobject-linter.yml):
+# every enabled rule is a hard error, so the build fails on any regression.
+
+# libadwaita >= 1.8 pulls in GLib >= 2.80; rules needing a newer GLib are skipped.
+min_glib_version = "2.80"
+
+# Treat every enabled, non-opt-in rule as an error so CI fails on new findings.
+default_level = "error"
+
+# This project deliberately uses the standard C scalar types (int/char/…) rather
+# than the GLib aliases (gint/gchar/…). The alias style is not enforced.
+[rules.type_style]
+level = "ignore"
+
+# The application is not yet internationalized (no gettext domain). Re-enable
+# once translation infrastructure is in place.
+[rules.untranslated_string]
+level = "ignore"
+
+# Advisory only: this rule mis-fires on floating GVariant references (consumed by
+# g_variant_new_tuple/builders) and on objects intentionally kept alive past the
+# function (e.g. the GlobalShortcuts GDBusProxy). Converting those to g_autoptr
+# would over-unref and crash, so it reports rather than blocks. Convert the safe
+# g_autofree/g_autoptr sites manually over time.
+[rules.use_auto_cleanup]
+level = "warn"