Skip to content

Commit a0a1abf

Browse files
Brooooooklynclaude
andauthored
style: fix clippy::missing_errors_doc (#225)
Add # Errors documentation sections to public functions that return Result: - Exec::resolve() - Documents PATH search and shebang parsing errors - ensure_env() - Documents EINVAL on conflicting env values - decode_payload_from_env() - Documents env var, base64, and bincode errors - PreExec::run() - Documents infallible nature - handle_exec() - Documents resolution and env operation errors 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent dd43e1e commit a0a1abf

6 files changed

Lines changed: 42 additions & 3 deletions

File tree

crates/fspy_shared_unix/src/exec/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ impl Exec {
8282
///
8383
/// * `Ok(())` if resolution succeeds and `self` is updated with resolved paths
8484
/// * `Err(nix::Error)` with appropriate errno, like the exec function would return
85+
///
86+
/// # Errors
87+
///
88+
/// Returns an error if:
89+
/// - The program is not found in PATH (`ENOENT`)
90+
/// - The program file cannot be accessed or read (`EACCES`, `EISDIR`, `EIO`)
91+
/// - Shebang parsing fails due to I/O errors (`EIO`)
8592
pub fn resolve(
8693
&mut self,
8794
mut on_path_access: impl FnMut(PathAccess<'_>),
@@ -134,6 +141,14 @@ impl Exec {
134141
}
135142
}
136143

144+
/// Ensures an environment variable is set to the specified value
145+
///
146+
/// If the variable doesn't exist, it is added. If it exists with the same value,
147+
/// no change is made. If it exists with a different value, an error is returned.
148+
///
149+
/// # Errors
150+
///
151+
/// Returns `Err(nix::Error::EINVAL)` if the environment variable already exists with a different value.
137152
pub fn ensure_env(
138153
envs: &mut Vec<(BString, Option<BString>)>,
139154
name: impl AsRef<BStr>,

crates/fspy_shared_unix/src/payload.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ pub fn encode_payload(payload: Payload) -> EncodedPayload {
3838
EncodedPayload { payload, encoded_string: encoded_string.into() }
3939
}
4040

41+
/// Decodes the fspy payload from the environment variable
42+
///
43+
/// # Errors
44+
///
45+
/// Returns an error if:
46+
/// - The environment variable is not found
47+
/// - The base64 decoding fails
48+
/// - The bincode deserialization fails
4149
pub fn decode_payload_from_env() -> anyhow::Result<EncodedPayload> {
4250
let Some(encoded_string) = std::env::var_os(PAYLOAD_ENV_NAME) else {
4351
anyhow::bail!("Environment variable '{}' not found", PAYLOAD_ENV_NAME);

crates/fspy_shared_unix/src/spawn/macos.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ use crate::{
1515

1616
pub struct PreExec(Infallible);
1717
impl PreExec {
18+
/// Runs pre-exec operations
19+
///
20+
/// # Errors
21+
///
22+
/// This function never returns an error as the type is `Infallible`
1823
pub fn run(&self) -> nix::Result<()> {
1924
match self.0 {}
2025
}

crates/fspy_shared_unix/src/spawn/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ use crate::{
1818
payload::EncodedPayload,
1919
};
2020

21+
/// Handles exec command resolution and injection
22+
///
23+
/// Resolves the program path and prepares the command for execution with
24+
/// appropriate environment variables and hooks.
25+
///
26+
/// # Errors
27+
///
28+
/// Returns an error if:
29+
/// - Program resolution fails (see [`Exec::resolve`] error variants, such as `ENOENT` (file not found) or `EACCES` (permission denied))
30+
/// - Environment variable operations fail (e.g., `ensure_env` may return `EINVAL` if an existing value conflicts)
31+
/// - Platform-specific errors from `os_specific::handle_exec`
2132
pub fn handle_exec(
2233
command: &mut Exec,
2334
config: ExecResolveConfig,

crates/vite_task/src/config/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,10 @@ impl std::fmt::Debug for ResolvedTaskCommand {
261261
///
262262
/// # Fingerprint Ignores Impact on Cache
263263
///
264-
/// The `fingerprint_ignores` field controls which files are tracked in PostRunFingerprint:
264+
/// The `fingerprint_ignores` field controls which files are tracked in `PostRunFingerprint`:
265265
/// - Changes to this config must invalidate the cache
266266
/// - Vec maintains insertion order (pattern order matters for last-match-wins semantics)
267-
/// - Even though ignore patterns only affect PostRunFingerprint, the config itself is part of the cache key
267+
/// - Even though ignore patterns only affect `PostRunFingerprint`, the config itself is part of the cache key
268268
#[derive(Encode, Decode, Debug, Serialize, Deserialize, PartialEq, Eq, Diff, Clone)]
269269
#[diff(attr(#[derive(Debug)]))]
270270
pub struct CommandFingerprint {

crates/vite_task/src/fingerprint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl PostRunFingerprint {
9999
.par_iter()
100100
.filter(|(path, _)| {
101101
// Filter out paths that match ignore patterns
102-
ignore_matcher.as_ref().map_or(true, |matcher| !matcher.is_match(path))
102+
ignore_matcher.as_ref().is_none_or(|matcher| !matcher.is_match(path))
103103
})
104104
.flat_map(|(path, path_read)| {
105105
Some((|| {

0 commit comments

Comments
 (0)