You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(compile): address fourth-round PR review on codemod refactor
Two findings + three suggestions from the latest Rust PR Reviewer pass:
1. Stage-3 typed-deserialize errors after codemods reused the same
"Failed to parse YAML front matter" context as the Stage-1 raw
parse, so a codemod that produced an invalid shape was
indistinguishable from a user typo. Switch to with_context that
surfaces the applied codemod ids when codemods ran:
"Failed to parse YAML front matter after applying codemods (id1, id2);
a codemod likely produced an invalid shape".
2. rename_key with ConflictPolicy::PreferNew returns Ok(true) when
it drops a stale `old` key even though `new` is unchanged. That
triggers a source-rewrite warning saying "we migrated" when
really we "cleaned up a remnant". The behavior is correct (the
mapping did mutate); the doc was misleading. Rewrote the
rename_key doc comment to enumerate exactly when Ok(true) fires
and call out the PreferNew/cleanup case.
3. Added `// TODO(codemods): remove when the first real codemod is
registered.` markers next to every #[allow(dead_code)] /
#[allow(unused_imports)] in src/compile/codemods/{mod,helpers}.rs
so search-based cleanup is trivial when the registry stops being
empty.
4. tests/codemod_tests.rs leaked temp dirs on assertion failure
because `let _ = fs::remove_dir_all(&dir)` only ran on the happy
path. Refactored to return tempfile::TempDir from the helpers
and rely on RAII cleanup, matching the pattern already used by
src/compile/codemod_integration_test.rs.
Skipped: the empty-mapping concern in reconstruct_source (a
mapping reduced to empty wouldn't deserialize as FrontMatter
anyway because of required name/description fields, so the
existing typed-deserialize error path catches it; #1 makes that
error informative).
All 1349 tests pass.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
0 commit comments