Skip to main content

ought_analysis/
types.rs

1use std::path::PathBuf;
2
3use chrono::{DateTime, Utc};
4use ought_spec::{ClauseId, Keyword};
5
6// -- Survey --
7
8/// Results from `ought analyze survey`.
9#[derive(Debug, Clone)]
10pub struct SurveyResult {
11    pub uncovered: Vec<UncoveredBehavior>,
12}
13
14/// A behavior found in source code with no corresponding spec clause.
15#[derive(Debug, Clone)]
16pub struct UncoveredBehavior {
17    pub file: PathBuf,
18    pub line: usize,
19    pub description: String,
20    pub suggested_clause: String,
21    pub suggested_keyword: Keyword,
22    pub suggested_spec: PathBuf,
23}
24
25// -- Audit --
26
27/// Results from `ought analyze audit`.
28#[derive(Debug, Clone)]
29pub struct AuditResult {
30    pub findings: Vec<AuditFinding>,
31}
32
33/// A coherence issue found across specs.
34#[derive(Debug, Clone)]
35pub struct AuditFinding {
36    pub kind: AuditFindingKind,
37    pub description: String,
38    pub clauses: Vec<ClauseId>,
39    pub suggestion: Option<String>,
40    pub confidence: Option<f64>,
41}
42
43#[derive(Debug, Clone, Copy, PartialEq, Eq)]
44pub enum AuditFindingKind {
45    Contradiction,
46    Gap,
47    Ambiguity,
48    Redundancy,
49}
50
51// -- Blame --
52
53/// Results from `ought debug blame`.
54#[derive(Debug, Clone)]
55pub struct BlameResult {
56    pub clause_id: ClauseId,
57    pub last_passed: Option<DateTime<Utc>>,
58    pub first_failed: Option<DateTime<Utc>>,
59    pub likely_commit: Option<CommitInfo>,
60    pub narrative: String,
61    pub suggested_fix: Option<String>,
62}
63
64/// Information about a git commit.
65#[derive(Debug, Clone)]
66pub struct CommitInfo {
67    pub hash: String,
68    pub message: String,
69    pub author: String,
70    pub date: DateTime<Utc>,
71}
72
73// -- Bisect --
74
75/// Results from `ought debug bisect`.
76#[derive(Debug, Clone)]
77pub struct BisectResult {
78    pub clause_id: ClauseId,
79    pub breaking_commit: CommitInfo,
80    pub diff_summary: String,
81}