diff options
| author | Peter Eisenmann <p3732@getgoogleoff.me> | 2026-04-17 09:56:37 +0200 |
|---|---|---|
| committer | Peter Eisenmann <p3732@getgoogleoff.me> | 2026-04-17 09:56:37 +0200 |
| commit | 776b1988a363eec0c6f38ff09358f4e239f4678f (patch) | |
| tree | dc75ec5e96857c351b3437688fe7983a30686a87 | |
| parent | c9700ba6d2908054855c47f7bd99be276a5487b4 (diff) | |
Add HACKING.md for contributorswip/kabus/coding-style
| -rw-r--r-- | HACKING.md | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/HACKING.md b/HACKING.md new file mode 100644 index 000000000..44f4a1225 --- /dev/null +++ b/HACKING.md @@ -0,0 +1,52 @@ +## Build +See https://handbook.gnome.org/development/building.html + +## Coding Style +Basic code formatting can be done by running the formatting script `build-aux/run-uncrustify.sh`. +It is also run via a merge request CI pipeline to catch any oversights. + +Nautilus has a lot of legacy code that would not be written the same way today. +Some general guidelines for the current code style: + +* Use [automatic cleanups](https://docs.gtk.org/glib/auto-cleanup.html) when possible +* Declare variables where they are needed and assign them directly if possible +* Explicitly compare pointers with `NULL` (`if (variable != NULL)` instead of `if (variable)`) +* Place empty lines between between blocks of declarations, expressions and return statements +* Keep line lengths below 100, put a line break after `=` or between function parameters if needed +* Prefer early returns over nested if cases + +You can look at newer changes to see these guidelines in practice. +Example code block: + + g_autoptr (Type) autocleanup_variable = inline_initialization (); + + if (variable == NULL) + { + return early; + } + + g_autofree char *define_variables_where_used = + use_line_break_after_assignment_if_line_would_get_too_long (); + + function_call_separated_by_empty_line (); + expressions += function_calls (are_grouped); + + return statement_separated_by_another_empty_line; + + +## Commit Messages +See https://handbook.gnome.org/development/commit-messages.html + +## Unit Tests +Enable building unit tests from the `test/` directory by setting the respective +meson option (`-Dtests=all`). +You can then run them, e.g. with `meson test -C build`. +The tests are also run via a merge request CI pipeline to avoid regressions. + +## Build With Address Sanitizer +* Install `libasan` in the build environment +* Reconfigure meson to use sanitizer, e.g. with: + + `meson setup --reconfigure --prefix=$PREFIX build -Db_sanitize=address` +* The sanitizer will inform you about leaked data on exiting. + This is most useful in combination with unittests |
