diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-05 17:29:12 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-05 17:29:12 +0900 |
| commit | 49b0884701a84731652fc934d428932ff6029bd4 (patch) | |
| tree | 7477029b8ed686b9b3b06d960cab2b54ba87b579 /crates/mozart/src/commands/validate.rs | |
| parent | 4623874d1c95414dcd5ae194d2561f2d98b40982 (diff) | |
| download | php-mozart-49b0884701a84731652fc934d428932ff6029bd4.tar.gz php-mozart-49b0884701a84731652fc934d428932ff6029bd4.tar.zst php-mozart-49b0884701a84731652fc934d428932ff6029bd4.zip | |
chore: remove redundant comments
Diffstat (limited to 'crates/mozart/src/commands/validate.rs')
| -rw-r--r-- | crates/mozart/src/commands/validate.rs | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/crates/mozart/src/commands/validate.rs b/crates/mozart/src/commands/validate.rs index d7bd9fb..6bff198 100644 --- a/crates/mozart/src/commands/validate.rs +++ b/crates/mozart/src/commands/validate.rs @@ -45,8 +45,6 @@ pub struct ValidateArgs { pub strict: bool, } -// ─── Result accumulator ───────────────────────────────────────────────────── - struct ValidationResult { errors: Vec<String>, publish_errors: Vec<String>, @@ -75,8 +73,6 @@ impl ValidationResult { } } -// ─── Helpers ───────────────────────────────────────────────────────────────── - fn should_check_lock(args: &ValidateArgs, manifest: &serde_json::Value) -> bool { let config_lock_enabled = manifest .get("config") @@ -86,8 +82,6 @@ fn should_check_lock(args: &ValidateArgs, manifest: &serde_json::Value) -> bool (!args.no_check_lock && config_lock_enabled) || args.check_lock } -// ─── Entry point ───────────────────────────────────────────────────────────── - pub async fn execute( args: &ValidateArgs, cli: &super::Cli, @@ -195,8 +189,6 @@ pub async fn execute( Ok(()) } -// ─── Manifest validation ───────────────────────────────────────────────────── - fn validate_manifest( manifest: &serde_json::Value, args: &ValidateArgs, @@ -228,8 +220,6 @@ fn validate_manifest( check_scripts_orphans(obj, result); } -// ─── Individual checks ─────────────────────────────────────────────────────── - /// Check the "name" field: must be present (for published packages) and lowercase. fn check_name(obj: &serde_json::Map<String, serde_json::Value>, result: &mut ValidationResult) { match obj.get("name").and_then(|v| v.as_str()) { @@ -647,8 +637,6 @@ fn check_scripts_orphans( } } -// ─── Dependency validation ─────────────────────────────────────────────── - fn validate_dependencies( vendor_dir: &Path, args: &ValidateArgs, @@ -736,8 +724,6 @@ fn validate_dependencies( (dep_errors, dep_warnings) } -// ─── Lock file freshness ───────────────────────────────────────────────────── - fn check_lock_freshness( composer_json_content: &str, composer_json_path: &Path, @@ -769,8 +755,6 @@ fn check_lock_freshness( } } -// ─── Output ────────────────────────────────────────────────────────────────── - fn output_result( console: &mozart_core::console::Console, file: &Path, @@ -871,8 +855,6 @@ fn output_result( } } -// ─── Exit code ─────────────────────────────────────────────────────────────── - /// Compute the exit code following Composer's convention: /// 0 = valid, 1 = warnings (only with --strict), 2 = errors, 3 = file unreadable (handled earlier) fn compute_exit_code( @@ -899,8 +881,6 @@ fn compute_exit_code( 0 } -// ─── Tests ─────────────────────────────────────────────────────────────────── - #[cfg(test)] mod tests { use super::*; @@ -925,8 +905,6 @@ mod tests { result } - // ── check_name ───────────────────────────────────────────────────────── - #[test] fn test_validate_missing_name_is_publish_error() { let json = r#"{"require": {"php": ">=8.1"}, "license": "MIT"}"#; @@ -973,8 +951,6 @@ mod tests { assert!(result.errors[0].contains("vendor/package")); } - // ── check_license ────────────────────────────────────────────────────── - #[test] fn test_validate_missing_license_warns() { let json = r#"{"name": "vendor/pkg"}"#; @@ -1110,8 +1086,6 @@ mod tests { ); } - // ── ValidatingArrayLoader-equivalent license checks ──────────────────── - #[test] fn test_validate_license_wrong_type_warns() { let json = r#"{"name": "vendor/pkg", "license": 42}"#; @@ -1252,8 +1226,6 @@ mod tests { ); } - // ── parse_iso_time_to_unix ───────────────────────────────────────────── - #[test] fn test_parse_iso_time_basic() { assert_eq!(parse_iso_time_to_unix("1970-01-01 00:00:00"), Some(0)); @@ -1297,8 +1269,6 @@ mod tests { assert_eq!(parse_iso_time_to_unix("2023/12/15 13:45:30"), None); } - // ── check_version_field ──────────────────────────────────────────────── - #[test] fn test_validate_version_field_warns() { let json = r#"{"name": "vendor/pkg", "license": "MIT", "version": "1.0.0"}"#; @@ -1315,8 +1285,6 @@ mod tests { assert!(!result.warnings.iter().any(|w| w.contains("version field"))); } - // ── check_package_type ───────────────────────────────────────────────── - #[test] fn test_validate_deprecated_type_warns() { let json = r#"{"name": "vendor/pkg", "license": "MIT", "type": "composer-installer"}"#; @@ -1341,8 +1309,6 @@ mod tests { ); } - // ── check_require_overlap ────────────────────────────────────────────── - #[test] fn test_validate_require_overlap_warns() { let json = r#"{ @@ -1372,8 +1338,6 @@ mod tests { assert!(!result.warnings.iter().any(|w| w.contains("required both"))); } - // ── check_provide_replace_overlap ────────────────────────────────────── - #[test] fn test_validate_provide_replace_overlap_warns() { let json = r#"{ @@ -1391,8 +1355,6 @@ mod tests { ); } - // ── check_commit_references ──────────────────────────────────────────── - #[test] fn test_validate_commit_ref_warns() { let json = r#"{ @@ -1415,8 +1377,6 @@ mod tests { assert!(!result.warnings.iter().any(|w| w.contains("commit-ref"))); } - // ── check_empty_psr_prefixes ─────────────────────────────────────────── - #[test] fn test_validate_empty_psr4_prefix_warns() { let json = r#"{ @@ -1450,8 +1410,6 @@ mod tests { assert!(!result.warnings.iter().any(|w| w.contains("psr-4"))); } - // ── check_minimum_stability ──────────────────────────────────────────── - #[test] fn test_validate_invalid_stability_errors() { let json = r#"{"name": "vendor/pkg", "license": "MIT", "minimum-stability": "invalid"}"#; @@ -1482,8 +1440,6 @@ mod tests { } } - // ── validate_manifest with non-object ────────────────────────────────── - #[test] fn test_validate_non_object_json_errors() { let value = serde_json::json!([1, 2, 3]); @@ -1492,8 +1448,6 @@ mod tests { assert!(result.errors.iter().any(|e| e.contains("JSON object"))); } - // ── compute_exit_code ───────────────────────────────────────────────── - #[test] fn test_compute_exit_code_no_issues() { let result = ValidationResult::new(); @@ -1557,8 +1511,6 @@ mod tests { assert_eq!(compute_exit_code(&result, &[], true, true, false), 0); } - // ── check_lock_freshness ─────────────────────────────────────────────── - #[test] fn test_check_lock_freshness_no_lock_file() { use tempfile::tempdir; @@ -1651,8 +1603,6 @@ mod tests { assert!(lock_errors[0].contains("not up to date")); } - // ── check_scripts_orphans ────────────────────────────────────────────── - #[test] fn test_validate_scripts_descriptions_orphan_warns() { let json = r#"{ @@ -1725,8 +1675,6 @@ mod tests { ); } - // ── should_check_lock ────────────────────────────────────────────────── - #[test] fn test_should_check_lock_config_false_disables() { let args = make_args(); @@ -1749,8 +1697,6 @@ mod tests { assert!(should_check_lock(&args, &manifest)); } - // ── Full manifest: valid package ─────────────────────────────────────── - #[test] fn test_validate_no_errors_on_valid_package() { let json = r#"{ |
