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(empty_list_concat): dedupe fn call by binding empty_array

+11 -5
+11 -5
lib/src/lints/empty_list_concat.rs
··· 45 45 46 46 let at = node.text_range(); 47 47 let message = "Concatenation with the empty list, `[]`, is a no-op"; 48 - if is_empty_array(&lhs) { 49 - Some(self.report().suggest(at, message, Suggestion::new(at, rhs))) 48 + 49 + let empty_array = if is_empty_array(&lhs) { 50 + rhs 50 51 } else if is_empty_array(&rhs) { 51 - Some(self.report().suggest(at, message, Suggestion::new(at, lhs))) 52 + lhs 52 53 } else { 53 - None 54 - } 54 + return None; 55 + }; 56 + 57 + Some( 58 + self.report() 59 + .suggest(at, message, Suggestion::new(at, empty_array)), 60 + ) 55 61 } 56 62 } 57 63