Repository navigation
Sweep cli args.rs: inline, dedupe tests, trim docs - #1842
Mikola Lysenko (mikolalysenko) wants to merge 3 commits into
Conversation
Assisted-by: Claude Code:claude-opus-5-5
Inline unsupported_ecosystem_message, telemetry_credentials and refuse_unloaded_deno_prefix (now in Commands::validate_paths, its one caller). validate_paths checks --cwd and --global-prefix with one helper. Trim history and restating doc comments. Delete inline tests that duplicate tests/cli_global_args.rs, the two vendor_service_config tests that assert constant VendorSource predicates, and a test that checked a hand list against itself. ecosystem_rejection_messages now goes through parse_supported_ecosystem with exact messages; the telemetry test asserts the route telemetry_auth builds. Behavior, messages and exit codes are unchanged. Assisted-by: Claude Code:claude-opus-5-5
Route telemetry_auth through api_client_overrides so telemetry and the API client start from the same values. Pin SOCKET_NO_CONFIG in the telemetry test, pin the literal ecosystem list in the rejection test, and assert use_public_proxy reaches the vendor service config. Restore the scrub warning on LOCAL_ARG_ENV_VARS and the --json reason in validate_paths, and make the Deno refusal a plain guard. Assisted-by: Claude Code:claude-opus-5-5
|
BugBot review Generated by Claude Code |
Assisted-by: Claude Code:claude-opus-5-5
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit d221369. Configure here.
|
Burn-down agent: labeled Ready for review at
Generated by Claude Code |
Final review brief (
|
LLM Description written by Claude Code:claude-opus-5-5
Summary
This PR sweeps
crates/socket-patch-cli/src/args.rs, the first audited and unswept row in the coverage manifest. It is part of the architecture refactor routine, and the run is logged in discussion #1830. The work follows theaudit-cli-testsnotes on the file: inline single-caller functions, flattenvalidate_paths, trim history comments, and delete duplicated or can't-fail inline tests.Changes
Inlined
unsupported_ecosystem_messageis now insideparse_supported_ecosystem, which also returns early instead of usingif/else.telemetry_credentialsis now insidetelemetry_auth, which still goes throughapi_client_overridesso it uses the same values as the API client.refuse_unloaded_deno_prefixhad one caller and is now insideCommands::validate_pathsinlib.rs, as a plain guard. The error text is byte-identical.Flattened
validate_pathsnow checks--cwdand--global-prefixwith onerequire_dirclosure instead of two copies of the same block.Comments
#444/#745/#1123references, and text that restated the code.whycomments stay, including the scrub warning, themanifest_unreadable/--jsonreason, the Deno refusal reason and the secret-leak note.--helptext (the field doc comments) is untouched.Tests deleted as duplicates of
tests/cli_global_args.rsempty_bool_env_var_parses_as_false_not_crashtruthy_bool_env_var_parses_as_truebare_cli_flag_sets_truebools_default_false_when_unsetcli_arg_overrides_env_varenv_var_used_then_default_appliesapi_client_overrides_default_is_all_nonevendor_url_and_patch_server_url_flow_from_cli_and_envparse_supported_ecosystem_rejects_unknown_names(a.containscheck, now folded into the exact-message test below)Tests deleted because they can't fail
vendor_service_config_default_source_permits_serviceandvendor_service_config_honors_service_and_build_sourcesassertVendorSourcepredicates that are constanttrue(C23 / Delete the vendored and hosted-vlt helpers left without a production caller by the v5 consolidation #782).global_arg_env_vars_includes_vendor_knobschecks a hand-written list against itself. Derive the env-var scrub lists from clap's bindings; SOCKET_NO_SOCKET_YML is missing from LOCAL_ARG_ENV_VARS #1837 tracks deriving that list from clap.Tests fixed
ecosystem_rejection_messagesnow goes throughparse_supported_ecosystemand compares the exact error strings against the literal ecosystem list. Before, it called the deleted helper with a made-up list. Red→green: changings.trim().is_empty()tos.is_empty()fails it.telemetry_auth_prefers_explicit_values_and_treats_empty_as_unsetreplaces thetelemetry_credentialstest. It asserts the org URL and bearer for explicit values, and the proxy with no bearer for empty values. It pinsSOCKET_NO_CONFIGand is now#[serial]. Red→green: passingNonefor the token fails it.vendor_service_config_threads_overrides_throughnow also asserts thatuse_public_proxythreads through. Red→green: hardcodinguse_public_proxy: falsefails it.vendor_source_flag_parses_normalizes_and_defaultsis renamedvendor_source_flag_normalizes_and_rejects_removed_sources. Its comments claimed anautodefault and that the env var was "honored", while the test actually asserts a rejection. It now also covers theautoalias.Not done
build_proxy_fallback_client(coreapi/client.rs) usesoverrides.proxy_urlwithout filtering empties, so the filter is load-bearing. The filter and its test stay, and the doc now says why.--vendor-source/VendorSourceplumbing spans core and is user-visible. It stays with C23 / Delete the vendored and hosted-vlt helpers left without a production caller by the v5 consolidation #782.Size
git diff --stat: 3 files, +180 / −506.args.rs839 → 722 lines;lib.rs+23. Net −94.args.rstest module 971 → 739. Net −232.Behavior change
None. Messages, exit codes and JSON are unchanged.
Verification
cargo clippy --workspace --all-features -- -D warnings: clean.cargo test -p socket-patch-cli --lib: 928 passed.--test cli_global_args(14),--test cli_path_flags_validated(29),--test global_scope_project_state(47) and--test cli -- list_render(4) all pass./code-review highran. Every finding is addressed except the deleted tautology test, which is covered by Derive the env-var scrub lists from clap's bindings; SOCKET_NO_SOCKET_YML is missing from LOCAL_ARG_ENV_VARS #1837.Risk
Low. The production change is limited to moving code that already existed. No
cfg(windows)/cfg(unix)code is touched.🤖 Generated with Claude Code
https://claude.ai/code/session_011f9aeSbHUhUaxmpmd61LMP
Note
Low Risk
Refactor-only: logic is relocated or deduplicated with no intended message, exit-code, or JSON changes; risk is limited to accidental wiring during the move.
Overview
This PR sweeps
crates/socket-patch-cli/src/args.rsas part of the CLI audit routine: structure and tests, not user-visible behavior.Production code
parse_supported_ecosysteminlines the oldunsupported_ecosystem_messagehelper (same empty vs unsupported wording).validate_pathsdeduplicates--cwd/--global-prefixchecks via a sharedrequire_dirclosure.telemetry_credentialsis folded intotelemetry_auth, still usingapi_client_overridesandresolve_ambient_credentials.refuse_unloaded_deno_prefixmoves fromGlobalArgsintoCommands::validate_pathsinlib.rs(same error text; restore commands still skip the check).Comments
GlobalArgshelpers are shortened; operationalwhynotes (env mirror, scrub, manifest vs--json, secret mirroring) stay.--helpfield docs are unchanged.Tests
tests/cli_global_args.rsor other suites already cover.telemetry_authURL/bearer vs proxy,use_public_proxythreading, vendor-sourceauto/ removedbuild.Integration
list_render.rscomments now referencetelemetry_authinstead oftelemetry_credentials.Net: ~500 lines removed, mostly comments and redundant tests;
args.rsshrinks while path validation, telemetry credential routing, and Deno--global-prefixrefusal stay the same.Reviewed by Cursor Bugbot for commit d221369. Configure here.
Generated by Claude Code