From fc8e42c096337591173f46996ae651d55c2174d4 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 2 Jun 2025 09:53:08 +0300 Subject: [PATCH] diagnostic: handle mixed indentation diagnostics with severity levels --- src/diagnostic.rs | 25 +++++++++++++++++-------- src/main.rs | 2 +- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/diagnostic.rs b/src/diagnostic.rs index abcc06b..0a2e74d 100644 --- a/src/diagnostic.rs +++ b/src/diagnostic.rs @@ -766,16 +766,25 @@ impl StyleAnalyzer { // Check for mixed indentation across the file if has_tabs && has_spaces { - if let Some(preferred) = &config.preferred_indent { - let range = Range::single_position(Position::new(0, 0)); - let diagnostic = Diagnostic::new( - range, + let range = Range::single_position(Position::new(0, 0)); + let (severity, message) = if let Some(preferred) = &config.preferred_indent { + ( DiagnosticSeverity::Information, - DiagnosticCode::InconsistentIndentation, format!("File uses mixed indentation; prefer {}", preferred), - ); - diagnostics.push(diagnostic); - } + ) + } else { + ( + DiagnosticSeverity::Warning, + "File uses mixed indentation (tabs and spaces)".to_string(), + ) + }; + let diagnostic = Diagnostic::new( + range, + severity, + DiagnosticCode::InconsistentIndentation, + message, + ); + diagnostics.push(diagnostic); } diagnostics diff --git a/src/main.rs b/src/main.rs index 88f6116..268c3d8 100755 --- a/src/main.rs +++ b/src/main.rs @@ -352,7 +352,7 @@ fn process_lint_command( let is_multiple_files = files.len() > 1; let mut has_errors = false; - + for file_path in files { if let Err(e) = process_single_file_lint( &file_path,