MCPcopy Create free account
hub / github.com/FastLED/FastLED / test_aggregation_check_single_file

Function test_aggregation_check_single_file

ci/lint_cpp_rs/src/lib.rs:3060–3134  ·  view source on GitHub ↗
(file_path: &str)

Source from the content-addressed store, hash-verified

3058}
3059
3060fn test_aggregation_check_single_file(file_path: &str) -> Vec<String> {
3061 let normalized = normalize_path(file_path);
3062 let root_prefix = project_root_prefix_for_file(&normalized);
3063 let Some(project_rel) = project_relative_path(&normalized) else {
3064 return Vec::new();
3065 };
3066 let resolved = normalize_path(&path_to_string(&join_project_path(
3067 &root_prefix,
3068 &project_rel,
3069 )));
3070 let mut violations = Vec::new();
3071
3072 for excluded_dir in TEST_AGGREGATED_DIRS {
3073 let aggregator_rel = test_aggregator_rel_for_dir(excluded_dir);
3074 let aggregator_path = join_project_path(&root_prefix, &aggregator_rel);
3075 let aggregator_norm = normalize_path(&path_to_string(&aggregator_path));
3076
3077 if aggregator_path.exists() && aggregator_norm == resolved {
3078 let (_, included_files) =
3079 collect_test_aggregation_included_files(&root_prefix, excluded_dir);
3080 let excluded_path = join_project_path(&root_prefix, excluded_dir);
3081 if excluded_path.exists() {
3082 for entry in WalkDir::new(&excluded_path)
3083 .into_iter()
3084 .filter_map(Result::ok)
3085 {
3086 if !entry.file_type().is_file() {
3087 continue;
3088 }
3089 let hpp_path = normalize_path(&path_to_string(entry.path()));
3090 if !hpp_path.ends_with(".hpp") || included_files.contains(&hpp_path) {
3091 continue;
3092 }
3093 let rel_file = project_relative_path(&hpp_path).unwrap_or(hpp_path);
3094 violations.push(format!("{}: orphaned {}", aggregator_rel, rel_file));
3095 }
3096 }
3097 for include in parse_aggregator_includes(&aggregator_path) {
3098 let inc_resolved = resolve_test_include(&root_prefix, &aggregator_rel, &include);
3099 if project_relative_path(&inc_resolved)
3100 .is_some_and(|rel| rel.starts_with(&format!("{excluded_dir}/")))
3101 && include.ends_with(".cpp")
3102 {
3103 violations.push(format!(
3104 "{}: #include \"{include}\" should use .hpp",
3105 aggregator_rel
3106 ));
3107 }
3108 }
3109 return violations;
3110 }
3111
3112 if project_rel == *excluded_dir
3113 || project_rel
3114 .strip_prefix(&format!("{excluded_dir}/"))
3115 .is_some()
3116 {
3117 if !project_rel.ends_with(".hpp") {

Callers 1

check_file_contentMethod · 0.85

Calls 14

project_relative_pathFunction · 0.85
path_to_stringFunction · 0.85
join_project_pathFunction · 0.85
resolve_test_includeFunction · 0.85
normalize_pathFunction · 0.70
pathMethod · 0.45
ends_withMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected