Skip to content

refactor(cli): share check/dump plumbing, collect check args in one struct - #146

Merged
sims1253 merged 4 commits into
mainfrom
refactor/cli-check-dump-dedup
Sep 1, 2026
Merged

sims1253 merged 4 commits into
mainfrom
refactor/cli-check-dump-dedup

Conversation

@sims1253

Copy link
Copy Markdown
Owner

Summary

This PR is stacked on #133 and should merge after it.

ry check and ry dump-types ran near-identical copies of the same pipeline code. This PR moves that code into one place. CLI behavior does not change.

Changes

  • New module crates/ry-cli/src/pipeline.rs holds the shared front half of both commands.
  • pipeline::parse_files replaces the two thread-local parser pools (PARSER in main.rs, DUMP_PARSER in 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_config replaces the duplicated Ok(Some)/Ok(None)/Err match 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_root and pipeline::workspace_context replace the copied BTreeMap grouping loop and the six-field WorkspaceContext copy. workspace_context splits 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_check takes a CheckArgs struct and run_check_once a CheckContext struct. Both #[allow(clippy::too_many_arguments)] are gone. The file set stays a run_check_once parameter because watch iterations change it.
  • CheckArgs now derives Args and backs Cmd::Check. The bare ry default is CheckArgs::default(). Flag defaults share one source: empty vecs, unset flags, and absent options default through their types; --output-format reads DEFAULT_CHECK_OUTPUT_FORMAT; --color and --min-confidence read the enums' Default impls.
  • CheckInput::files drops the dead version: i32 field. Both call sites passed literal 0.
  • Test module: one check_files(paths, repo_root) helper replaces ten copies of the same run_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-cli
  • cargo clippy -p ry-cli --all-targets -- -D warnings
  • cargo test -p ry-cli — all suites pass (34 unit, 37 config e2e, 11 dump-types e2e, plus testkit/lsp/typeshed)
  • cargo check --workspace

No changelog entry: nothing user-visible changed.

@coderabbitai

coderabbitai Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 59 minutes.

View limit details

Limit 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.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Team

Run ID: 035af7b5-5f7a-4e83-a3ae-b2ebbb37f349

📥 Commits

Reviewing files that changed from the base of the PR and between 196850f and e4ff5a0.

📒 Files selected for processing (5)
  • crates/ry-cli/src/check.rs
  • crates/ry-cli/src/dump.rs
  • crates/ry-cli/src/main.rs
  • crates/ry-cli/src/pipeline.rs
  • crates/ry-cli/tests/dump_types_e2e.rs

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ 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.rs owns the front half of both ry check and ry dump-types: config discovery (discover_config), one thread-local parser pool (parse_files, replacing PARSER and DUMP_PARSER), per-package grouping (group_by_package_root), and the WorkspaceContext split (workspace_context); the two commands' differing parse-failure policies are callbacks returning FailureAction::Skip/Abort.
  • Cmd::Check moves from an inline variant field list to a #[derive(Args)] CheckArgs struct that also backs bare ry via CheckArgs::default(); scalar flag defaults are single-sourced (DEFAULT_CHECK_OUTPUT_FORMAT, #[default] on ColorChoice::Auto/ConfidenceChoice::Low).
  • run_check_once's parameter list collapses into CheckContext (the file set stays a parameter because watch iterations change it); CheckInput::files drops the always-0 version: i32 field.
  • The test module deduplicates ten run_check_once(...) tails into a check_files helper.

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_source and pipeline::enclosing_package_root are pub(crate), but after the move nothing outside pipeline.rs calls them — they could be plain-private now (the crate visibility was an artifact of being shared out of main.rs).
  • The abort path of parse_files (an unreadable-but-discovered file in ry dump-types: exactly one ry: <path>: <error> line, exit 1) is the one piece of behavior this PR genuinely rewired, and nothing pins it — the !root.exists() guard in run_dump_types intercepts 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.

Pullfrog  | Fix it ➔ | View workflow run | Using openai-compatible/glm-5.3 | 𝕏

@sims1253
sims1253 deleted the branch main August 31, 2026 19:57
@sims1253 sims1253 closed this Aug 31, 2026
@sims1253 sims1253 reopened this Aug 31, 2026
@sims1253
sims1253 changed the base branch from fix/cli-verbosity-messages to main August 31, 2026 21:25
…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).
@sims1253

Copy link
Copy Markdown
Owner Author

Addressed both review nitpicks in e4ff5a0:

  • pipeline::read_r_source and pipeline::enclosing_package_root are now plain-private. Grep confirmed their only callers live in pipeline.rs; the pub(crate) was a leftover from when they sat in main.rs.
  • Added unreadable_discovered_file_aborts_with_single_stderr_line to dump_types_e2e.rs. It pins the rewired abort path: a discovered file with mode 0o000 produces exactly one ry: <path>: <error> line on stderr, exit code 1, and no JSON on stdout. The test verifies the chmod actually denies the read first and skips when it does not (running as root), so it stays portable. The nonexistent-input case stays covered separately by the !root.exists() guard.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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_source and enclosing_package_root to private — both lost their last callers outside the module when the helpers moved out of main.rs; a repo-wide grep confirms every caller now sits inside pipeline.rs, and main.rs's shared-helper import list no longer names them.
  • Pinned the dump-types read-error abort in e2e — new unreadable_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 one ry: <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.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | View workflow run | Using openai-compatible/glm-5.3 | 𝕏

@sims1253
sims1253 merged commit c42779b into main Sep 1, 2026
16 checks passed
@sims1253
sims1253 deleted the refactor/cli-check-dump-dedup branch September 1, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant