const ELISION_PHRASES: &[&str] = &[
"the full file content remains unchanged",
"full file content remains unchanged",
"rest of the file remains unchanged",
"rest of the file is unchanged",
"rest of the file unchanged",
"rest of file unchanged",
"remainder of the file unchanged",
"rest of the code remains unchanged",
"rest of the code is unchanged",
"rest of the implementation unchanged",
"rest of the implementation is unchanged",
"unchanged portion omitted",
"omitted for brevity",
];
pub fn lazy_emission_reason(content: &str) -> Option<String> {
if content.trim().is_empty() {
return Some("empty file content".to_string());
}
for (i, line) in content.lines().enumerate() {
let stripped = line
.trim()
.trim_start_matches(|c: char| "/*#<>-! \t".contains(c))
.trim();
let lc = stripped.to_lowercase();
if let Some(p) = ELISION_PHRASES.iter().find(|p| lc.contains(**p)) {
return Some(format!("elision placeholder (line {}): {p:?}", i + 1));
}
}
None
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn flags_the_548_placeholder() {
assert!(lazy_emission_reason("<the full file content remains unchanged>").is_some());
}
#[test]
fn flags_an_elision_inside_a_real_looking_emission() {
let body = "fn main() {\n // ... rest of the file unchanged ...\n}\n";
assert!(lazy_emission_reason(body).is_some());
}
#[test]
fn flags_empty_or_whitespace_content() {
assert!(lazy_emission_reason("").is_some());
assert!(lazy_emission_reason(" \n \t\n").is_some());
}
#[test]
fn passes_a_complete_file() {
let body = "pub fn help_lines() -> &'static [&'static str] {\n &[\"/dgx\"]\n}\n";
assert!(lazy_emission_reason(body).is_none());
}
#[test]
fn does_not_flag_legit_prose_mentioning_unchanged() {
let body = "// The public API is unchanged; only the internals moved.\npub fn f() {}\n";
assert!(lazy_emission_reason(body).is_none());
let body2 = "let msg = \"the value remains unchanged after the call\";\n";
assert!(lazy_emission_reason(body2).is_none());
}
}