Stop delaying Trailing whitespace error reporting
This commit is contained in:
parent
42efae5944
commit
2e90c4314c
1 changed files with 8 additions and 14 deletions
22
src/lib.rs
22
src/lib.rs
|
|
@ -516,7 +516,6 @@ fn format_lines(
|
|||
config: &Config,
|
||||
report: &FormatReport,
|
||||
) {
|
||||
let mut trims = vec![];
|
||||
let mut last_was_space = false;
|
||||
let mut line_len = 0;
|
||||
let mut cur_line = 1;
|
||||
|
|
@ -565,8 +564,15 @@ fn format_lines(
|
|||
// Check for (and record) trailing whitespace.
|
||||
if last_was_space {
|
||||
if should_report_error(config, kind, is_string, &ErrorKind::TrailingWhitespace)
|
||||
&& !is_skipped_line(cur_line, skipped_range)
|
||||
{
|
||||
trims.push((cur_line, kind, line_buffer.clone()));
|
||||
errors.push(FormattingError {
|
||||
line: cur_line,
|
||||
kind: ErrorKind::TrailingWhitespace,
|
||||
is_comment: kind.is_comment(),
|
||||
is_string: kind.is_string(),
|
||||
line_buffer: line_buffer.clone(),
|
||||
});
|
||||
}
|
||||
line_len -= 1;
|
||||
}
|
||||
|
|
@ -611,18 +617,6 @@ fn format_lines(
|
|||
text.truncate(line);
|
||||
}
|
||||
|
||||
for &(l, kind, ref b) in &trims {
|
||||
if !is_skipped_line(l, skipped_range) {
|
||||
errors.push(FormattingError {
|
||||
line: l,
|
||||
kind: ErrorKind::TrailingWhitespace,
|
||||
is_comment: kind.is_comment(),
|
||||
is_string: kind.is_string(),
|
||||
line_buffer: b.clone(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
report.append(name.clone(), errors);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue