@@ -22,28 +22,30 @@ pub fn execute_rule_allowed_file_location(
2222 return ;
2323 }
2424
25- let mut in_correct_root = false ;
26- let mut has_path_entry = false ;
27- let mut matched_locations: Vec < String > = vec ! [ ] ;
25+ let mut is_in_correct_location = false ;
26+ let mut matched_allowed_locations: Vec < String > = vec ! [ ] ;
2827
28+ // Check if file matches any configured patterns
2929 for ( pattern, locations) in config. allowed_file_locations . iter ( ) {
3030 if glob_match ( pattern, & file. relative_path ) {
31- has_path_entry = true ;
3231 for location in locations {
33- matched_locations . push ( location. to_owned ( ) ) ;
32+ matched_allowed_locations . push ( location. to_owned ( ) ) ;
3433 if glob_match ( location, & file. relative_path ) {
35- in_correct_root = true ;
34+ is_in_correct_location = true ;
35+ break ;
3636 }
3737 }
3838 }
3939 }
40- if !has_path_entry {
40+
41+ if matched_allowed_locations. is_empty ( ) {
4142 return ;
4243 }
43- let folders_list = matched_locations. join ( " or " ) ;
44+
45+ let folders_list = matched_allowed_locations. join ( " or " ) ;
4446
4547 let validation_output = handle_validation_result (
46- in_correct_root ,
48+ is_in_correct_location ,
4749 "rule-allowed-file-location" . to_owned ( ) ,
4850 format ! ( "Found {} in correct location" , file. file_name. bold( ) ) ,
4951 format ! (
@@ -56,7 +58,8 @@ pub fn execute_rule_allowed_file_location(
5658 test_results,
5759 file,
5860 ) ;
59- if validation_output. is_some ( ) {
60- println ! ( "{}" , validation_output. unwrap( ) )
61+
62+ if let Some ( output) = validation_output {
63+ println ! ( "{}" , output) ;
6164 }
6265}
0 commit comments