Skip to content

Commit d05bee6

Browse files
committed
fix: gate platform-specific imports with cfg attributes
Prevents unused import/variable clippy warnings on Linux CI where macOS-only code paths are compiled out.
1 parent 6ef1bf6 commit d05bee6

5 files changed

Lines changed: 21 additions & 6 deletions

File tree

src/cleaners/electron.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@
99
//! - Figma
1010
//! - And many more Electron/Chromium apps
1111
12-
use super::{calculate_dir_size, get_mtime, CleanableItem, SafetyLevel};
12+
#[cfg(target_os = "macos")]
13+
use super::get_mtime;
14+
use super::{calculate_dir_size, CleanableItem, SafetyLevel};
1315
use crate::error::Result;
1416
use std::borrow::Cow;
1517
use std::path::PathBuf;
1618

1719
/// Extra cache bundle IDs that don't follow the standard naming pattern.
1820
/// Maps Application Support folder name → known ~/Library/Caches/ bundle ID.
21+
#[cfg(target_os = "macos")]
1922
const EXTRA_CACHE_BUNDLE_IDS: &[(&str, &str)] = &[
2023
("Spotify", "com.spotify.client"),
2124
("discord", "com.hnc.Discord"),

src/cleaners/ide.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
//! - Sublime Text
77
//! - Cursor
88
9-
use super::{calculate_dir_size, get_mtime, CleanableItem, SafetyLevel};
9+
#[cfg(target_os = "macos")]
10+
use super::get_mtime;
11+
use super::{calculate_dir_size, CleanableItem, SafetyLevel};
1012
use crate::error::Result;
1113
use std::borrow::Cow;
1214
use std::path::PathBuf;
@@ -487,6 +489,7 @@ impl IdeCleaner {
487489

488490
/// Detect Zed editor caches
489491
fn detect_zed(&self) -> Result<Vec<CleanableItem>> {
492+
#[allow(unused_mut)]
490493
let mut items = Vec::new();
491494

492495
#[cfg(target_os = "macos")]

src/cleaners/logs.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
//! - Development tool logs
77
//! - Crash reports
88
9-
use super::{calculate_dir_size, get_mtime, CleanableItem, SafetyLevel};
9+
#[cfg(target_os = "macos")]
10+
use super::get_mtime;
11+
use super::{calculate_dir_size, CleanableItem, SafetyLevel};
1012
use crate::error::Result;
1113
use std::borrow::Cow;
1214
use std::path::PathBuf;
@@ -190,6 +192,7 @@ impl LogsCleaner {
190192

191193
/// Detect crash reports
192194
fn detect_crash_reports(&self) -> Result<Vec<CleanableItem>> {
195+
#[allow(unused_mut)]
193196
let mut items = Vec::new();
194197

195198
#[cfg(target_os = "macos")]

src/cleaners/macos.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@
66
//! - Application support remnants
77
//! - System caches
88
9+
#[cfg(target_os = "macos")]
910
use super::{calculate_dir_size, get_mtime, CleanableItem, SafetyLevel};
11+
#[cfg(target_os = "macos")]
1012
use crate::error::Result;
13+
#[cfg(target_os = "macos")]
1114
use std::borrow::Cow;
15+
#[cfg(target_os = "macos")]
1216
use std::collections::HashSet;
17+
#[cfg(target_os = "macos")]
1318
use std::path::PathBuf;
1419

1520
/// macOS system cleaner

src/cleaners/xcode.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@ pub struct XcodeCleaner {
2020
impl XcodeCleaner {
2121
/// Create a new Xcode cleaner
2222
pub fn new() -> Option<Self> {
23-
let home = dirs::home_dir()?;
24-
2523
// Only available on macOS
2624
#[cfg(not(target_os = "macos"))]
2725
return None;
2826

2927
#[cfg(target_os = "macos")]
30-
Some(Self { home })
28+
{
29+
let home = dirs::home_dir()?;
30+
Some(Self { home })
31+
}
3132
}
3233

3334
/// Detect all Xcode cleanable items

0 commit comments

Comments
 (0)