repo: cover all Rust crates in check/format all
- Commit
417f8584d0047a97f11ac885e98983663ab96e54- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-01 18:59 UTC (4 days ago)
- Parents
78cf39a
The module-scoped cargo fmt steps in ./check and ./format only reached crates under a named Gradle module src/main/rust, so workspace crates with no Gradle module (scripts/, third_party/, library/tilecodec, library/jni-http, library/vision and communicate-dev/src/main/rust-mls) could drift unchecked, and a standalone crate outside the workspace had no path in at all. With the all keyword, both scripts now run cargo fmt --all for the whole workspace, and discover standalone crates (Cargo.toml files outside target/build/personal that are not workspace members, per cargo metadata) and check or format each in its own dir. Scoped module behaviour is unchanged, and AGENTS.md describes the all behaviour. Verified with bash -n on both scripts, standalone discovery returning zero crates on this checkout, a temporary standalone crate being discovered and formatted in-dir, and ./format --check astronomy reaching its cargo fmt step (its exit 1 is pre-existing Kotlin ktlint test-source violations, not Rust).
Diff
AGENTS.md
diff --git a/AGENTS.md b/AGENTS.mdindex 93e853a258..c42f2971ad 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -138,7 +138,7 @@ Findings fail the task. Only `notes/`, `backup/`, `library/ui/`, `games/voxels/` ./format --check <module> # ktlintCheck + cargo fmt --check only ./format all # every app + library module ```-Formatting (current state): Kotlin uses ktlint's standard rule set via the `org.jlleitschuh.gradle.ktlint` Gradle plugin (version pinned in `gradle/libs.versions.toml`; engine 1.5.0), applied by `common-conventions-app`/`common-conventions-library` so every app/library module has `ktlintFormat`/`ktlintCheck`. Style is the root `.editorconfig` (indent 4, max line 120, LF, final newline), which ktlint reads natively. Generated sources and `*.kts` build scripts are excluded (scope is `src/**`). `./check` enforces formatting per module (`:ktlintCheck` beside detekt/lint; `cargo fmt --check` blocking for Rust — style in the root `rustfmt.toml`, max_width 100; the rustfmt component is required: `rustup component add rustfmt`). Rule exceptions: no ktlint rule is disabled. The one configured knob is `ktlint_function_naming_ignore_when_annotated_with = Composable` in `.editorconfig` — composables are PascalCase by repo convention (one public `@Composable` per file, named as the file), so the rule must not demand camelCase for them. Roll out module by module: `./format <module>` plus manual fixes for non-autocorrectable findings, then `./check <module>` green.+Formatting (current state): Kotlin uses ktlint's standard rule set via the `org.jlleitschuh.gradle.ktlint` Gradle plugin (version pinned in `gradle/libs.versions.toml`; engine 1.5.0), applied by `common-conventions-app`/`common-conventions-library` so every app/library module has `ktlintFormat`/`ktlintCheck`. Style is the root `.editorconfig` (indent 4, max line 120, LF, final newline), which ktlint reads natively. Generated sources and `*.kts` build scripts are excluded (scope is `src/**`). `./check` enforces formatting per module (`:ktlintCheck` beside detekt/lint; `cargo fmt --check` blocking for Rust — style in the root `rustfmt.toml`, max_width 100; the rustfmt component is required: `rustup component add rustfmt`). `./check all` and `./format all` additionally run the workspace-wide `cargo fmt --all`, covering workspace crates with no Gradle module (`scripts/`, `third_party/`, `library/tilecodec`, `library/jni-http`, `library/vision`, `communicate-dev/src/main/rust-mls`), and check/format any standalone crate that is not a workspace member in its own dir. Rule exceptions: no ktlint rule is disabled. The one configured knob is `ktlint_function_naming_ignore_when_annotated_with = Composable` in `.editorconfig` — composables are PascalCase by repo convention (one public `@Composable` per file, named as the file), so the rule must not demand camelCase for them. Roll out module by module: `./format <module>` plus manual fixes for non-autocorrectable findings, then `./check <module>` green. ### On-device file map (per-module `AGENTS.md` carries concrete names) - Room (`RoomRepository`, `DB_NAME` in `data/`): `/data/data/<pkg>/databases/<DB_NAME>` (+ `-wal`/`-shm` sidecars). SQLCipher-encrypted. `getDatabasePath`/`deleteDatabase`/`LEGACY_*` names are the same dir.
check
diff --git a/check b/checkindex 5bf136e880..0031321e1b 100755--- a/check+++ b/check@@ -191,8 +191,40 @@ done # --- cargo fmt (blocking) --- # `cargo fmt --check` fails this script on drift. Fix with # `./format <module>` (or `cargo fmt -p <crate>`); style is rustfmt.toml.+# With `all`, the workspace-wide `--all` run also covers workspace crates+# with no Gradle module (scripts/, third_party/, library/tilecodec,+# library/jni-http, library/vision, communicate-dev/src/main/rust-mls),+# and any standalone crate that is not a workspace member (a Cargo.toml+# outside target/build/personal and outside the workspace member set)+# is checked in its own dir.+standalone_crate_dirs() {+ python3 - "$ROOT" "$CARGO_BIN" <<'PYEOF'+import json, os, pathlib, subprocess, sys+root = pathlib.Path(sys.argv[1]); cargo = sys.argv[2]+try:+ meta = json.loads(subprocess.check_output([cargo, "metadata", "--format-version", "1", "--no-deps"], cwd=root, text=True, stderr=subprocess.DEVNULL))+ members = {str(pathlib.Path(p["manifest_path"]).parent) for p in meta["packages"]}+except Exception:+ members = set()+skip = {"target", "build", ".git", ".gradle", "personal"}+for dirpath, dirnames, filenames in os.walk(root):+ dirnames[:] = sorted(d for d in dirnames if d not in skip)+ if "Cargo.toml" in filenames and dirpath != str(root) and dirpath not in members:+ print(dirpath)+PYEOF+} FMT_RC=0-if [[ ${#ROOT_CRATES[@]} -gt 0 ]]; then+if [[ $ALL_EXP -eq 1 ]]; then+ echo ""+ echo "Running: cargo fmt --check --all"+ FMT_OUT="$(cd "$ROOT" && "$CARGO_BIN" fmt --check --all 2>&1)" || FMT_RC=$?+ if [[ $FMT_RC -ne 0 ]]; then+ FMT_COUNT="$(echo "$FMT_OUT" | grep -c '^Diff in' || true)"+ echo "Error: rustfmt drift: $FMT_COUNT hunks in workspace (run ./format all to fix)."+ else+ echo "rustfmt: clean (workspace)."+ fi+elif [[ ${#ROOT_CRATES[@]} -gt 0 ]]; then echo "" FMT_ARGS=() for c in "${ROOT_CRATES[@]}"; do FMT_ARGS+=(-p "$c"); done@@ -216,6 +248,22 @@ for rdir in ${STANDALONE_DIRS[@]:-}; do echo "rustfmt: clean ($rdir)." fi done+if [[ $ALL_EXP -eq 1 ]]; then+ while IFS= read -r rdir; do+ [[ -z "$rdir" ]] && continue+ dup=0; for m in ${STANDALONE_DIRS[@]:-}; do [[ "$m" == "$rdir" ]] && dup=1; done+ [[ $dup -eq 1 ]] && continue+ echo ""+ echo "Running: cargo fmt --check (standalone in $rdir)"+ FMT_OUT="$(cd "$rdir" && "$CARGO_BIN" fmt --check 2>&1)" || FMT_RC=$?+ if [[ $FMT_RC -ne 0 ]]; then+ FMT_COUNT="$(echo "$FMT_OUT" | grep -c '^Diff in' || true)"+ echo "Error: rustfmt drift: $FMT_COUNT hunks in $rdir (run ./format all to fix)."+ else+ echo "rustfmt: clean ($rdir)."+ fi+ done < <(standalone_crate_dirs)+fi # --- cargo doc (rust modules only, lint-sweep Phase 4) --- # Catches rustdoc::broken_intra_doc_links / invalid_html_tags. Both land as # warnings first (warn-then-error), so this fails only on rustdoc errors.
format
diff --git a/format b/formatindex d63d58a0d2..224c6d6420 100755--- a/format+++ b/format@@ -114,6 +114,28 @@ echo "" # --- cargo fmt (rust modules only; same crate scoping as ./check) --- # Workspace members share one root invocation via -p; standalone crates # (own [workspace] table) are handled individually in their own dir.+# With `all`, the workspace-wide `--all` run also covers workspace crates+# with no Gradle module (scripts/, third_party/, library/tilecodec,+# library/jni-http, library/vision, communicate-dev/src/main/rust-mls),+# and any standalone crate that is not a workspace member (a Cargo.toml+# outside target/build/personal and outside the workspace member set)+# is formatted in its own dir.+standalone_crate_dirs() {+ python3 - "$ROOT" "$CARGO_BIN" <<'PYEOF'+import json, os, pathlib, subprocess, sys+root = pathlib.Path(sys.argv[1]); cargo = sys.argv[2]+try:+ meta = json.loads(subprocess.check_output([cargo, "metadata", "--format-version", "1", "--no-deps"], cwd=root, text=True, stderr=subprocess.DEVNULL))+ members = {str(pathlib.Path(p["manifest_path"]).parent) for p in meta["packages"]}+except Exception:+ members = set()+skip = {"target", "build", ".git", ".gradle", "personal"}+for dirpath, dirnames, filenames in os.walk(root):+ dirnames[:] = sorted(d for d in dirnames if d not in skip)+ if "Cargo.toml" in filenames and dirpath != str(root) and dirpath not in members:+ print(dirpath)+PYEOF+} ROOT_CRATES=() STANDALONE_DIRS=() for mod in "${MODS[@]}"; do@@ -130,7 +152,7 @@ for mod in "${MODS[@]}"; do fi done CARGO_RC=0-if [[ ${#ROOT_CRATES[@]} -gt 0 || ${#STANDALONE_DIRS[@]} -gt 0 ]]; then+if [[ ${#ROOT_CRATES[@]} -gt 0 || ${#STANDALONE_DIRS[@]} -gt 0 || $ALL_EXP -eq 1 ]]; then if command -v cargo >/dev/null 2>&1; then CARGO_BIN="cargo" else@@ -138,7 +160,17 @@ if [[ ${#ROOT_CRATES[@]} -gt 0 || ${#STANDALONE_DIRS[@]} -gt 0 ]]; then [[ -x "$CARGO_BIN" ]] || { echo "Error: cargo not found ($CARGO_BIN)." >&2; exit 1; } fi fi-if [[ ${#ROOT_CRATES[@]} -gt 0 ]]; then+if [[ $ALL_EXP -eq 1 ]]; then+ echo ""+ if [[ $CHECK_ONLY -eq 1 ]]; then+ echo "Running: $FMT_LABEL --all"+ ( cd "$ROOT" && "$CARGO_BIN" fmt --check --all ) || CARGO_RC=$?+ else+ echo "Running: $FMT_LABEL --all"+ ( cd "$ROOT" && "$CARGO_BIN" fmt --all ) || CARGO_RC=$?+ fi+ [[ $CARGO_RC -ne 0 ]] && echo "Warning: $FMT_LABEL (workspace) reported failures (exit $CARGO_RC)."+elif [[ ${#ROOT_CRATES[@]} -gt 0 ]]; then echo "" FMT_ARGS=() for c in "${ROOT_CRATES[@]}"; do FMT_ARGS+=(-p "$c"); done@@ -157,7 +189,22 @@ for rdir in ${STANDALONE_DIRS[@]:-}; do fi [[ $CARGO_RC -ne 0 ]] && echo "Warning: $FMT_LABEL ($rdir) reported failures (exit $CARGO_RC)." done-if [[ ${#ROOT_CRATES[@]} -eq 0 && ${#STANDALONE_DIRS[@]} -eq 0 ]]; then+if [[ $ALL_EXP -eq 1 ]]; then+ while IFS= read -r rdir; do+ [[ -z "$rdir" ]] && continue+ dup=0; for m in ${STANDALONE_DIRS[@]:-}; do [[ "$m" == "$rdir" ]] && dup=1; done+ [[ $dup -eq 1 ]] && continue+ echo ""+ echo "Running: $FMT_LABEL (standalone in $rdir)"+ if [[ $CHECK_ONLY -eq 1 ]]; then+ ( cd "$rdir" && "$CARGO_BIN" fmt --check ) || CARGO_RC=$?+ else+ ( cd "$rdir" && "$CARGO_BIN" fmt ) || CARGO_RC=$?+ fi+ [[ $CARGO_RC -ne 0 ]] && echo "Warning: $FMT_LABEL ($rdir) reported failures (exit $CARGO_RC)."+ done < <(standalone_crate_dirs)+fi+if [[ ${#ROOT_CRATES[@]} -eq 0 && ${#STANDALONE_DIRS[@]} -eq 0 && $ALL_EXP -eq 0 ]]; then echo "No Rust crates in scope; cargo steps skipped." fi