use crate::rules::{Evidence, Finding, Rule, Stance, Trend};
use crate::shell::Parsed;
pub const RULE: Rule = Rule {
id: "gh-pr-merge-auto",
default_stance: Stance::Observe,
evidence: Evidence {
per_1000: 0.02,
measured: "2026-08-20",
trend: Trend::Rare,
},
examine,
confirm: None,
};
fn examine(parsed: &Parsed) -> Option<Finding> {
for cmd in parsed.clauses() {
if cmd.program() != Some("gh") || cmd.subcommand() != Some("pr") {
continue;
}
if cmd.operands().get(1).map(|w| w.text.as_str()) != Some("merge") {
continue;
}
if !cmd.has_flag("--auto") {
continue;
}
return Some(Finding {
reason: "`--auto` waits only where the repository has required status \
checks. Without branch protection there is nothing to wait for, \
so the pull request merges immediately — before CI has started."
.to_string(),
remedy: "Confirm required checks are configured, or drop `--auto` and \
poll until the run concludes successfully before merging."
.to_string(),
span: cmd.at..cmd.end,
});
}
None
}