refactor(clippy): apply lints

This commit is contained in:
LGUG2Z
2025-07-19 16:42:25 -07:00
parent 7839980ddf
commit 3c44f3bfdb
18 changed files with 32 additions and 36 deletions

View File

@@ -128,7 +128,7 @@ fn stop_powershell() -> Result<()> {
pub fn exec_powershell(cmd: &str) -> Result<()> {
if let Some(session_stdin) = SESSION_STDIN.lock().as_mut() {
if let Err(e) = writeln!(session_stdin, "{}", cmd) {
if let Err(e) = writeln!(session_stdin, "{cmd}") {
tracing::error!(error = %e, cmd = cmd, "failed to write command to PowerShell stdin");
return Err(e);
}
@@ -635,8 +635,7 @@ impl Komobar {
assert!(
home.is_dir(),
"$Env:KOMOREBI_CONFIG_HOME is set to '{}', which is not a valid directory",
home_path
"$Env:KOMOREBI_CONFIG_HOME is set to '{home_path}', which is not a valid directory"
);
home

View File

@@ -159,8 +159,7 @@ fn main() -> color_eyre::Result<()> {
assert!(
home.is_dir(),
"$Env:KOMOREBI_CONFIG_HOME is set to '{}', which is not a valid directory",
home_path
"$Env:KOMOREBI_CONFIG_HOME is set to '{home_path}', which is not a valid directory"
);
home

View File

@@ -181,7 +181,7 @@ impl BarWidget for Battery {
.args(["/C", "start", "ms-settings:batterysaver"])
.spawn()
{
eprintln!("{}", error)
eprintln!("{error}")
}
}
});

View File

@@ -76,8 +76,8 @@ impl Cpu {
CpuOutput {
label: match self.label_prefix {
LabelPrefix::Text | LabelPrefix::IconAndText => format!("CPU: {}%", used),
LabelPrefix::None | LabelPrefix::Icon => format!("{}%", used),
LabelPrefix::Text | LabelPrefix::IconAndText => format!("CPU: {used}%"),
LabelPrefix::None | LabelPrefix::Icon => format!("{used}%"),
},
selected,
}
@@ -124,7 +124,7 @@ impl BarWidget for Cpu {
if let Err(error) =
Command::new("cmd.exe").args(["/C", "taskmgr.exe"]).spawn()
{
eprintln!("{}", error)
eprintln!("{error}")
}
}
});

View File

@@ -166,7 +166,7 @@ impl Date {
.to_string()
.trim()
.to_string(),
Err(_) => format!("Invalid timezone: {}", timezone),
Err(_) => format!("Invalid timezone: {timezone}"),
},
None => Local::now()
.format(&self.format.fmt_string())

View File

@@ -41,8 +41,7 @@ impl<'de> Deserialize<'de> for KomorebiLayout {
let s: String = String::deserialize(deserializer)?;
// Attempt to deserialize the string as a DefaultLayout
if let Ok(default_layout) =
from_str::<komorebi_client::DefaultLayout>(&format!("\"{}\"", s))
if let Ok(default_layout) = from_str::<komorebi_client::DefaultLayout>(&format!("\"{s}\""))
{
return Ok(KomorebiLayout::Default(default_layout));
}
@@ -53,7 +52,7 @@ impl<'de> Deserialize<'de> for KomorebiLayout {
"Floating" => Ok(KomorebiLayout::Floating),
"Paused" => Ok(KomorebiLayout::Paused),
"Custom" => Ok(KomorebiLayout::Custom),
_ => Err(Error::custom(format!("Invalid layout: {}", s))),
_ => Err(Error::custom(format!("Invalid layout: {s}"))),
}
}
}

View File

@@ -79,9 +79,9 @@ impl Memory {
MemoryOutput {
label: match self.label_prefix {
LabelPrefix::Text | LabelPrefix::IconAndText => {
format!("RAM: {}%", usage)
format!("RAM: {usage}%")
}
LabelPrefix::None | LabelPrefix::Icon => format!("{}%", usage),
LabelPrefix::None | LabelPrefix::Icon => format!("{usage}%"),
},
selected,
}
@@ -128,7 +128,7 @@ impl BarWidget for Memory {
if let Err(error) =
Command::new("cmd.exe").args(["/C", "taskmgr.exe"]).spawn()
{
eprintln!("{}", error)
eprintln!("{error}")
}
}
});

View File

@@ -314,7 +314,7 @@ impl Network {
.clicked()
{
if let Err(error) = Command::new("cmd.exe").args(["/C", "ncpa"]).spawn() {
eprintln!("{}", error);
eprintln!("{error}");
}
}
}
@@ -535,6 +535,6 @@ enum DataUnit {
impl fmt::Display for DataUnit {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self)
write!(f, "{self:?}")
}
}

View File

@@ -87,7 +87,7 @@ impl Storage {
LabelPrefix::Text | LabelPrefix::IconAndText => {
format!("{} {}%", mount.to_string_lossy(), percentage)
}
LabelPrefix::None | LabelPrefix::Icon => format!("{}%", percentage),
LabelPrefix::None | LabelPrefix::Icon => format!("{percentage}%"),
},
selected,
})
@@ -151,7 +151,7 @@ impl BarWidget for Storage {
])
.spawn()
{
eprintln!("{}", error)
eprintln!("{error}")
}
}
});

View File

@@ -209,7 +209,7 @@ impl Time {
Some(dt.time()),
)
}
Err(_) => (format!("Invalid timezone: {:?}", timezone), None),
Err(_) => (format!("Invalid timezone: {timezone:?}"), None),
},
None => {
let dt = Local::now();

View File

@@ -148,7 +148,7 @@ impl BarWidget for Update {
)])
.spawn()
{
eprintln!("{}", error)
eprintln!("{error}")
}
}
});

View File

@@ -17,5 +17,5 @@ pub enum AnimationPrefix {
}
pub fn new_animation_key(prefix: AnimationPrefix, key: String) -> String {
format!("{}:{}", prefix, key)
format!("{prefix}:{key}")
}

View File

@@ -302,7 +302,7 @@ mod tests {
let deserialized: Container =
serde_json::from_str(&serialized).expect("Should deserialize");
assert_eq!(deserialized.locked(), true);
assert!(deserialized.locked());
assert_eq!(deserialized.id(), container.id());
}
}

View File

@@ -200,8 +200,7 @@ lazy_static! {
assert!(
home.is_dir(),
"$Env:KOMOREBI_CONFIG_HOME is set to '{}', which is not a valid directory",
home_path
"$Env:KOMOREBI_CONFIG_HOME is set to '{home_path}', which is not a valid directory"
);

View File

@@ -331,12 +331,12 @@ mod tests {
let mut ring = test_deque(&[(0, false), (1, true), (2, false), (3, false)]);
ring.swap_respecting_locks(0, 1);
assert_eq!(vals(&ring), vec![1, 0, 2, 3]);
assert_eq!(ring[0].locked, false);
assert_eq!(ring[1].locked, true);
assert!(!ring[0].locked);
assert!(ring[1].locked);
ring.swap_respecting_locks(0, 1);
assert_eq!(vals(&ring), vec![0, 1, 2, 3]);
assert_eq!(ring[0].locked, false);
assert_eq!(ring[1].locked, true);
assert!(!ring[0].locked);
assert!(ring[1].locked);
// Both locked
let mut ring = test_deque(&[(0, true), (1, false), (2, true)]);

View File

@@ -801,7 +801,7 @@ mod tests {
let wm = match WindowManager::new(receiver, Some(socket_path.clone())) {
Ok(manager) => manager,
Err(e) => {
panic!("Failed to create WindowManager: {}", e);
panic!("Failed to create WindowManager: {e}");
}
};
@@ -829,7 +829,7 @@ mod tests {
Ok(notification) => {
assert_eq!(notification, MonitorNotification::ResolutionScalingChanged);
}
Err(e) => panic!("Failed to receive MonitorNotification: {}", e),
Err(e) => panic!("Failed to receive MonitorNotification: {e}"),
}
}
@@ -849,7 +849,7 @@ mod tests {
for _ in 0..20 {
let notification = match receiver.try_recv() {
Ok(notification) => notification,
Err(e) => panic!("Failed to receive MonitorNotification: {}", e),
Err(e) => panic!("Failed to receive MonitorNotification: {e}"),
};
assert_eq!(
notification,
@@ -960,7 +960,7 @@ mod tests {
Ok(notification) => {
assert_eq!(notification, MonitorNotification::DisplayConnectionChange);
}
Err(e) => panic!("Failed to receive MonitorNotification: {}", e),
Err(e) => panic!("Failed to receive MonitorNotification: {e}"),
}
}

View File

@@ -1180,6 +1180,7 @@ impl WindowsApi {
#[allow(dead_code)]
pub fn enable_focus_follows_mouse() -> Result<()> {
#[allow(clippy::manual_dangling_ptr)]
Self::system_parameters_info_w(
SPI_SETACTIVEWINDOWTRACKING,
0,

View File

@@ -92,8 +92,7 @@ lazy_static! {
assert!(
whkd_config_home.is_dir(),
"$Env:WHKD_CONFIG_HOME is set to '{}', which is not a valid directory",
home_path
"$Env:WHKD_CONFIG_HOME is set to '{home_path}', which is not a valid directory"
);
whkd_config_home