use crate::analysis::findings::{Finding, Severity};
use crate::languages::spec::ToolSpec;
pub(super) fn parse_lines(spec: &ToolSpec, output: &str) -> Vec<Finding> {
output
.lines()
.filter(|line| !line.trim().is_empty())
.map(|line| {
let path = line.trim();
let suggest = match spec.command.split_last() {
Some((_, base)) if !base.is_empty() => {
Some(format!("Run `{} -w {path}`", base.join(" ")))
}
_ => None,
};
Finding::deterministic(
spec.name.to_owned(),
Severity::Error,
path.to_owned(),
1,
None,
format!("{}: file is not formatted", spec.name),
suggest,
)
})
.collect()
}