use std::borrow::Cow;
use std::path::PathBuf;
use harn_lexer::{FixEdit, Span};
pub use harn_modules::project_config::LintSeverity;
use harn_parser::{DiagnosticCode as Code, Repair};
#[derive(Debug, Clone)]
pub struct LintDiagnostic {
pub code: Code,
pub rule: Cow<'static, str>,
pub message: String,
pub span: Span,
pub severity: LintSeverity,
pub suggestion: Option<String>,
pub fix: Option<Vec<FixEdit>>,
}
impl LintDiagnostic {
pub fn repair(&self) -> Option<Repair> {
self.code.repair_template().map(Repair::from_template)
}
pub fn machine_applicable_fix(&self) -> Option<&[FixEdit]> {
let fix = self.fix.as_deref()?;
self.code
.repair_template()
.is_none_or(|repair| repair.safety.is_machine_applicable())
.then_some(fix)
}
}
pub const DEFAULT_COMPLEXITY_THRESHOLD: usize = 25;
#[derive(Debug, Default, Clone)]
pub struct LintOptions<'a> {
pub file_path: Option<&'a std::path::Path>,
pub require_file_header: bool,
pub require_docstrings: bool,
pub complexity_threshold: Option<usize>,
pub persona_step_allowlist: &'a [String],
pub require_stdlib_metadata: bool,
pub engine_rules: &'a [String],
pub native_rule_paths: &'a [PathBuf],
pub severity_overrides: std::collections::HashMap<String, LintSeverity>,
pub trusted_host_dispatch: bool,
pub connector_runtime_module: bool,
}