Repository navigation
refactor(cli): share check/dump plumbing, collect check args in one struct - #146
Conversation
|
Warning Review limit reachedNext included review available in 59 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Team Run ID: 📒 Files selected for processing (5)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
ℹ️ No critical issues — two minor nitpicks below.
Reviewed changes
This review covers the full PR (1 commit): the shared-pipeline extraction, the CheckArgs/CheckContext reshapes, and the dead-field removal, with an independent parity check against the pre-refactor behavior.
- New
crates/ry-cli/src/pipeline.rsowns the front half of bothry checkandry dump-types: config discovery (discover_config), one thread-local parser pool (parse_files, replacingPARSERandDUMP_PARSER), per-package grouping (group_by_package_root), and theWorkspaceContextsplit (workspace_context); the two commands' differing parse-failure policies are callbacks returningFailureAction::Skip/Abort. Cmd::Checkmoves from an inline variant field list to a#[derive(Args)] CheckArgsstruct that also backs bareryviaCheckArgs::default(); scalar flag defaults are single-sourced (DEFAULT_CHECK_OUTPUT_FORMAT,#[default]onColorChoice::Auto/ConfidenceChoice::Low).run_check_once's parameter list collapses intoCheckContext(the file set stays a parameter because watch iterations change it);CheckInput::filesdrops the always-0version: i32field.- The test module deduplicates ten
run_check_once(...)tails into acheck_fileshelper.
Parity verified independently: all four parse-failure stderr messages are byte-identical in format, abort selection stays first-in-input-order, parse_errors/file_count/RY097-filter semantics are unchanged, CheckArgs::default() matches the old literal defaults field-for-field, and the ValueSource arg IDs driving the config merge are untouched. cargo test -p ry-cli and cargo clippy -p ry-cli --all-targets -- -D warnings both pass on this tree, and ry check --help renders with the same flags and defaults.
ℹ️ Nitpicks
pipeline::read_r_sourceandpipeline::enclosing_package_rootarepub(crate), but after the move nothing outsidepipeline.rscalls them — they could be plain-private now (the crate visibility was an artifact of being shared out ofmain.rs).- The abort path of
parse_files(an unreadable-but-discovered file inry dump-types: exactly onery: <path>: <error>line, exit 1) is the one piece of behavior this PR genuinely rewired, and nothing pins it — the!root.exists()guard inrun_dump_typesintercepts the nonexistent-input case first, so a regression in the rewiring would be silent. A small e2e test with an unreadable fixture would lock the contract.
openai-compatible/glm-5.3 | 𝕏
…mp-dedup # Conflicts: # CHANGELOG.md # crates/ry-cli/src/main.rs
read_r_source and enclosing_package_root lost their last callers outside pipeline.rs when the helpers moved out of main.rs; demote both to private. Add an e2e test for the one behavior this PR rewired: an unreadable-but-discovered file aborts ry dump-types with exactly one `ry: <path>: <error>` line on stderr and exit code 1. The test skips itself when mode-0 files stay readable (root).
|
Addressed both review nitpicks in e4ff5a0:
|
There was a problem hiding this comment.
✅ No new issues found. Both nitpicks from the prior review are addressed cleanly.
Reviewed changes
This run covers the delta since the prior review at ac85e81: merge commit 1675dc3 (verified earlier as a no-op for the refactor — one help-comment line absorbed from main) and e4ff5a0, which targets exactly the two open nitpicks.
- Demoted
read_r_sourceandenclosing_package_rootto private — both lost their last callers outside the module when the helpers moved out ofmain.rs; a repo-wide grep confirms every caller now sits insidepipeline.rs, andmain.rs's shared-helper import list no longer names them. - Pinned the
dump-typesread-error abort in e2e — newunreadable_discovered_file_aborts_with_single_stderr_line(#[cfg(unix)], mode-0 fixture with a documented self-skip when root/exotic filesystems can still read it) asserts the full rewired contract: exit code 1, empty stdout, exactly onery: <path>: …line on stderr.
Verified locally on e4ff5a0: cargo test -p ry-cli --test dump_types_e2e passes 12/12 with the new test actually executing (this environment is non-root, so the abort path runs rather than skipping), and cargo clippy -p ry-cli --all-targets -- -D warnings is clean. The exactly-one-stderr-line assertion is robust under inherited environments because the CLI builds its EnvFilter from the -v flags rather than RUST_LOG.
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using openai-compatible/glm-5.3 | 𝕏

Summary
This PR is stacked on #133 and should merge after it.
ry checkandry dump-typesran near-identical copies of the same pipeline code. This PR moves that code into one place. CLI behavior does not change.Changes
crates/ry-cli/src/pipeline.rsholds the shared front half of both commands.pipeline::parse_filesreplaces the two thread-local parser pools (PARSERin main.rs,DUMP_PARSERin dump.rs). One pool now serves both. Each command passes its error policy as a callback: check reports and counts every failure; dump-types warns and skips an unparseable file, and aborts on an unreadable one. The thread-local rationale comment moved with the pool.pipeline::discover_configreplaces the duplicatedOk(Some)/Ok(None)/Errmatch in both commands. The two search-start rules stay separate and now say so in comments: check anchors at the first path's parent, dump-types at the first input itself.pipeline::group_by_package_rootandpipeline::workspace_contextreplace the copiedBTreeMapgrouping loop and the six-fieldWorkspaceContextcopy.workspace_contextsplits the resolved scope into the checker input and the degraded-scope notes; each command still reports those notes its own way. The helper lives in ry-cli; ry-workspace is untouched.run_checktakes aCheckArgsstruct andrun_check_onceaCheckContextstruct. Both#[allow(clippy::too_many_arguments)]are gone. The file set stays arun_check_onceparameter because watch iterations change it.CheckArgsnow derivesArgsand backsCmd::Check. The barerydefault isCheckArgs::default(). Flag defaults share one source: empty vecs, unset flags, and absent options default through their types;--output-formatreadsDEFAULT_CHECK_OUTPUT_FORMAT;--colorand--min-confidenceread the enums'Defaultimpls.CheckInput::filesdrops the deadversion: i32field. Both call sites passed literal0.check_files(paths, repo_root)helper replaces ten copies of the samerun_check_once(...)tail.Verification
ry --help,ry check --help,ry dump-types --help, and the zsh/bash/fish completions are byte-identical before and after (captured and diffed).cargo fmt -p ry-clicargo clippy -p ry-cli --all-targets -- -D warningscargo test -p ry-cli— all suites pass (34 unit, 37 config e2e, 11 dump-types e2e, plus testkit/lsp/typeshed)cargo check --workspaceNo changelog entry: nothing user-visible changed.