From 49b0884701a84731652fc934d428932ff6029bd4 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 5 May 2026 17:29:12 +0900 Subject: chore: remove redundant comments --- crates/mozart/src/commands/config.rs | 66 ------------------------------------ 1 file changed, 66 deletions(-) (limited to 'crates/mozart/src/commands/config.rs') diff --git a/crates/mozart/src/commands/config.rs b/crates/mozart/src/commands/config.rs index 1946264..71a5981 100644 --- a/crates/mozart/src/commands/config.rs +++ b/crates/mozart/src/commands/config.rs @@ -60,12 +60,8 @@ pub struct ConfigArgs { pub source: bool, } -// ─── ComposerConfig ─────────────────────────────────────────────────────────── - pub use mozart_core::composer::{ComposerConfig, resolve_references}; -// ─── ConfigValueType ───────────────────────────────────────────────────────── - /// Classification of config key value types for validation and normalization. #[derive(Debug)] enum ConfigValueType { @@ -277,8 +273,6 @@ fn normalize_bool(key: &str, value: &str) -> anyhow::Result { } } -// ─── Repository helpers ─────────────────────────────────────────────────────── - /// Match `repo.X`, `repos.X`, `repositories.X` and return the suffix X. fn match_repository_key(key: &str) -> Option<&str> { for prefix in &["repositories.", "repos.", "repo."] { @@ -291,8 +285,6 @@ fn match_repository_key(key: &str) -> Option<&str> { None } -// ─── JSON path helpers ──────────────────────────────────────────────────────── - /// Set a value at a dot-separated path within a JSON Value. /// Creates intermediate objects as needed. fn json_set_nested(root: &mut serde_json::Value, path: &str, value: serde_json::Value) { @@ -337,8 +329,6 @@ fn json_remove_nested(root: &mut serde_json::Value, path: &str) -> bool { } } -// ─── File I/O helpers ───────────────────────────────────────────────────────── - /// Determine which JSON file to read/write. /// - `--global` → `$COMPOSER_HOME/config.json` /// - `--file ` → user-specified file @@ -356,8 +346,6 @@ fn resolve_config_file_path(args: &ConfigArgs, cli: &super::Cli) -> anyhow::Resu Ok(cli.working_dir()?.join("composer.json")) } -// ─── Helpers ────────────────────────────────────────────────────────────────── - /// Load the `config` section from a JSON file (global `config.json` or local /// `composer.json`). Returns an empty map when the file is absent or has no /// `config` key. @@ -379,10 +367,6 @@ fn load_config_section( } } -// ─── Value rendering ───────────────────────────────────────────────────────── - -// ─── execute() ─────────────────────────────────────────────────────────────── - pub async fn execute( args: &ConfigArgs, cli: &super::Cli, @@ -411,8 +395,6 @@ pub async fn execute( execute_read(args, cli, &config_file_path, console) } -// ─── execute_editor() ──────────────────────────────────────────────────────── - fn execute_editor(args: &ConfigArgs, cli: &super::Cli) -> anyhow::Result<()> { let file_path = resolve_config_file_path(args, cli)?; @@ -438,8 +420,6 @@ fn execute_editor(args: &ConfigArgs, cli: &super::Cli) -> anyhow::Result<()> { Ok(()) } -// ─── execute_write() ───────────────────────────────────────────────────────── - fn execute_write( args: &ConfigArgs, _cli: &super::Cli, @@ -463,8 +443,6 @@ fn execute_write( Ok(()) } -// ─── execute_unset() ───────────────────────────────────────────────────────── - fn execute_unset(json: &mut serde_json::Value, key: &str, args: &ConfigArgs) -> anyhow::Result<()> { // 1. Repository key if let Some(repo_name) = match_repository_key(key) { @@ -529,8 +507,6 @@ fn split_dotted_config_key(key: &str) -> Option<(&str, &str)> { None } -// ─── execute_set() ─────────────────────────────────────────────────────────── - fn execute_set( json: &mut serde_json::Value, key: &str, @@ -771,8 +747,6 @@ fn merge_json_values( } } -// ─── execute_read() ────────────────────────────────────────────────────────── - fn execute_read( args: &ConfigArgs, cli: &super::Cli, @@ -892,14 +866,10 @@ fn execute_read( Ok(()) } -// ─── Tests ─────────────────────────────────────────────────────────────────── - #[cfg(test)] mod tests { use super::*; - // ── defaults ─────────────────────────────────────────────────────────── - #[test] fn test_defaults_contain_expected_keys() { let cfg = ComposerConfig::defaults(); @@ -958,8 +928,6 @@ mod tests { assert_eq!(cfg.values["autoloader-suffix"], serde_json::Value::Null); } - // ── merge ────────────────────────────────────────────────────────────── - #[test] fn test_merge_overrides_existing_key() { let mut cfg = ComposerConfig::defaults(); @@ -996,8 +964,6 @@ mod tests { assert_eq!(cfg.values["vendor-dir"], original_vendor); } - // ── reference resolution ─────────────────────────────────────────────── - #[test] fn test_reference_resolution_bin_dir() { let mut cfg = ComposerConfig::defaults(); @@ -1052,8 +1018,6 @@ mod tests { assert_eq!(cfg.values["process-timeout"], before); } - // ── single key query ─────────────────────────────────────────────────── - #[test] fn test_get_existing_key() { let cfg = ComposerConfig::defaults(); @@ -1068,8 +1032,6 @@ mod tests { assert!(cfg.get("does-not-exist").is_none()); } - // ── render_value ─────────────────────────────────────────────────────── - #[test] fn test_render_value_string() { assert_eq!(render_value(&serde_json::json!("hello")), "hello"); @@ -1102,8 +1064,6 @@ mod tests { assert_eq!(render_value(&serde_json::json!({})), "{}"); } - // ── load_config_section ──────────────────────────────────────────────── - #[test] fn test_load_config_section_absent_file() { let path = std::path::Path::new("/tmp/nonexistent_composer_abc123.json"); @@ -1143,8 +1103,6 @@ mod tests { assert!(result.is_empty()); } - // ── full merge pipeline ──────────────────────────────────────────────── - #[test] fn test_full_pipeline_project_overrides_are_applied() { use std::io::Write; @@ -1173,8 +1131,6 @@ mod tests { ); } - // ── match_repository_key ─────────────────────────────────────────────── - #[test] fn test_match_repository_key_full() { assert_eq!(match_repository_key("repositories.foo"), Some("foo")); @@ -1189,8 +1145,6 @@ mod tests { assert_eq!(match_repository_key("sort-packages"), None); } - // ── json_set_nested / json_remove_nested ─────────────────────────────── - #[test] fn test_json_set_nested_simple() { let mut root = serde_json::json!({}); @@ -1235,8 +1189,6 @@ mod tests { assert!(!removed); } - // ── validate_and_normalize ───────────────────────────────────────────── - #[test] fn test_validate_bool_true() { let result = validate_and_normalize("sort-packages", "true", &ConfigValueType::Bool); @@ -1313,8 +1265,6 @@ mod tests { assert_eq!(result.unwrap(), serde_json::Value::Null); } - // ── validate_and_normalize_multi ─────────────────────────────────────── - #[test] fn test_validate_multi_string_array() { let values = vec!["a".to_string(), "b".to_string()]; @@ -1345,8 +1295,6 @@ mod tests { assert!(result.is_err()); } - // ── execute_set / execute_unset round-trips ──────────────────────────── - fn make_empty_json() -> serde_json::Value { serde_json::json!({}) } @@ -1480,8 +1428,6 @@ mod tests { assert!(result.is_err()); } - // ── unset tests ──────────────────────────────────────────────────────── - #[test] fn test_unset_config_value() { let mut json = serde_json::json!({"config": {"sort-packages": true}}); @@ -1498,8 +1444,6 @@ mod tests { assert!(result.is_err()); } - // ── package property tests ───────────────────────────────────────────── - #[test] fn test_set_package_property_name() { let mut json = make_empty_json(); @@ -1555,8 +1499,6 @@ mod tests { assert!(json.get("description").is_none()); } - // ── repository tests ─────────────────────────────────────────────────── - #[test] fn test_add_repository() { let mut json = make_empty_json(); @@ -1670,8 +1612,6 @@ mod tests { assert_eq!(match_repository_key("repositories.foo"), Some("foo")); } - // ── extra/suggest tests ──────────────────────────────────────────────── - #[test] fn test_set_extra_property() { let mut json = make_empty_json(); @@ -1735,8 +1675,6 @@ mod tests { assert!(json["extra"].get("key").is_none()); } - // ── dotted config key tests ──────────────────────────────────────────── - #[test] fn test_set_platform_php() { let mut json = make_empty_json(); @@ -1790,8 +1728,6 @@ mod tests { ); } - // ── global config file tests ─────────────────────────────────────────── - #[test] fn test_global_config_creates_file() { use tempfile::TempDir; @@ -1832,8 +1768,6 @@ mod tests { ); } - // ── read_json_file default skeleton ─────────────────────────────────── - #[test] fn test_read_json_file_missing_global() { let path = std::path::Path::new("/tmp/nonexistent_global_abc123.json"); -- cgit v1.3.1