diff --git a/src/message.rs b/src/message.rs index 5f0dbcc..f65dbfb 100644 --- a/src/message.rs +++ b/src/message.rs @@ -23,10 +23,10 @@ pub struct Message { /// Description part of the commit message. pub description: Option, - /// Footers part of the commit message. pub footers: Option>, + #[allow(dead_code)] /// Raw commit message (or any input from stdin) including the body and footers. pub raw: String, diff --git a/src/rule/description_format.rs b/src/rule/description_format.rs index 070d315..0b5c3db 100644 --- a/src/rule/description_format.rs +++ b/src/rule/description_format.rs @@ -78,8 +78,10 @@ mod tests { #[test] fn test_invalid_description_format() { - let mut rule = DescriptionFormat::default(); - rule.format = Some(r"^[a-z].*".to_string()); + let rule = DescriptionFormat { + format: Some(r"^[a-z].*".to_string()), + ..Default::default() + }; let message = Message { body: None, @@ -96,8 +98,10 @@ mod tests { #[test] fn test_valid_description_format() { - let mut rule = DescriptionFormat::default(); - rule.format = Some(r"^[a-z].*".to_string()); + let rule = DescriptionFormat { + format: Some(r"^[a-z].*".to_string()), + ..Default::default() + }; let message = Message { body: None, @@ -120,8 +124,10 @@ mod tests { #[test] fn test_invalid_regex() { - let mut rule = DescriptionFormat::default(); - rule.format = Some(r"(".to_string()); + let rule = DescriptionFormat { + format: Some(r"(".to_string()), + ..Default::default() + }; let message = Message { body: None, diff --git a/src/rule/scope.rs b/src/rule/scope.rs index a0fdd06..f469898 100644 --- a/src/rule/scope.rs +++ b/src/rule/scope.rs @@ -140,8 +140,10 @@ mod tests { use super::*; #[test] fn test_empty_scope() { - let mut rule = Scope::default(); - rule.options = vec!["api".to_string(), "web".to_string()]; + let rule = Scope { + options: vec!["api".to_string(), "web".to_string()], + ..Default::default() + }; let message = Message { body: None, @@ -164,8 +166,10 @@ mod tests { #[test] fn test_none_scope() { - let mut rule = Scope::default(); - rule.options = vec!["api".to_string(), "web".to_string()]; + let rule = Scope { + options: vec!["api".to_string(), "web".to_string()], + ..Default::default() + }; let message = Message { body: None, @@ -188,8 +192,10 @@ mod tests { #[test] fn test_valid_scope() { - let mut rule = Scope::default(); - rule.options = vec!["api".to_string(), "web".to_string()]; + let rule = Scope { + options: vec!["api".to_string(), "web".to_string()], + ..Default::default() + }; let message = Message { body: None, @@ -206,8 +212,10 @@ mod tests { #[test] fn test_invalid_scope() { - let mut rule = Scope::default(); - rule.options = vec!["api".to_string(), "web".to_string()]; + let rule = Scope { + options: vec!["api".to_string(), "web".to_string()], + ..Default::default() + }; let message = Message { body: None, diff --git a/src/rule/scope_format.rs b/src/rule/scope_format.rs index 9889bed..d0b0959 100644 --- a/src/rule/scope_format.rs +++ b/src/rule/scope_format.rs @@ -78,8 +78,10 @@ mod tests { #[test] fn test_invalid_description_format() { - let mut rule = ScopeFormat::default(); - rule.format = Some(r"^[a-z].*".to_string()); + let rule = ScopeFormat { + format: Some(r"^[a-z].*".to_string()), + ..Default::default() + }; let message = Message { body: None, @@ -96,8 +98,10 @@ mod tests { #[test] fn test_valid_description_format() { - let mut rule = ScopeFormat::default(); - rule.format = Some(r"^[a-z].*".to_string()); + let rule = ScopeFormat { + format: Some(r"^[a-z].*".to_string()), + ..Default::default() + }; let message = Message { body: None, @@ -120,8 +124,10 @@ mod tests { #[test] fn test_invalid_regex() { - let mut rule = ScopeFormat::default(); - rule.format = Some(r"(".to_string()); + let rule = ScopeFormat { + format: Some(r"(".to_string()), + ..Default::default() + }; let message = Message { body: None, diff --git a/src/rule/type.rs b/src/rule/type.rs index ba4f4b5..26f3e94 100644 --- a/src/rule/type.rs +++ b/src/rule/type.rs @@ -139,8 +139,10 @@ mod tests { use super::*; #[test] fn test_empty_type() { - let mut rule = Type::default(); - rule.options = vec!["feat".to_string(), "chore".to_string()]; + let rule = Type { + options: vec!["feat".to_string(), "chore".to_string()], + ..Default::default() + }; let message = Message { body: None, @@ -163,8 +165,10 @@ mod tests { #[test] fn test_none_type() { - let mut rule = Type::default(); - rule.options = vec!["feat".to_string(), "chore".to_string()]; + let rule = Type { + options: vec!["feat".to_string(), "chore".to_string()], + ..Default::default() + }; let message = Message { body: None, @@ -187,8 +191,10 @@ mod tests { #[test] fn test_valid_type() { - let mut rule = Type::default(); - rule.options = vec!["feat".to_string(), "chore".to_string()]; + let rule = Type { + options: vec!["feat".to_string(), "chore".to_string()], + ..Default::default() + }; let message = Message { body: None, @@ -205,8 +211,10 @@ mod tests { #[test] fn test_invalid_type() { - let mut rule = Type::default(); - rule.options = vec!["feat".to_string(), "chore".to_string()]; + let rule = Type { + options: vec!["feat".to_string(), "chore".to_string()], + ..Default::default() + }; let message = Message { body: None, diff --git a/src/rule/type_format.rs b/src/rule/type_format.rs index 259a3ee..672549c 100644 --- a/src/rule/type_format.rs +++ b/src/rule/type_format.rs @@ -78,8 +78,10 @@ mod tests { #[test] fn test_invalid_description_format() { - let mut rule = TypeFormat::default(); - rule.format = Some(r"^[a-z].*".to_string()); + let rule = TypeFormat { + format: Some(r"^[a-z].*".to_string()), + ..Default::default() + }; let message = Message { body: None, @@ -96,8 +98,10 @@ mod tests { #[test] fn test_valid_description_format() { - let mut rule = TypeFormat::default(); - rule.format = Some(r"^[a-z].*".to_string()); + let rule = TypeFormat { + format: Some(r"^[a-z].*".to_string()), + ..Default::default() + }; let message = Message { body: None, @@ -120,8 +124,10 @@ mod tests { #[test] fn test_invalid_regex() { - let mut rule = TypeFormat::default(); - rule.format = Some(r"(".to_string()); + let rule = TypeFormat { + format: Some(r"(".to_string()), + ..Default::default() + }; let message = Message { body: None,