MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / print_coverage

Method print_coverage

atomic-cli/src/commands/agent/attest.rs:660–708  ·  view source on GitHub ↗

Print coverage per view.

(&self, repo: &Repository, attest: &Attestation)

Source from the content-addressed store, hash-verified

658
659 /// Print coverage per view.
660 fn print_coverage(&self, repo: &Repository, attest: &Attestation) {
661 let views = match repo.list_views() {
662 Ok(s) => s,
663 Err(_) => return,
664 };
665
666 let covered_set: std::collections::HashSet<&Hash> = attest.changes_covered.iter().collect();
667
668 let mut has_coverage = false;
669
670 for view_name in &views {
671 let history = match repo
672 .log(atomic_repository::history::HistoryOptions::default().view(view_name))
673 {
674 Ok(h) => h,
675 Err(_) => continue,
676 };
677
678 let total = history.len();
679 if total == 0 {
680 continue;
681 }
682
683 let covered = history
684 .iter()
685 .filter(|e| covered_set.contains(&e.hash))
686 .count();
687
688 if covered == 0 {
689 continue;
690 }
691
692 if !has_coverage {
693 println!("Coverage:");
694 has_coverage = true;
695 }
696
697 let pct = (covered as f64 / total as f64) * 100.0;
698 let bar_width = 20;
699 let filled = ((pct / 100.0) * bar_width as f64) as usize;
700 let empty = bar_width - filled;
701 let bar = format!("{}{}", "█".repeat(filled), "░".repeat(empty),);
702
703 println!(
704 " {:<20} {} {}/{} ({:.0}%)",
705 view_name, bar, covered, total, pct,
706 );
707 }
708 }
709}
710
711/// One per-view coverage row off the wire's detail bundle.

Callers 1

show_detailMethod · 0.80

Calls 8

list_viewsMethod · 0.45
collectMethod · 0.45
iterMethod · 0.45
logMethod · 0.45
viewMethod · 0.45
lenMethod · 0.45
countMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected