From f749a47804cd296a3059cd3f8079c62dbaa5fdc0 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 7 Aug 2026 07:26:48 +0900 Subject: refactor: merge split inherent impl blocks into one per type Enable clippy::multiple_inherent_impl and fix the 21 sites it reports. Types whose inherent methods were spread across two or three impl blocks now keep them in a single block; only the impl headers move, no method bodies change. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe/src/command/validate_command.rs | 190 ++++++++++++------------- 1 file changed, 94 insertions(+), 96 deletions(-) (limited to 'crates/shirabe/src/command/validate_command.rs') diff --git a/crates/shirabe/src/command/validate_command.rs b/crates/shirabe/src/command/validate_command.rs index 0a89b71d..c663c868 100644 --- a/crates/shirabe/src/command/validate_command.rs +++ b/crates/shirabe/src/command/validate_command.rs @@ -41,6 +41,100 @@ impl ValidateCommand { .expect("ValidateCommand::configure uses static, valid metadata"); command } + + #[allow(clippy::too_many_arguments, reason = "to keep PHP signature")] + fn output_result( + &self, + io: std::rc::Rc>, + name: &str, + errors: &mut Vec, + warnings: &mut Vec, + check_publish: bool, + publish_errors: &mut Vec, + check_lock: bool, + lock_errors: &mut Vec, + print_schema_url: bool, + ) { + let mut do_print_schema_url = false; + + if !errors.is_empty() { + io.write_error(&format!( + "{} is invalid, the following errors/warnings were found:", + name + )); + } else if !publish_errors.is_empty() && check_publish { + io.write_error(&format!( + "{} is valid for simple usage with Composer but has", + name + )); + io.write_error( + "strict errors that make it unable to be published as a package", + ); + do_print_schema_url = print_schema_url; + } else if !warnings.is_empty() { + io.write_error(&format!( + "{} is valid, but with a few warnings", + name + )); + do_print_schema_url = print_schema_url; + } else if !lock_errors.is_empty() { + io.write(&format!( + "{} is valid but your composer.lock has some {}", + name, + if check_lock { "errors" } else { "warnings" } + )); + } else { + io.write(&format!("{} is valid", name)); + } + + if do_print_schema_url { + io.write_error("See https://getcomposer.org/doc/04-schema.md for details on the schema"); + } + + if !errors.is_empty() { + *errors = errors.iter().map(|e| format!("- {}", e)).collect(); + errors.insert(0, "# General errors".to_string()); + } + if !warnings.is_empty() { + *warnings = warnings.iter().map(|w| format!("- {}", w)).collect(); + warnings.insert(0, "# General warnings".to_string()); + } + + let mut extra_warnings: Vec = vec![]; + + if !publish_errors.is_empty() && check_publish { + *publish_errors = publish_errors.iter().map(|e| format!("- {}", e)).collect(); + publish_errors.insert(0, "# Publish errors".to_string()); + errors.append(publish_errors); + } + + if !lock_errors.is_empty() { + if check_lock { + lock_errors.insert(0, "# Lock file errors".to_string()); + errors.append(lock_errors); + } else { + lock_errors.insert(0, "# Lock file warnings".to_string()); + extra_warnings.append(lock_errors); + } + } + + let all_warnings: Vec = warnings.iter().cloned().chain(extra_warnings).collect(); + + for msg in errors.iter() { + if msg.starts_with('#') { + io.write_error(&format!("{}", msg)); + } else { + io.write_error(msg); + } + } + for msg in &all_warnings { + if msg.starts_with('#') { + io.write_error(&format!("{}", msg)); + } else { + io.write_error(msg); + } + } + } } impl Command for ValidateCommand { @@ -328,99 +422,3 @@ impl BaseCommand for ValidateCommand { crate::delegate_base_command_trait_impls_to_inner!(base_command_data); } - -impl ValidateCommand { - #[allow(clippy::too_many_arguments, reason = "to keep PHP signature")] - fn output_result( - &self, - io: std::rc::Rc>, - name: &str, - errors: &mut Vec, - warnings: &mut Vec, - check_publish: bool, - publish_errors: &mut Vec, - check_lock: bool, - lock_errors: &mut Vec, - print_schema_url: bool, - ) { - let mut do_print_schema_url = false; - - if !errors.is_empty() { - io.write_error(&format!( - "{} is invalid, the following errors/warnings were found:", - name - )); - } else if !publish_errors.is_empty() && check_publish { - io.write_error(&format!( - "{} is valid for simple usage with Composer but has", - name - )); - io.write_error( - "strict errors that make it unable to be published as a package", - ); - do_print_schema_url = print_schema_url; - } else if !warnings.is_empty() { - io.write_error(&format!( - "{} is valid, but with a few warnings", - name - )); - do_print_schema_url = print_schema_url; - } else if !lock_errors.is_empty() { - io.write(&format!( - "{} is valid but your composer.lock has some {}", - name, - if check_lock { "errors" } else { "warnings" } - )); - } else { - io.write(&format!("{} is valid", name)); - } - - if do_print_schema_url { - io.write_error("See https://getcomposer.org/doc/04-schema.md for details on the schema"); - } - - if !errors.is_empty() { - *errors = errors.iter().map(|e| format!("- {}", e)).collect(); - errors.insert(0, "# General errors".to_string()); - } - if !warnings.is_empty() { - *warnings = warnings.iter().map(|w| format!("- {}", w)).collect(); - warnings.insert(0, "# General warnings".to_string()); - } - - let mut extra_warnings: Vec = vec![]; - - if !publish_errors.is_empty() && check_publish { - *publish_errors = publish_errors.iter().map(|e| format!("- {}", e)).collect(); - publish_errors.insert(0, "# Publish errors".to_string()); - errors.append(publish_errors); - } - - if !lock_errors.is_empty() { - if check_lock { - lock_errors.insert(0, "# Lock file errors".to_string()); - errors.append(lock_errors); - } else { - lock_errors.insert(0, "# Lock file warnings".to_string()); - extra_warnings.append(lock_errors); - } - } - - let all_warnings: Vec = warnings.iter().cloned().chain(extra_warnings).collect(); - - for msg in errors.iter() { - if msg.starts_with('#') { - io.write_error(&format!("{}", msg)); - } else { - io.write_error(msg); - } - } - for msg in &all_warnings { - if msg.starts_with('#') { - io.write_error(&format!("{}", msg)); - } else { - io.write_error(msg); - } - } - } -} -- cgit v1.3.1