Skip to main content

deps_cli/format/
mod.rs

1//! Output formatters for a [`crate::report::CheckReport`] (FR-006, FR-007).
2
3pub mod json;
4pub mod sarif;
5pub mod table;
6
7/// Renders `severity` as the lowercase token used by both output formats.
8#[must_use]
9pub fn severity_str(severity: deps_core::diagnostic::Severity) -> &'static str {
10    use deps_core::diagnostic::Severity;
11    match severity {
12        Severity::Error => "error",
13        Severity::Warning => "warning",
14        Severity::Information => "information",
15        Severity::Hint => "hint",
16    }
17}
18
19#[cfg(test)]
20mod tests {
21    use super::*;
22    use deps_core::diagnostic::Severity;
23
24    #[test]
25    fn test_severity_str_covers_every_lsp_severity() {
26        assert_eq!(severity_str(Severity::Error), "error");
27        assert_eq!(severity_str(Severity::Warning), "warning");
28        assert_eq!(severity_str(Severity::Information), "information");
29        assert_eq!(severity_str(Severity::Hint), "hint");
30    }
31}