impl SimpleProgressStyle {
#[must_use]
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn default_spinner() -> Self {
Self
}
#[must_use]
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn default_bar() -> Self {
Self
}
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn template(self, _template: &str) -> Result<Self, std::convert::Infallible> {
Ok(self)
}
#[must_use]
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn tick_chars(self, _chars: &str) -> Self {
self
}
#[must_use]
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn tick_strings(self, _strings: &[&str]) -> Self {
self
}
#[must_use]
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn progress_chars(self, _chars: &str) -> Self {
self
}
}
impl ProgressTracker {
#[must_use]
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn new(enable_progress: bool) -> Self {
Self { enable_progress }
}
#[must_use]
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn create_spinner(&self, message: &str) -> SimpleProgressBar {
if !self.enable_progress {
return SimpleProgressBar::hidden();
}
let pb = SimpleProgressBar::new_spinner();
pb.set_message(message.to_string());
eprintln!("⏳ {}", message);
pb
}
#[must_use]
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn create_file_progress(&self, total_files: u64, message: &str) -> SimpleProgressBar {
if !self.enable_progress {
return SimpleProgressBar::hidden();
}
let pb = SimpleProgressBar::new(total_files);
pb.set_message(message.to_string());
eprintln!("📁 {} (0/{})", message, total_files);
pb
}
#[must_use]
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn create_bytes_progress(&self, total_bytes: u64, message: &str) -> SimpleProgressBar {
if !self.enable_progress {
return SimpleProgressBar::hidden();
}
let pb = SimpleProgressBar::new(total_bytes);
pb.set_message(message.to_string());
eprintln!("📦 {} (0/{} bytes)", message, total_bytes);
pb
}
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "path_exists")]
pub fn log_skipped_file(&self, file_path: &std::path::Path, reason: &str) {
if self.enable_progress {
eprintln!("⚠️ Skipped: {} ({})", file_path.display(), reason);
}
}
#[must_use]
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn create_sub_progress(&self, message: &str, total: u64) -> SimpleProgressBar {
if !self.enable_progress {
return SimpleProgressBar::hidden();
}
let pb = SimpleProgressBar::new(total);
pb.set_message(message.to_string());
pb
}
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn clear(&self) {
}
}
impl FileClassificationReporter {
#[must_use]
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn new(tracker: ProgressTracker) -> Self {
Self {
tracker,
skipped_count: AtomicU64::new(0),
large_files_skipped: Arc::new(Mutex::new(Vec::new())),
}
}
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "path_exists")]
pub fn report_skipped(
&self,
path: &std::path::Path,
reason: crate::services::file_classifier::SkipReason,
) {
use crate::services::file_classifier::SkipReason;
self.skipped_count.fetch_add(1, Ordering::Relaxed);
match reason {
SkipReason::LargeFile => {
if let Ok(mut files) = self.large_files_skipped.lock() {
files.push(path.to_path_buf());
}
self.tracker.log_skipped_file(path, "large file >500KB");
}
SkipReason::MinifiedContent => {
self.tracker.log_skipped_file(path, "minified content");
}
SkipReason::VendorDirectory => {
}
SkipReason::LineTooLong => {
self.tracker.log_skipped_file(path, "line too long");
}
_ => {}
}
}
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "path_exists")]
pub fn get_summary(&self) -> (u64, Vec<std::path::PathBuf>) {
let count = self.skipped_count.load(Ordering::Relaxed);
let files = self
.large_files_skipped
.lock()
.expect("internal error")
.clone();
(count, files)
}
}
impl SimpleMultiProgress {
#[must_use]
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn new() -> Self {
Self
}
#[must_use]
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn add(&self, pb: SimpleProgressBar) -> SimpleProgressBar {
pb
}
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn clear(&self) -> std::io::Result<()> {
Ok(())
}
}