ignore-tidy-trailing-newlines
This commit is contained in:
parent
eeb1bd18dc
commit
6263eb438d
@ -1,4 +1,4 @@
|
||||
// ignore-tidy-end-whitespace
|
||||
// ignore-tidy-trailing-newlines
|
||||
// error-pattern: aborting due to 6 previous errors
|
||||
|
||||
fn main() {}
|
||||
|
@ -152,6 +152,8 @@ pub fn check(path: &Path, bad: &mut bool) {
|
||||
let mut skip_file_length = contains_ignore_directive(can_contain, &contents, "filelength");
|
||||
let mut skip_end_whitespace =
|
||||
contains_ignore_directive(can_contain, &contents, "end-whitespace");
|
||||
let mut skip_trailing_newlines =
|
||||
contains_ignore_directive(can_contain, &contents, "trailing-newlines");
|
||||
let mut skip_copyright = contains_ignore_directive(can_contain, &contents, "copyright");
|
||||
let mut leading_new_lines = false;
|
||||
let mut trailing_new_lines = 0;
|
||||
@ -214,10 +216,17 @@ pub fn check(path: &Path, bad: &mut bool) {
|
||||
if leading_new_lines {
|
||||
tidy_error!(bad, "{}: leading newline", file.display());
|
||||
}
|
||||
let mut err = |msg: &str| {
|
||||
tidy_error!(bad, "{}: {}", file.display(), msg);
|
||||
};
|
||||
match trailing_new_lines {
|
||||
0 => tidy_error!(bad, "{}: missing trailing newline", file.display()),
|
||||
0 => suppressible_tidy_err!(err, skip_trailing_newlines, "missing trailing newline"),
|
||||
1 => {}
|
||||
n => tidy_error!(bad, "{}: too many trailing newlines ({})", file.display(), n),
|
||||
n => suppressible_tidy_err!(
|
||||
err,
|
||||
skip_trailing_newlines,
|
||||
&format!("too many trailing newlines ({})", n)
|
||||
),
|
||||
};
|
||||
if lines > LINES {
|
||||
let mut err = |_| {
|
||||
@ -247,6 +256,9 @@ pub fn check(path: &Path, bad: &mut bool) {
|
||||
if let Directive::Ignore(false) = skip_end_whitespace {
|
||||
tidy_error!(bad, "{}: ignoring trailing whitespace unnecessarily", file.display());
|
||||
}
|
||||
if let Directive::Ignore(false) = skip_trailing_newlines {
|
||||
tidy_error!(bad, "{}: ignoring trailing newlines unnecessarily", file.display());
|
||||
}
|
||||
if let Directive::Ignore(false) = skip_copyright {
|
||||
tidy_error!(bad, "{}: ignoring copyright unnecessarily", file.display());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user