fallow_engine/health/
pipeline.rs1use std::path::PathBuf;
4
5use fallow_config::{ResolvedConfig, WorkspaceInfo};
6use fallow_output::DiffIndex;
7use fallow_types::workspace::WorkspaceDiagnostic;
8use rustc_hash::{FxHashMap, FxHashSet};
9
10use crate::{
11 duplicates::DuplicationReport,
12 results::{AnalysisResults, DeadCodeAnalysisArtifacts},
13};
14
15use super::StylingAnalysisArtifacts;
16
17pub struct HealthPipelineInputs {
19 pub config: ResolvedConfig,
20 pub files: Vec<fallow_types::discover::DiscoveredFile>,
21 pub modules: Vec<fallow_types::extract::ModuleInfo>,
22 pub config_ms: f64,
24 pub discover_ms: f64,
25 pub parse_ms: f64,
26 pub parse_cpu_ms: f64,
27 pub shared_parse: bool,
29 pub pre_computed_analysis: Option<DeadCodeAnalysisArtifacts>,
30 pub dead_code_results: Option<AnalysisResults>,
31 pub styling_artifacts: Option<StylingAnalysisArtifacts>,
32 pub pre_computed_duplication: Option<DuplicationReport>,
33 pub workspaces: Vec<WorkspaceInfo>,
34 pub workspace_diagnostics: Vec<WorkspaceDiagnostic>,
35}
36
37pub struct HealthScopeInputs<'a, R> {
44 pub changed_files: Option<FxHashSet<PathBuf>>,
45 pub diff_index: Option<&'a DiffIndex>,
46 pub ws_roots: Option<Vec<PathBuf>>,
47 pub group_resolver: Option<R>,
48}
49
50pub(super) struct HealthPipelineTimings {
51 pub(super) config: f64,
52 pub(super) discover: f64,
53 pub(super) parse: f64,
54 pub(super) parse_cpu: f64,
56 pub(super) shared_parse: bool,
58}
59
60impl HealthPipelineTimings {
61 pub(super) fn into_base_input(self, complexity_ms: f64) -> HealthTimingBaseInput {
62 HealthTimingBaseInput {
63 config_ms: self.config,
64 discover_ms: self.discover,
65 parse_ms: self.parse,
66 parse_cpu_ms: self.parse_cpu,
67 complexity_ms,
68 shared_parse: self.shared_parse,
69 }
70 }
71}
72
73pub(super) struct HealthScope<'a, R> {
74 pub(super) max_cyclomatic: u16,
75 pub(super) max_cognitive: u16,
76 pub(super) max_crap: f64,
77 pub(super) enforce_crap: bool,
78 pub(super) ignore_set: globset::GlobSet,
79 pub(super) changed_files: Option<FxHashSet<PathBuf>>,
80 pub(super) diff_index: Option<&'a DiffIndex>,
81 pub(super) ws_roots: Option<Vec<PathBuf>>,
82 pub(super) group_resolver: Option<R>,
83 pub(super) file_paths: FxHashMap<crate::discover::FileId, &'a PathBuf>,
84}
85
86pub(super) struct HealthTimingBaseInput {
87 pub(super) config_ms: f64,
88 pub(super) discover_ms: f64,
89 pub(super) parse_ms: f64,
90 pub(super) parse_cpu_ms: f64,
91 pub(super) complexity_ms: f64,
92 pub(super) shared_parse: bool,
93}