diagnostic: handle mixed indentation diagnostics with severity levels

This commit is contained in:
raf 2025-06-02 09:53:08 +03:00
commit fc8e42c096
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
2 changed files with 18 additions and 9 deletions

View file

@ -766,16 +766,25 @@ impl StyleAnalyzer {
// Check for mixed indentation across the file // Check for mixed indentation across the file
if has_tabs && has_spaces { if has_tabs && has_spaces {
if let Some(preferred) = &config.preferred_indent { let range = Range::single_position(Position::new(0, 0));
let range = Range::single_position(Position::new(0, 0)); let (severity, message) = if let Some(preferred) = &config.preferred_indent {
let diagnostic = Diagnostic::new( (
range,
DiagnosticSeverity::Information, DiagnosticSeverity::Information,
DiagnosticCode::InconsistentIndentation,
format!("File uses mixed indentation; prefer {}", preferred), 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 diagnostics

View file

@ -352,7 +352,7 @@ fn process_lint_command(
let is_multiple_files = files.len() > 1; let is_multiple_files = files.len() > 1;
let mut has_errors = false; let mut has_errors = false;
for file_path in files { for file_path in files {
if let Err(e) = process_single_file_lint( if let Err(e) = process_single_file_lint(
&file_path, &file_path,