diagnostic: handle mixed indentation diagnostics with severity levels
This commit is contained in:
parent
0ed74c6a51
commit
fc8e42c096
2 changed files with 18 additions and 9 deletions
|
@ -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
|
||||||
|
|
|
@ -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,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue