diff --git a/src/network_management/name.rs b/src/network_management/name.rs index 37372a1..d8ba1a9 100644 --- a/src/network_management/name.rs +++ b/src/network_management/name.rs @@ -1,5 +1,4 @@ // Copyright 2023 Raven Industries inc. -#![allow(dead_code)] const DEFAULT_NAME: u64 = 0xFFFFFFFFFFFFFFFF; #[derive(PartialEq, Eq, Clone, Copy)] @@ -33,6 +32,7 @@ impl NAME { Self { raw_name } } + #[allow(clippy::too_many_arguments)] pub fn build( short_identity_number: u16, extended_identity_number: u8, @@ -61,7 +61,7 @@ impl NAME { pub fn check_mask(name_to_check: &NAME, name_fields: &Vec) -> bool { let mut matched = false; - if (0 != name_fields.len()) && (DEFAULT_NAME != name_to_check.raw_name) { + if (!name_fields.is_empty()) && (DEFAULT_NAME != name_to_check.raw_name) { matched = true; for field in name_fields { @@ -205,7 +205,7 @@ impl NAME { } } } - return matched; + matched } pub fn get_device_class(&self) -> u8 { @@ -326,7 +326,7 @@ mod tests { name_under_test.set_device_class_instance(7); name_under_test.set_manufacturer_code(8); - assert_eq!(true, name_under_test.get_self_configurable_address()); + assert!(name_under_test.get_self_configurable_address()); assert_eq!(1, name_under_test.get_industry_group()); assert_eq!(2, name_under_test.get_device_class()); assert_eq!(3, name_under_test.get_function()); @@ -388,9 +388,9 @@ mod tests { }; filters_to_test.push(identity_number_filter); - assert_eq!(false, NAME::check_mask(&test_name, &filters_to_test)); + assert!(!NAME::check_mask(&test_name, &filters_to_test)); test_name.set_identity_number(1); - assert_eq!(true, NAME::check_mask(&test_name, &filters_to_test)); + assert!(NAME::check_mask(&test_name, &filters_to_test)); let manufacturer_number_filter = NameFieldValue { value: 2, @@ -398,9 +398,9 @@ mod tests { }; filters_to_test.push(manufacturer_number_filter); - assert_eq!(false, NAME::check_mask(&test_name, &filters_to_test)); + assert!(!NAME::check_mask(&test_name, &filters_to_test)); test_name.set_manufacturer_code(2); - assert_eq!(true, NAME::check_mask(&test_name, &filters_to_test)); + assert!(NAME::check_mask(&test_name, &filters_to_test)); let ecu_instance_filter = NameFieldValue { value: 3, @@ -408,9 +408,9 @@ mod tests { }; filters_to_test.push(ecu_instance_filter); - assert_eq!(false, NAME::check_mask(&test_name, &filters_to_test)); + assert!(!NAME::check_mask(&test_name, &filters_to_test)); test_name.set_ecu_instance(3); - assert_eq!(true, NAME::check_mask(&test_name, &filters_to_test)); + assert!(NAME::check_mask(&test_name, &filters_to_test)); let function_instance_filter = NameFieldValue { value: 4, @@ -418,9 +418,9 @@ mod tests { }; filters_to_test.push(function_instance_filter); - assert_eq!(false, NAME::check_mask(&test_name, &filters_to_test)); + assert!(!NAME::check_mask(&test_name, &filters_to_test)); test_name.set_function_instance(4); - assert_eq!(true, NAME::check_mask(&test_name, &filters_to_test)); + assert!(NAME::check_mask(&test_name, &filters_to_test)); let function_filter = NameFieldValue { value: 5, @@ -428,9 +428,9 @@ mod tests { }; filters_to_test.push(function_filter); - assert_eq!(false, NAME::check_mask(&test_name, &filters_to_test)); + assert!(!NAME::check_mask(&test_name, &filters_to_test)); test_name.set_function(5); - assert_eq!(true, NAME::check_mask(&test_name, &filters_to_test)); + assert!(NAME::check_mask(&test_name, &filters_to_test)); let device_class_filter = NameFieldValue { value: 6, @@ -438,9 +438,9 @@ mod tests { }; filters_to_test.push(device_class_filter); - assert_eq!(false, NAME::check_mask(&test_name, &filters_to_test)); + assert!(!NAME::check_mask(&test_name, &filters_to_test)); test_name.set_device_class(6); - assert_eq!(true, NAME::check_mask(&test_name, &filters_to_test)); + assert!(NAME::check_mask(&test_name, &filters_to_test)); let industry_group_filter = NameFieldValue { value: 7, @@ -448,9 +448,9 @@ mod tests { }; filters_to_test.push(industry_group_filter); - assert_eq!(false, NAME::check_mask(&test_name, &filters_to_test)); + assert!(!NAME::check_mask(&test_name, &filters_to_test)); test_name.set_industry_group(7); - assert_eq!(true, NAME::check_mask(&test_name, &filters_to_test)); + assert!(NAME::check_mask(&test_name, &filters_to_test)); let device_class_instance_filter = NameFieldValue { value: 8, @@ -458,9 +458,9 @@ mod tests { }; filters_to_test.push(device_class_instance_filter); - assert_eq!(false, NAME::check_mask(&test_name, &filters_to_test)); + assert!(!NAME::check_mask(&test_name, &filters_to_test)); test_name.set_device_class_instance(8); - assert_eq!(true, NAME::check_mask(&test_name, &filters_to_test)); + assert!(NAME::check_mask(&test_name, &filters_to_test)); let self_configurable_address_filter = NameFieldValue { value: true as u32, @@ -468,8 +468,8 @@ mod tests { }; filters_to_test.push(self_configurable_address_filter); - assert_eq!(false, NAME::check_mask(&test_name, &filters_to_test)); + assert!(!NAME::check_mask(&test_name, &filters_to_test)); test_name.set_self_configurable_address(true); - assert_eq!(true, NAME::check_mask(&test_name, &filters_to_test)); + assert!(NAME::check_mask(&test_name, &filters_to_test)); } }