Lints and suggestions for the Nix programming language
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor(repeated_keys): an early non-match return

+11 -10
+11 -10
lib/src/lints/repeated_keys.rs
··· 72 72 let mut kv_scrutinee_components = scrutinee_key.path(); 73 73 let kv_scrutinee_first_component = kv_scrutinee_components.next()?; 74 74 let kv_scrutinee_ident = Ident::cast(kv_scrutinee_first_component)?; 75 - if kv_scrutinee_ident.as_str() == first_component_ident.as_str() { 76 - Some(( 77 - kv_scrutinee.key()?.node().text_range(), 78 - kv_scrutinee_components 79 - .map(|n| n.to_string()) 80 - .collect::<Vec<_>>() 81 - .join("."), 82 - )) 83 - } else { 84 - None 75 + 76 + if kv_scrutinee_ident.as_str() != first_component_ident.as_str() { 77 + return None; 85 78 } 79 + 80 + Some(( 81 + kv_scrutinee.key()?.node().text_range(), 82 + kv_scrutinee_components 83 + .map(|n| n.to_string()) 84 + .collect::<Vec<_>>() 85 + .join("."), 86 + )) 86 87 }) 87 88 .collect::<Vec<_>>(); 88 89