| 306 | } |
| 307 | |
| 308 | fn inspect_parsed( |
| 309 | report: &mut AnalysisReport, |
| 310 | change: &str, |
| 311 | path: &str, |
| 312 | after: StructuralInspection, |
| 313 | baseline: Result<StructuralInspection, String>, |
| 314 | snapshot: bool, |
| 315 | ) { |
| 316 | if !snapshot { |
| 317 | report.checks.push(Check { |
| 318 | change: change.into(), |
| 319 | path: path.into(), |
| 320 | rule: "recorded-baseline".into(), |
| 321 | status: if baseline.is_ok() { |
| 322 | CheckStatus::Completed |
| 323 | } else { |
| 324 | CheckStatus::Error |
| 325 | }, |
| 326 | detail: baseline |
| 327 | .as_ref() |
| 328 | .map(|_| "Recorded baseline inspected".into()) |
| 329 | .unwrap_or_else(Clone::clone), |
| 330 | }); |
| 331 | } |
| 332 | let language = Language::detect(path).expect("successful parse has a detected language"); |
| 333 | for rule in Rule::ALL { |
| 334 | let (status, detail) = if !rule.supports(language) { |
| 335 | ( |
| 336 | CheckStatus::Skipped, |
| 337 | "Rule not implemented for this language", |
| 338 | ) |
| 339 | } else if rule != Rule::Syntax && after.has_syntax_errors { |
| 340 | ( |
| 341 | CheckStatus::Skipped, |
| 342 | "Syntax recovery prevents reliable anti-slop inspection", |
| 343 | ) |
| 344 | } else if rule == Rule::Manageability && !after.ambiguous_manageability_subjects.is_empty() |
| 345 | { |
| 346 | (CheckStatus::Skipped, "Ambiguous named-function identities excluded from joint manageability; unique subjects were checked") |
| 347 | } else { |
| 348 | (CheckStatus::Completed, rule.coverage()) |
| 349 | }; |
| 350 | report.checks.push(Check { |
| 351 | change: change.into(), |
| 352 | path: path.into(), |
| 353 | rule: rule.id().into(), |
| 354 | status, |
| 355 | detail: detail.into(), |
| 356 | }); |
| 357 | } |
| 358 | // Compare exact node text as a multiset, not line numbers. A line-only move |
| 359 | // is pre-existing; an extra identical occurrence is a new candidate. This |
| 360 | // is syntactic attribution, not a proof of behavioral regression. |
| 361 | let mut counts = BTreeMap::new(); |
| 362 | if let Ok(before) = &baseline { |
| 363 | for issue in &before.issues { |
| 364 | *counts |
| 365 | .entry((issue.rule, issue.source.as_str())) |