Skip to content

refactor: remove stale dead code#10238

Merged
jdx merged 4 commits into
jdx:mainfrom
risu729:refactor/remove-unused-option-source-helper
Jun 5, 2026
Merged

refactor: remove stale dead code#10238
jdx merged 4 commits into
jdx:mainfrom
risu729:refactor/remove-unused-option-source-helper

Conversation

@risu729

@risu729 risu729 commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • remove stale unused helpers, fields, and enum variants instead of moving broad #[allow(dead_code)] annotations into this branch
  • keep the CI workflow unchanged because .github/workflows/test.yml already runs cargo clippy -- -D warnings and cargo clippy --all-features --all-targets -- -D warnings

Removed stale code

Option source / backend args

  • ResolvedToolOptions::has_any_key_except_from_sources — added in #9306 but never wired to production; only its unit-test assertion referenced it.
  • BackendArg::full_with_opts — introduced in #4960 / #6807; last production caller removed in #8448 (write_backend_meta switched to full_without_opts()). Tests added later in #9124 and #9958 kept it alive for Clippy.
  • Config::get_tool_opts — introduced in #7655; external callers migrated to get_tool_opts_with_overrides / resolve_tool_opts_with_overrides in #9306, leaving this accessor as an unused wrapper that was inlined here.

Config / env

  • ConfigFile::config_type and its impls — introduced in #4902; last callers removed in #6501 when idiomatic version file handling changed. Idiomatic impls lingered through #8171 without new call sites.
  • IdiomaticVersionFile::init — added in #8171 for the generic idiomatic parser refactor, but never called.
  • Config::vars_results and vars_loader — introduced in #6401; production immediately used vars_results_cached() instead, so the async accessor and loader back-reference were never called.
  • MinVersionSpec mutators, is_empty, merge_with, and Display — introduced in #6433; specs are built via parsing/new and checked through hard_violation / soft_violation, so write/merge/display helpers were never used. MiseToml debug snapshot updated to use derived Debug output.

Deps / platform / plugins

  • DepsProviderConfig::is_custom and DepsConfig::{merge,get} — introduced in #9056; the deps engine reads provider maps directly and never called these helpers.
  • Platform::{is_compatible_with_current,is_arm64,is_x64} — introduced in #6227; only referenced from their own unit tests after platform resolution moved to validation, lockfile keys, and OS helpers.
  • PluginEnum::install — added in #5172 alongside ensure_installed, but install flows always used ensure_installed / concrete plugin methods instead.
  • Backend::warn_if_dependencies_missing — introduced with a caller in #3104; last caller removed in #3172. The trait default lingered and was updated in #5172 / #5223, but no call sites were restored.

Redactions / lockfile metadata

  • Redactions::{merge,render,is_empty} — introduced in #3529; runtime redaction moved to Redactor in #7931, leaving these methods unused.
  • Redactor::patterns — added with Redactor in #7931; only a unit test referenced it (patterns_arc() is used in production).
  • tera::render_str_if_template — introduced in #9833; production call sites in that PR switched to contains_template_syntax + render_str, and the only remaining caller was the already-dead Redactions::render path.
  • GitHubReleaseInfo::{repo,release_type} and ReleaseType — introduced in #6228 / #6230; platform lock resolution only reads asset_pattern and api_url, so the other fields were write-only scaffolding.

Out of scope (handled separately)

  • ProgressIcon::{Warning,Error} — restored on this branch; kept for future use.
  • TaskTemplate::{hide,quiet,raw} — not dead code; schema/runtime mismatch tracked in #10242.

Verification

  • cargo fmt --all -- --check
  • git diff --check
  • cargo clippy -- -D warnings
  • cargo clippy --all-features --all-targets -- -D warnings
  • cargo test config::config_file::mise_toml::tests::test_env
  • cargo test tool_options fails before running tests in unrelated Aqua test code (AquaPackage::complete_windows_ext_to_file_src, complete_windows_ext_to_file_dst, and windows_ext are missing); this PR does not modify src/backend/aqua.rs or crates/aqua-registry.

Summary by CodeRabbit

  • Refactor
    • Internal code cleanup and simplification of configuration and plugin APIs
    • Removed redundant helper methods and streamlined internal data structures
    • Simplified configuration type handling across config file implementations

@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Complex PR? Review this PR in Change Stack to move by importance, not file order.

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b4d33815-a0e8-4227-8bd9-007a76b8901b

📥 Commits

Reviewing files that changed from the base of the PR and between ebf4795 and d747334.

⛔ Files ignored due to path filters (1)
  • src/config/config_file/snapshots/mise__config__config_file__mise_toml__tests__env-4.snap is excluded by !**/*.snap
📒 Files selected for processing (15)
  • src/backend/mod.rs
  • src/cli/args/backend_arg.rs
  • src/config/config_file/idiomatic_version/mod.rs
  • src/config/config_file/min_version.rs
  • src/config/config_file/mise_toml.rs
  • src/config/config_file/mod.rs
  • src/config/config_file/tool_versions.rs
  • src/config/mod.rs
  • src/deps/rule.rs
  • src/platform.rs
  • src/plugins/core/bun.rs
  • src/plugins/mod.rs
  • src/redactions.rs
  • src/tera.rs
  • src/toolset/tool_version_options.rs
💤 Files with no reviewable changes (6)
  • src/plugins/mod.rs
  • src/config/config_file/tool_versions.rs
  • src/deps/rule.rs
  • src/platform.rs
  • src/config/config_file/mod.rs
  • src/config/config_file/idiomatic_version/mod.rs

📝 Walkthrough

Walkthrough

This PR removes unused public APIs and simplifies data structures across multiple backend and configuration modules. Changes include removing fields from GitHubReleaseInfo, deleting config_type() from the ConfigFile trait, encapsulating MinVersionSpec accessors, refactoring Config internals to eliminate vars_loader, and removing convenience methods from utilities like BackendArg, Platform, Redactions, and others.

Changes

API cleanup and schema simplification

Layer / File(s) Summary
Type and schema simplifications
src/backend/mod.rs, src/config/config_file/min_version.rs, src/redactions.rs
GitHubReleaseInfo drops repo and release_type fields; MinVersionSpec encapsulates hard/soft accessors and removes mutation methods; Redactions becomes a simple tuple struct with patterns_arc() replacing patterns().
Trait interface removals
src/backend/mod.rs, src/config/config_file/mod.rs
ConfigFile trait removes config_type() method; Backend trait removes warn_if_dependencies_missing() helper method and HashSet import.
ConfigFile implementation updates
src/config/config_file/idiomatic_version/mod.rs, src/config/config_file/mise_toml.rs, src/config/config_file/tool_versions.rs
Remove config_type() overrides from all three ConfigFile implementations; remove test-only init() from IdiomaticVersionFile; update imports and debug field formatting for MinVersionSpec.
Bun plugin GitHubReleaseInfo updates
src/plugins/core/bun.rs
Update Bun plugin to construct GitHubReleaseInfo without repo and release_type; remove ReleaseType import and reformat api_url construction.
Config module internals refactoring
src/config/mod.rs
Remove vars_loader field from Config struct; eliminate public vars_results() and get_tool_opts() accessors; inline option resolution logic into resolve_tool_opts_with_overrides(); update five unit test fixtures to remove vars_loader initialization.
BackendArg method removal
src/cli/args/backend_arg.rs
Remove full_with_opts() method and its dependent imports (EPHEMERAL_OPT_KEYS, serialize_tool_options); delete tests covering option serialization, appending, and bracket handling.
Utility and helper method removals
src/deps/rule.rs, src/platform.rs, src/plugins/mod.rs, src/tera.rs, src/toolset/tool_version_options.rs
Remove DepsProviderConfig::is_custom(), DepsConfig::merge(), and DepsConfig::get(); remove Platform architecture predicates (is_arm64, is_x64, is_compatible_with_current); remove PluginEnum::install(); remove render_str_if_template() and related tests; remove ResolvedToolOptions::has_any_key_except_from_sources(); update all associated tests and documentation.
Redactions accessor test update
src/redactions.rs
Update test assertion to use new patterns_arc().len() instead of removed patterns().len().

🎯 4 (Complex) | ⏱️ ~75 minutes

A curious rabbit hops through the code, pruning branches with care,
Removing old paths that nobody dared to repair.
Schemas grow simpler, traits lose their weight,
The codebase breathes lighter—less baggage to crate! 🐰✂️

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 73.68% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately summarizes the main change: systematically removing unused helpers, fields, and enum variants across the codebase.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@greptile-apps

greptile-apps Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR removes accumulated dead code across 16 files — helpers, fields, enum variants, and trait methods that were introduced in earlier PRs but whose call sites were subsequently removed or replaced. Each deletion is backed by a traceable history in the PR description.

  • Removes unused methods/fields across backends, config, redactions, tera, platform, and plugins (e.g. full_with_opts, config_type, warn_if_dependencies_missing, render_str_if_template, vars_loader, ReleaseType).
  • Inlines the body of the now-private get_tool_opts directly into its sole remaining caller get_tool_opts_with_overrides, and updates the MinVersionSpec debug output from the deleted Display impl to derived Debug with a matching snapshot update.

Confidence Score: 5/5

Pure dead-code removal with no behavioral changes; all deletions are verified by the author against cargo clippy -- -D warnings.

Every removed symbol is either call-site-free (confirmed by Clippy) or only referenced by its own unit tests, which are also removed. The one non-trivial transformation — inlining get_tool_opts into get_tool_opts_with_overrides — is a mechanical copy with identical logic. The snapshot update correctly reflects the shift from a hand-written Display to derived Debug.

No files require special attention.

Important Files Changed

Filename Overview
src/config/mod.rs Removes vars_loader field and vars_results() async accessor; inlines the previously separate get_tool_opts() helper directly into get_tool_opts_with_overrides() — logic is identical, no behavioral change.
src/cli/args/backend_arg.rs Removes full_with_opts() method and all five associated unit tests; also drops unused EPHEMERAL_OPT_KEYS and serialize_tool_options imports.
src/config/config_file/mod.rs Removes config_type() as a required method from the ConfigFile trait, which had no production call sites after #6501.
src/config/config_file/min_version.rs Makes hard()/soft() private, removes setters, is_empty, merge_with, and the Display impl; spec is now only built via new() and queried via hard_violation/soft_violation.
src/backend/mod.rs Removes unused HashSet import, repo/release_type fields from GitHubReleaseInfo, the ReleaseType enum, and the warn_if_dependencies_missing trait default method — all confirmed dead by the PR history.
src/redactions.rs Removes Redactions::{merge,render,is_empty} and Redactor::patterns(); test updated to use patterns_arc().len() instead of patterns().len().
src/tera.rs Removes render_str_if_template() and its two dedicated unit tests; remaining test code updated to call render_str() directly.

Reviews (5): Last reviewed commit: "refactor: restore progress_report and ta..." | Re-trigger Greptile

@risu729 risu729 force-pushed the refactor/remove-unused-option-source-helper branch from 42cf883 to 697f5fc Compare June 5, 2026 18:59
@risu729 risu729 changed the title refactor(toolset): remove unused option source helper refactor: remove stale dead code Jun 5, 2026
risu729 added 3 commits June 6, 2026 05:54
Drop helpers that only existed for removed APIs (Redactor::patterns,
MinVersionSpec::Display, IdiomaticVersionFile::init) and inline the
unused public Config::get_tool_opts accessor into resolve_tool_opts.
Reflect MinVersionSpec derived Debug output after removing Display.
Keep ProgressIcon::Warning/Error in progress_report and TaskTemplate
hide/quiet/raw fields out of this dead-code cleanup PR. Template
output flags are a separate bug fix, not stale code removal.
@risu729 risu729 marked this pull request as ready for review June 5, 2026 20:56
@jdx jdx merged commit 33d6ec4 into jdx:main Jun 5, 2026
33 checks passed
@risu729 risu729 deleted the refactor/remove-unused-option-source-helper branch June 5, 2026 23:56
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.

2 participants