@@ -27,20 +27,12 @@ impl Rule for TypeMaxLength {
2727 }
2828
2929 fn validate ( & self , message : & Message ) -> Option < Violation > {
30- match & message. r#type {
31- Some ( t) => {
32- if t. len ( ) >= self . length {
33- return Some ( Violation {
34- level : self . level . unwrap_or ( Self :: LEVEL ) ,
35- message : self . message ( message) ,
36- } ) ;
37- }
38- }
39- None => {
30+ if let Some ( t) = & message. r#type {
31+ if t. len ( ) >= self . length {
4032 return Some ( Violation {
4133 level : self . level . unwrap_or ( Self :: LEVEL ) ,
4234 message : self . message ( message) ,
43- } )
35+ } ) ;
4436 }
4537 }
4638
@@ -81,6 +73,25 @@ mod tests {
8173 assert ! ( rule. validate( & message) . is_none( ) ) ;
8274 }
8375
76+ #[ test]
77+ fn test_no_type ( ) {
78+ let rule = TypeMaxLength {
79+ length : usize:: MAX , // Long length for testing
80+ ..Default :: default ( )
81+ } ;
82+ let message = Message {
83+ body : None ,
84+ description : Some ( "broadcast $destroy event on scope destruction" . to_string ( ) ) ,
85+ footers : None ,
86+ r#type : None ,
87+ raw : "feat(scope): broadcast $destroy event on scope destruction" . to_string ( ) ,
88+ scope : Some ( "scope" . to_string ( ) ) ,
89+ subject : Some ( "feat(scope): broadcast $destroy event on scope destruction" . to_string ( ) ) ,
90+ } ;
91+
92+ assert ! ( rule. validate( & message) . is_none( ) ) ;
93+ }
94+
8495 #[ test]
8596 fn test_short_type ( ) {
8697 let rule = TypeMaxLength {
0 commit comments