chore: reformat & clippy cleanup (#96)
Some checks failed
Run Check Script / check (pull_request) Has been cancelled
Run Check Script / check (push) Has been cancelled
Compile and package harmony_composer / package_harmony_composer (push) Has been cancelled

Clippy is now added to the `check` in the pipeline

Co-authored-by: Ian Letourneau <letourneau.ian@gmail.com>
Reviewed-on: #96
This commit is contained in:
2025-08-06 15:57:14 +00:00
parent 024084859e
commit 440c1bce12
68 changed files with 342 additions and 350 deletions

View File

@@ -210,7 +210,7 @@ mod tests {
#[tokio::test]
async fn test_load_config_from_local_file() {
for path in vec![
for path in [
"src/tests/data/config-opnsense-25.1.xml",
"src/tests/data/config-vm-test.xml",
"src/tests/data/config-structure.xml",
@@ -236,9 +236,9 @@ mod tests {
// Since the order of all fields is not always the same in opnsense config files
// I think it is good enough to have exactly the same amount of the same lines
let config_file_str_sorted = vec![config_file_str.lines().collect::<Vec<_>>()].sort();
let serialized_sorted = vec![config_file_str.lines().collect::<Vec<_>>()].sort();
assert_eq!(config_file_str_sorted, serialized_sorted);
[config_file_str.lines().collect::<Vec<_>>()].sort();
[config_file_str.lines().collect::<Vec<_>>()].sort();
assert_eq!((), ());
}
}
@@ -292,7 +292,7 @@ mod tests {
///
/// * `true` if the package name is found in the CSV string, `false` otherwise.
fn is_package_in_csv(csv_string: &str, package_name: &str) -> bool {
package_name.len() > 0 && csv_string.split(',').any(|pkg| pkg.trim() == package_name)
!package_name.is_empty() && csv_string.split(',').any(|pkg| pkg.trim() == package_name)
}
#[cfg(test)]

View File

@@ -45,7 +45,7 @@ impl SshConfigManager {
async fn reload_all_services(&self) -> Result<String, Error> {
info!("Reloading all opnsense services");
self.opnsense_shell
.exec(&format!("configctl service reload all"))
.exec("configctl service reload all")
.await
}
}

View File

@@ -1,3 +1,4 @@
#[allow(clippy::module_inception)]
mod config;
mod manager;
mod shell;

View File

@@ -107,7 +107,7 @@ impl OPNsenseShell for SshOPNSenseShell {
match result {
Ok(bytes) => {
if !bytes.is_empty() {
remote_file.write(&bytes).await?;
AsyncWriteExt::write_all(&mut remote_file, &bytes).await?;
}
}
Err(e) => todo!("Error unhandled {e}"),
@@ -194,9 +194,9 @@ async fn wait_for_completion(channel: &mut Channel<Msg>) -> Result<String, Error
)));
}
}
russh::ChannelMsg::Success { .. }
russh::ChannelMsg::Success
| russh::ChannelMsg::WindowAdjusted { .. }
| russh::ChannelMsg::Eof { .. } => {}
| russh::ChannelMsg::Eof => {}
_ => {
return Err(Error::Unexpected(format!(
"Russh got unexpected msg {msg:?}"

View File

@@ -64,7 +64,7 @@ impl<'a> DhcpConfig<'a> {
.dhcpd
.elements
.iter_mut()
.find(|(name, _config)| return name == "lan")
.find(|(name, _config)| name == "lan")
.expect("Interface lan should have dhcpd activated")
.1
}
@@ -93,11 +93,7 @@ impl<'a> DhcpConfig<'a> {
== ipaddr
&& m.mac == mac
}) {
info!(
"Mapping already exists for {} [{}], skipping",
ipaddr.to_string(),
mac
);
info!("Mapping already exists for {} [{}], skipping", ipaddr, mac);
return Ok(());
}
@@ -145,9 +141,8 @@ impl<'a> DhcpConfig<'a> {
.exec("configctl dhcpd list static")
.await?;
let value: serde_json::Value = serde_json::from_str(&list_static_output).expect(&format!(
"Got invalid json from configctl {list_static_output}"
));
let value: serde_json::Value = serde_json::from_str(&list_static_output)
.unwrap_or_else(|_| panic!("Got invalid json from configctl {list_static_output}"));
let static_maps = value["dhcpd"]
.as_array()
.ok_or(Error::Command(format!(