Skip to content

Commit

Permalink
Added check for copyright notices.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Regueiro committed Jan 13, 2019
1 parent 88336ea commit 49143e0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/tools/tidy/src/style.rs
Expand Up @@ -111,6 +111,7 @@ pub fn check(path: &Path, bad: &mut bool) {
let skip_tab = contents.contains("ignore-tidy-tab");
let skip_length = contents.contains("ignore-tidy-linelength");
let skip_end_whitespace = contents.contains("ignore-tidy-end-whitespace");
let skip_copyright = contents.contains("ignore-tidy-copyright");
let mut trailing_new_lines = 0;
for (i, line) in contents.split('\n').enumerate() {
let mut err = |msg: &str| {
Expand All @@ -120,13 +121,13 @@ pub fn check(path: &Path, bad: &mut bool) {
&& !long_line_is_ok(line) {
err(&format!("line longer than {} chars", COLS));
}
if line.contains('\t') && !skip_tab {
if !skip_tab && line.contains('\t') {
err("tab character");
}
if !skip_end_whitespace && (line.ends_with(' ') || line.ends_with('\t')) {
err("trailing whitespace");
}
if line.contains('\r') && !skip_cr {
if !skip_cr && line.contains('\r') {
err("CR character");
}
if filename != "style.rs" {
Expand All @@ -137,6 +138,13 @@ pub fn check(path: &Path, bad: &mut bool) {
err("XXX is deprecated; use FIXME")
}
}
if !skip_copyright && (line.starts_with("// Copyright") ||
line.starts_with("# Copyright") ||
line.starts_with("Copyright"))
&& (line.contains("Rust Developers") ||
line.contains("Rust Project Developers")) {
err("copyright notices attributed to the Rust Project Developers are deprecated");
}
if line.ends_with("```ignore") || line.ends_with("```rust,ignore") {
err(UNEXPLAINED_IGNORE_DOCTEST_INFO);
}
Expand Down

0 comments on commit 49143e0

Please sign in to comment.