From c839244d8d09f3036ebfee8eef7eb6b147e593ab Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 19 May 2026 00:10:22 +0900 Subject: fix(compile): fix various compile errors Co-Authored-By: Claude Sonnet 4.6 --- crates/shirabe/src/advisory/auditor.rs | 145 ++++++++++++--------------------- 1 file changed, 50 insertions(+), 95 deletions(-) (limited to 'crates/shirabe/src/advisory/auditor.rs') diff --git a/crates/shirabe/src/advisory/auditor.rs b/crates/shirabe/src/advisory/auditor.rs index e1b40c2..68bedb0 100644 --- a/crates/shirabe/src/advisory/auditor.rs +++ b/crates/shirabe/src/advisory/auditor.rs @@ -70,7 +70,7 @@ impl Auditor { /// @throws InvalidArgumentException If no packages are passed in pub fn audit( &self, - io: &dyn IOInterface, + io: &mut dyn IOInterface, repo_set: &RepositorySet, packages: Vec>, format: &str, @@ -170,17 +170,13 @@ impl Auditor { ), ); - io.write( - PhpMixed::String(JsonFile::encode( - &PhpMixed::Array(json.into_iter().map(|(k, v)| (k, Box::new(v))).collect()), - shirabe_php_shim::JSON_UNESCAPED_SLASHES - | shirabe_php_shim::JSON_PRETTY_PRINT - | shirabe_php_shim::JSON_UNESCAPED_UNICODE, - JsonFile::INDENT_DEFAULT, - )), - true, - io_interface::NORMAL, - ); + io.write(&JsonFile::encode_with_indent( + &PhpMixed::Array(json.into_iter().map(|(k, v)| (k, Box::new(v))).collect()), + shirabe_php_shim::JSON_UNESCAPED_SLASHES + | shirabe_php_shim::JSON_PRETTY_PRINT + | shirabe_php_shim::JSON_UNESCAPED_UNICODE, + JsonFile::INDENT_DEFAULT, + )); return Ok(audit_bitmask); } @@ -214,57 +210,31 @@ impl Auditor { }; let pkg_plurality = if pkg_count == 1 { "" } else { "s" }; let punctuation = if format == "summary" { "." } else { ":" }; - io.write_error( - PhpMixed::String(sprintf( - &message, - &[ - PhpMixed::Int(total_advisory_count), - PhpMixed::String(plurality.to_string()), - PhpMixed::Int(pkg_count), - PhpMixed::String(pkg_plurality.to_string()), - PhpMixed::String(punctuation.to_string()), - ], - )), - true, - io_interface::NORMAL, - ); + io.write_error(&sprintf( + &message, + &[ + PhpMixed::Int(total_advisory_count), + PhpMixed::String(plurality.to_string()), + PhpMixed::Int(pkg_count), + PhpMixed::String(pkg_plurality.to_string()), + PhpMixed::String(punctuation.to_string()), + ], + )); self.output_advisories(io, advisories_to_output, format)?; } } if format == Self::FORMAT_SUMMARY { - io.write_error( - PhpMixed::String( - "Run \"composer audit\" for a full list of advisories.".to_string(), - ), - true, - io_interface::NORMAL, - ); + io.write_error("Run \"composer audit\" for a full list of advisories."); } } else { - io.write_error( - PhpMixed::String( - "No security vulnerability advisories found.".to_string(), - ), - true, - io_interface::NORMAL, - ); + io.write_error("No security vulnerability advisories found."); } if !unreachable_repos.is_empty() { - io.write_error( - PhpMixed::String( - "The following repositories were unreachable:".to_string(), - ), - true, - io_interface::NORMAL, - ); + io.write_error("The following repositories were unreachable:"); for repo in &unreachable_repos { - io.write_error( - PhpMixed::String(format!(" - {}", repo)), - true, - io_interface::NORMAL, - ); + io.write_error(&format!(" - {}", repo)); } } @@ -458,7 +428,7 @@ impl Auditor { /// @param self::FORMAT_* $format The format that will be used to output audit results. fn output_advisories( &self, - io: &dyn IOInterface, + io: &mut dyn IOInterface, advisories: &IndexMap>, format: &str, ) -> Result<()> { @@ -534,8 +504,8 @@ impl Auditor { } let _ = row; io.get_table() - .set_horizontal() - .set_headers(headers) + .set_horizontal(true) + .set_headers(headers.into_iter().map(|h| h.into()).collect()) .add_row(ConsoleIO::sanitize(PhpMixed::Null, false)) .set_column_width(1, 80) .set_column_max_width(1, 80) @@ -547,7 +517,7 @@ impl Auditor { /// @param array> $advisories fn output_advisories_plain( &self, - io: &dyn IOInterface, + io: &mut dyn IOInterface, advisories: &IndexMap>, ) { let mut error: Vec = vec![]; @@ -596,41 +566,30 @@ impl Auditor { first_advisory = false; } } - io.write_error( - PhpMixed::List( - error - .into_iter() - .map(|s| Box::new(PhpMixed::String(s))) - .collect(), - ), - true, - io_interface::NORMAL, - ); + for line in &error { + io.write_error(line); + } } /// @param array $packages /// @param self::FORMAT_PLAIN|self::FORMAT_TABLE $format fn output_abandoned_packages( &self, - io: &dyn IOInterface, + io: &mut dyn IOInterface, packages: &[Box], format: &str, ) -> Result<()> { - io.write_error( - PhpMixed::String(sprintf( - "Found %d abandoned package%s:", - &[ - PhpMixed::Int(packages.len() as i64), - PhpMixed::String(if packages.len() > 1 { - "s".to_string() - } else { - String::new() - }), - ], - )), - true, - io_interface::NORMAL, - ); + io.write_error(&sprintf( + "Found %d abandoned package%s:", + &[ + PhpMixed::Int(packages.len() as i64), + PhpMixed::String(if packages.len() > 1 { + "s".to_string() + } else { + String::new() + }), + ], + )); if format == Self::FORMAT_PLAIN { for pkg in packages { @@ -639,17 +598,13 @@ impl Auditor { } else { "No replacement was suggested".to_string() }; - io.write_error( - PhpMixed::String(sprintf( - "%s is abandoned. %s.", - &[ - PhpMixed::String(self.get_package_name_with_link_for_complete(pkg)), - PhpMixed::String(replacement), - ], - )), - true, - io_interface::NORMAL, - ); + io.write_error(&sprintf( + "%s is abandoned. %s.", + &[ + PhpMixed::String(self.get_package_name_with_link_for_complete(pkg)), + PhpMixed::String(replacement), + ], + )); } return Ok(()); @@ -672,8 +627,8 @@ impl Auditor { .unwrap() .get_table() .set_headers(vec![ - "Abandoned Package".to_string(), - "Suggested Replacement".to_string(), + "Abandoned Package".to_string().into(), + "Suggested Replacement".to_string().into(), ]) .set_column_width(1, 80) .set_column_max_width(1, 80); -- cgit v1.3.1