use fallow_config::{ResolvedConfig, WorkspaceInfo};
use fallow_output::DiffIndex;
use fallow_types::workspace::WorkspaceDiagnostic;
use rustc_hash::{FxHashMap, FxHashSet};
use std::path::PathBuf;
use crate::{
duplicates::DuplicationReport,
results::{AnalysisResults, DeadCodeAnalysisArtifacts},
};
use super::StylingAnalysisArtifacts;
pub struct HealthPipelineInputs {
pub config: ResolvedConfig,
pub files: Vec<fallow_types::discover::DiscoveredFile>,
pub modules: Vec<fallow_types::extract::ModuleInfo>,
pub config_ms: f64,
pub discover_ms: f64,
pub parse_ms: f64,
pub parse_cpu_ms: f64,
pub shared_parse: bool,
pub pre_computed_analysis: Option<DeadCodeAnalysisArtifacts>,
pub dead_code_results: Option<AnalysisResults>,
pub styling_artifacts: Option<StylingAnalysisArtifacts>,
pub pre_computed_duplication: Option<DuplicationReport>,
pub workspaces: Vec<WorkspaceInfo>,
pub workspace_diagnostics: Vec<WorkspaceDiagnostic>,
}
pub(super) struct HealthPipelineRunInputs<M> {
pub(super) config: ResolvedConfig,
pub(super) files: Vec<fallow_types::discover::DiscoveredFile>,
pub(super) modules: M,
pub(super) config_ms: f64,
pub(super) discover_ms: f64,
pub(super) parse_ms: f64,
pub(super) parse_cpu_ms: f64,
pub(super) shared_parse: bool,
pub(super) pre_computed_analysis: Option<DeadCodeAnalysisArtifacts>,
pub(super) dead_code_results: Option<AnalysisResults>,
pub(super) styling_artifacts: Option<StylingAnalysisArtifacts>,
pub(super) pre_computed_duplication: Option<DuplicationReport>,
pub(super) workspaces: Vec<WorkspaceInfo>,
pub(super) workspace_diagnostics: Vec<WorkspaceDiagnostic>,
}
impl From<HealthPipelineInputs>
for HealthPipelineRunInputs<Vec<fallow_types::extract::ModuleInfo>>
{
fn from(input: HealthPipelineInputs) -> Self {
Self {
config: input.config,
files: input.files,
modules: input.modules,
config_ms: input.config_ms,
discover_ms: input.discover_ms,
parse_ms: input.parse_ms,
parse_cpu_ms: input.parse_cpu_ms,
shared_parse: input.shared_parse,
pre_computed_analysis: input.pre_computed_analysis,
dead_code_results: input.dead_code_results,
styling_artifacts: input.styling_artifacts,
pre_computed_duplication: input.pre_computed_duplication,
workspaces: input.workspaces,
workspace_diagnostics: input.workspace_diagnostics,
}
}
}
pub struct HealthScopeInputs<'a, R> {
pub changed_files: Option<FxHashSet<PathBuf>>,
pub diff_index: Option<&'a DiffIndex>,
pub ws_roots: Option<Vec<PathBuf>>,
pub group_resolver: Option<R>,
}
pub(super) struct HealthPipelineTimings {
pub(super) config: f64,
pub(super) discover: f64,
pub(super) parse: f64,
pub(super) parse_cpu: f64,
pub(super) shared_parse: bool,
}
impl HealthPipelineTimings {
pub(super) fn into_base_input(self, complexity_ms: f64) -> HealthTimingBaseInput {
HealthTimingBaseInput {
config_ms: self.config,
discover_ms: self.discover,
parse_ms: self.parse,
parse_cpu_ms: self.parse_cpu,
complexity_ms,
shared_parse: self.shared_parse,
}
}
}
pub(super) struct HealthScope<'a, R> {
pub(super) max_cyclomatic: u16,
pub(super) max_cognitive: u16,
pub(super) max_crap: f64,
pub(super) enforce_crap: bool,
pub(super) ignore_set: globset::GlobSet,
pub(super) changed_files: Option<FxHashSet<PathBuf>>,
pub(super) diff_index: Option<&'a DiffIndex>,
pub(super) ws_roots: Option<Vec<PathBuf>>,
pub(super) group_resolver: Option<R>,
pub(super) file_paths: FxHashMap<crate::discover::FileId, &'a PathBuf>,
}
pub(super) struct HealthTimingBaseInput {
pub(super) config_ms: f64,
pub(super) discover_ms: f64,
pub(super) parse_ms: f64,
pub(super) parse_cpu_ms: f64,
pub(super) complexity_ms: f64,
pub(super) shared_parse: bool,
}