From 9be0f98f71fe8071ab839ac1036b4064ac3172b4 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 29 Jun 2026 00:03:00 +0900 Subject: chore(lint): ban bare `use anyhow::Result` and fully qualify it Add a no_banned_use linter that forbids importing anyhow::Result, and update all call sites to reference it via its fully-qualified path so it is never confused with std::result::Result. Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/shirabe/src/util/process_executor.rs | 46 +++++++++++++++++------------ 1 file changed, 27 insertions(+), 19 deletions(-) (limited to 'crates/shirabe/src/util/process_executor.rs') diff --git a/crates/shirabe/src/util/process_executor.rs b/crates/shirabe/src/util/process_executor.rs index 230695a..463e511 100644 --- a/crates/shirabe/src/util/process_executor.rs +++ b/crates/shirabe/src/util/process_executor.rs @@ -5,7 +5,6 @@ use crate::io::IOInterfaceImmutable; use crate::io::io_interface; use crate::util::GitHub; use crate::util::Platform; -use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; use shirabe_external_packages::seld::signal::SignalHandler; @@ -170,7 +169,12 @@ impl ProcessExecutor { } /// runs a process on the commandline - pub fn execute<'o, C, O>(&mut self, command: C, output: O, cwd: Option<&str>) -> Result + pub fn execute<'o, C, O>( + &mut self, + command: C, + output: O, + cwd: Option<&str>, + ) -> anyhow::Result where C: IntoExecCommand, O: IntoExecOutput<'o>, @@ -201,7 +205,7 @@ impl ProcessExecutor { } /// runs a process on the commandline in TTY mode - pub fn execute_tty(&mut self, command: C, cwd: Option<&str>) -> Result + pub fn execute_tty(&mut self, command: C, cwd: Option<&str>) -> anyhow::Result where C: IntoExecCommand, { @@ -220,7 +224,7 @@ impl ProcessExecutor { env: Option>, tty: bool, output: O, - ) -> Result> + ) -> anyhow::Result> where O: IntoExecOutput<'o>, { @@ -302,7 +306,7 @@ impl ProcessExecutor { }), ); - let result: Result<()> = (|| -> Result<()> { + let result: anyhow::Result<()> = (|| -> anyhow::Result<()> { match output.to_callback() { Ok(callback) => { process.run(Some(callback), IndexMap::new())?; @@ -324,7 +328,7 @@ impl ProcessExecutor { self.error_output = process.get_error_output()?; Ok(()) })(); - let final_result: Result<()> = match result { + let final_result: anyhow::Result<()> = match result { Ok(()) => Ok(()), Err(e) => { if let Some(pse) = e.downcast_ref::() { @@ -352,7 +356,7 @@ impl ProcessExecutor { cwd: Option<&str>, tty: bool, output: O, - ) -> Result + ) -> anyhow::Result where O: IntoExecOutput<'o>, { @@ -409,7 +413,7 @@ impl ProcessExecutor { command: PhpMixed, cwd: Option<&str>, output: O, - ) -> Result + ) -> anyhow::Result where O: IntoExecOutput<'o>, { @@ -574,7 +578,11 @@ impl ProcessExecutor { } /// starts a process on the commandline in async mode - pub async fn execute_async(&mut self, command: C, cwd: Option<&str>) -> Result + pub async fn execute_async( + &mut self, + command: C, + cwd: Option<&str>, + ) -> anyhow::Result where C: IntoExecCommand, { @@ -677,7 +685,7 @@ impl ProcessExecutor { self.output_command_run(&command, cwd.as_deref(), true); - let process_result: Result = if is_string(&command) { + let process_result: anyhow::Result = if is_string(&command) { Process::from_shell_commandline( command.as_string().unwrap_or(""), cwd.as_deref(), @@ -760,11 +768,11 @@ impl ProcessExecutor { } /// @param ?int $index job id - pub fn wait(&mut self) -> Result<()> { + pub fn wait(&mut self) -> anyhow::Result<()> { self.wait_id(None) } - pub fn wait_id(&mut self, index: Option) -> Result<()> { + pub fn wait_id(&mut self, index: Option) -> anyhow::Result<()> { loop { if 0 == self.count_active_jobs(index)? { return Ok(()); @@ -780,7 +788,7 @@ impl ProcessExecutor { } /// @internal - pub fn count_active_jobs(&mut self, index: Option) -> Result { + pub fn count_active_jobs(&mut self, index: Option) -> anyhow::Result { // tick let ids: Vec = self.jobs.keys().copied().collect(); for id in &ids { @@ -1152,7 +1160,7 @@ pub trait IntoExecOutput<'a>: Sized { /// `Ok(callback)` for a user-supplied output handler (passed straight to `Process::run`), /// `Err(self)` for the capture/forward cases (a default handler is used and `self` is returned /// so the captured output can still be written back). - fn to_callback(self) -> Result bool>, Self>; + fn to_callback(self) -> anyhow::Result bool>, Self>; /// Assigns the captured output back to the by-reference target, mirroring PHP's /// `$output = $process->getOutput()`. Only meaningful when [`capture_output`](Self::capture_output) @@ -1167,7 +1175,7 @@ impl<'a> IntoExecOutput<'a> for () { true } - fn to_callback(self) -> Result bool>, Self> { + fn to_callback(self) -> anyhow::Result bool>, Self> { Err(self) } @@ -1181,7 +1189,7 @@ impl<'a> IntoExecOutput<'a> for ProcessForwardOutput { false } - fn to_callback(self) -> Result bool>, Self> { + fn to_callback(self) -> anyhow::Result bool>, Self> { Err(self) } @@ -1195,7 +1203,7 @@ impl<'a> IntoExecOutput<'a> for &'a mut PhpMixed { true } - fn to_callback(self) -> Result bool>, Self> { + fn to_callback(self) -> anyhow::Result bool>, Self> { Err(self) } @@ -1211,7 +1219,7 @@ impl<'a> IntoExecOutput<'a> for &'a mut String { true } - fn to_callback(self) -> Result bool>, Self> { + fn to_callback(self) -> anyhow::Result bool>, Self> { Err(self) } @@ -1228,7 +1236,7 @@ impl<'a> IntoExecOutput<'a> for Box bool> { false } - fn to_callback(self) -> Result bool>, Self> { + fn to_callback(self) -> anyhow::Result bool>, Self> { Ok(self) } -- cgit v1.3.1