Skip to content

Commit 7e15112

Browse files
fix: resolve clippy warnings in ironposh-psrp and ironposh-winrm
1 parent 99be778 commit 7e15112

File tree

12 files changed

+33
-58
lines changed

12 files changed

+33
-58
lines changed

crates/ironposh-psrp/examples/analyze.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
316316
// Check for --multi flag for defragmentation
317317
if args.len() > 2 && args[1] == "--multi" {
318318
print_separator("MULTI-FRAGMENT DEFRAGMENTATION MODE");
319-
let fragments: Vec<&str> = args[2..].iter().map(|s| s.as_str()).collect();
319+
let fragments: Vec<&str> = args[2..].iter().map(String::as_str).collect();
320320

321321
match try_defragment_multiple_messages(&fragments) {
322322
Ok(messages) => {
@@ -464,7 +464,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
464464

465465
if !fragments.is_empty() {
466466
let fragment_refs: Vec<&str> =
467-
fragments.iter().map(|s| s.as_str()).collect();
467+
fragments.iter().map(String::as_str).collect();
468468
match try_defragment_multiple_messages(&fragment_refs) {
469469
Ok(messages) => {
470470
if messages.is_empty() {

crates/ironposh-psrp/src/fragmentation/tests.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1-
use super::*;
2-
use crate::messages::{
3-
ApartmentState, ApplicationArguments, InitRunspacePool, PSThreadOptions, SessionCapability,
4-
};
5-
use tracing::info;
6-
use tracing_test::traced_test;
7-
use uuid::Uuid;
8-
9-
#[cfg(test)]
10-
#[cfg(disabled_temporarily)] // Disabled due to from_crossterm compilation issues
1+
// Disabled due to from_crossterm compilation issues - uses `cfg(any())` which is always false
2+
#[cfg(any())]
113
mod tests {
124
use crate::messages::{HostDefaultData, HostInfo};
135

crates/ironposh-psrp/src/tests/command_xml_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ mod tests {
262262
// Convert back to ComplexObject
263263
let recreated_obj = ComplexObject::from(create_pipeline.clone());
264264

265-
let xml = PsValue::Object(recreated_obj.clone())
265+
let xml = PsValue::Object(recreated_obj)
266266
.to_element_as_root()
267267
.unwrap()
268268
.to_xml_string()

crates/ironposh-psrp/src/tests/creation_xml.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
1-
use crate::{
2-
HostDefaultData, HostInfo,
3-
fragmentation::{DefragmentResult, Defragmenter, Fragmenter},
4-
messages::{
5-
ApartmentState, ApplicationArguments, InitRunspacePool, PSThreadOptions, SessionCapability,
6-
},
7-
};
8-
9-
use tracing::info;
10-
use tracing_test::traced_test;
11-
use uuid::Uuid;
12-
1+
// Disabled due to from_crossterm compilation issues - uses `cfg(any())` which is always false
2+
#[cfg(any())]
133
#[test]
14-
#[cfg(disabled_temporarily)] // Disabled due to from_crossterm compilation issues
15-
#[traced_test]
4+
#[tracing_test::traced_test]
165
fn test_combined_messages_like_runspace_open() {
176
// Test the exact scenario from RunspacePool::open()
187
let session_capability = SessionCapability {

crates/ironposh-psrp/src/tests/creation_xml_roundtrip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ fn test_creation_xml_roundtrip() {
144144
if e.to_string().contains("Object reference") {
145145
println!(
146146
" (This is expected for messages with object references - serialization needs reference preservation)"
147-
)
147+
);
148148
} else {
149149
println!(" (Unexpected error - investigate further)");
150150
}

crates/ironposh-psrp/src/tests/error_record_test.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#[cfg(test)]
22
mod error_record_integration_tests {
33
use crate::ps_value::{
4-
ComplexObject, ComplexObjectContent, PsPrimitiveValue, PsProperty, PsType, PsValue,
4+
ComplexObject, ComplexObjectContent, PsPrimitiveValue, PsProperty, PsValue,
55
};
66
use crate::{ErrorCategory, ErrorRecord};
77
use std::collections::BTreeMap;
@@ -26,9 +26,8 @@ mod error_record_integration_tests {
2626
.expect("Should successfully deserialize XML to PsValue");
2727

2828
// Extract the ComplexObject from PsValue
29-
let complex_object = match ps_value {
30-
PsValue::Object(obj) => obj,
31-
_ => panic!("Expected PsValue::Object from XML parsing"),
29+
let PsValue::Object(complex_object) = ps_value else {
30+
panic!("Expected PsValue::Object from XML parsing")
3231
};
3332

3433
println!("✅ Successfully parsed XML into ComplexObject");
@@ -86,7 +85,7 @@ mod error_record_integration_tests {
8685
);
8786
}
8887
Err(e) => {
89-
panic!("❌ Failed to parse ErrorRecord: {}", e);
88+
panic!("❌ Failed to parse ErrorRecord: {e}");
9089
}
9190
}
9291
}
@@ -192,7 +191,7 @@ mod error_record_integration_tests {
192191
.serialize_extended_info(false)
193192
.error_category(Some(ErrorCategory::builder()
194193
.category(13)
195-
.activity(Some("".to_string()))
194+
.activity(Some(String::new()))
196195
.reason(Some("CommandNotFoundException".to_string()))
197196
.target_name(Some("ed".to_string()))
198197
.target_type(Some("String".to_string()))

crates/ironposh-psrp/src/tests/exact_xml_tests.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ fn test_runspace_pool_message() {
155155
let mut host_data_dict = BTreeMap::new();
156156

157157
// Add dictionary entries for host data
158-
for (key, value_type, value_obj) in [
158+
for (key, _value_type, value_obj) in [
159159
(
160160
9,
161161
"System.String",
@@ -839,13 +839,9 @@ fn test_deserialize_dictionary_xml() {
839839
assert_eq!(dict.len(), 2);
840840

841841
// Verify we have the expected entries
842-
let has_int_key = dict.keys().any(|k| {
843-
if let PsValue::Primitive(PsPrimitiveValue::I32(9)) = k {
844-
true
845-
} else {
846-
false
847-
}
848-
});
842+
let has_int_key = dict
843+
.keys()
844+
.any(|k| matches!(k, PsValue::Primitive(PsPrimitiveValue::I32(9))));
849845
assert!(has_int_key, "Should have integer key 9");
850846

851847
let has_string_key = dict.keys().any(|k| {

crates/ironposh-psrp/src/tests/parse_real_pipeline_output.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,13 @@ fn test_parse_real_pipeline_output_detailed_inspection() {
234234
match &obj.content {
235235
ComplexObjectContent::Standard => println!("\nContent: Standard"),
236236
ComplexObjectContent::ExtendedPrimitive(prim) => {
237-
println!("\nContent: ExtendedPrimitive({prim:?})")
237+
println!("\nContent: ExtendedPrimitive({prim:?})");
238238
}
239239
ComplexObjectContent::Container(container) => {
240240
println!("\nContent: Container({container:?})");
241241
}
242242
ComplexObjectContent::PsEnums(enums) => {
243-
println!("\nContent: Enum({})", enums.value)
243+
println!("\nContent: Enum({})", enums.value);
244244
}
245245
}
246246
}
@@ -259,8 +259,7 @@ fn classify_ps_value(value: &PsValue) -> String {
259259
.type_def
260260
.as_ref()
261261
.and_then(|t| t.type_names.first())
262-
.map(|s| s.as_ref())
263-
.unwrap_or("Unknown");
262+
.map_or("Unknown", AsRef::as_ref);
264263

265264
let content_type = match &obj.content {
266265
ComplexObjectContent::Standard => "Standard",

crates/ironposh-psrp/tests/test_psrp_message_edge_cases.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,7 @@ mod tests {
307307

308308
assert!(
309309
result.is_ok(),
310-
"Message type {:?} should parse: {result:?}",
311-
msg_type
310+
"Message type {msg_type:?} should parse: {result:?}"
312311
);
313312

314313
let msg = result.unwrap();

crates/ironposh-winrm/src/test_macro.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ mod tests {
3434
// The TagValue implementation worked if we got here without panicking
3535

3636
// Test deserialization with a simple XML string
37-
let test_xml = r#"<test>
37+
let test_xml = r"<test>
3838
<Action>test-action</Action>
3939
<MessageID>msg-123</MessageID>
4040
<To>destination</To>
41-
</test>"#;
41+
</test>";
4242

4343
// Parse the XML back
4444
let doc = ironposh_xml::parser::parse(test_xml).expect("Failed to parse XML");

0 commit comments

Comments
 (0)