Stop delaying Trailing whitespace error reporting

This commit is contained in:
Tibo Delor 2018-06-10 14:19:09 +10:00
parent 42efae5944
commit 2e90c4314c
No known key found for this signature in database
GPG key ID: 2DF74CAC68BE8FCD

View file

@ -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);
}