use crate::health_scores::{
HealthConfiguredThresholds, HealthEffectiveThresholds, ThresholdOverrideDimension,
ThresholdOverrideMetrics, ThresholdOverrideStatus,
};
pub use fallow_types::inline_threshold::InlineThresholdProblemKind;
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct InlineThresholdOverrideState {
pub status: ThresholdOverrideStatus,
pub dimension: ThresholdOverrideDimension,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub outstanding: Vec<ThresholdOverrideDimension>,
#[serde(serialize_with = "fallow_types::serde_path::serialize")]
pub path: std::path::PathBuf,
pub comment_line: u32,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub function: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub line: Option<u32>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub col: Option<u32>,
pub configured_thresholds: HealthConfiguredThresholds,
pub effective_thresholds: HealthEffectiveThresholds,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub metrics: Option<ThresholdOverrideMetrics>,
pub reason: String,
}
impl InlineThresholdOverrideState {
#[must_use]
pub fn target_label(&self, display: &str) -> String {
match (self.line, self.function.as_deref()) {
(Some(line), Some(name)) => format!("{display}:{line}:{name}"),
_ => format!("{display}:{}", self.comment_line),
}
}
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct InlineThresholdOverrideProblem {
#[serde(serialize_with = "fallow_types::serde_path::serialize")]
pub path: std::path::PathBuf,
pub line: u32,
pub problem: InlineThresholdProblemKind,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub token: Option<String>,
}