Skip to content

Commit d05266b

Browse files
committed
Migrate the fluent_lowercase check to diagnostics
1 parent 8f09140 commit d05266b

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/tools/tidy/src/fluent_lowercase.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::path::Path;
44

55
use fluent_syntax::ast::{Entry, Message, PatternElement};
66

7+
use crate::diagnostics::{CheckId, DiagCtx, RunningCheck};
78
use crate::walk::{filter_dirs, walk};
89

910
#[rustfmt::skip]
@@ -34,7 +35,7 @@ fn is_allowed_capitalized_word(msg: &str) -> bool {
3435
})
3536
}
3637

37-
fn check_lowercase(filename: &str, contents: &str, bad: &mut bool) {
38+
fn check_lowercase(filename: &str, contents: &str, check: &mut RunningCheck) {
3839
let (Ok(parse) | Err((parse, _))) = fluent_syntax::parser::parse(contents);
3940

4041
for entry in &parse.body {
@@ -45,20 +46,20 @@ fn check_lowercase(filename: &str, contents: &str, bad: &mut bool) {
4546
&& value.chars().next().is_some_and(char::is_uppercase)
4647
&& !is_allowed_capitalized_word(value)
4748
{
48-
tidy_error!(
49-
bad,
49+
check.error(format!(
5050
"{filename}: message `{value}` starts with an uppercase letter. Fix it or add it to `ALLOWED_CAPITALIZED_WORDS`"
51-
);
51+
));
5252
}
5353
}
5454
}
5555

56-
pub fn check(path: &Path, bad: &mut bool) {
56+
pub fn check(path: &Path, diag_ctx: DiagCtx) {
57+
let mut check = diag_ctx.start_check(CheckId::new("fluent_lowercase").path(path));
5758
walk(
5859
path,
5960
|path, is_dir| filter_dirs(path) || (!is_dir && filter_fluent(path)),
6061
&mut |ent, contents| {
61-
check_lowercase(ent.path().to_str().unwrap(), contents, bad);
62+
check_lowercase(ent.path().to_str().unwrap(), contents, &mut check);
6263
},
6364
);
6465
}

src/tools/tidy/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ fn main() {
121121
check!(error_codes, &root_path, &[&compiler_path, &librustdoc_path], &ci_info);
122122
check!(fluent_alphabetical, &compiler_path, bless);
123123
check!(fluent_period, &compiler_path);
124-
// check!(fluent_lowercase, &compiler_path);
124+
check!(fluent_lowercase, &compiler_path);
125125
// check!(target_policy, &root_path);
126126
// check!(gcc_submodule, &root_path, &compiler_path);
127127

0 commit comments

Comments
 (0)