Skip to content

Commit

Permalink
Stop delaying Trailing whitespace error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
t-botz committed Jun 10, 2018
1 parent 42efae5 commit 2e90c43
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions src/lib.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 2e90c43

Please sign in to comment.