Skip to content

Commit dca1727

Browse files
authored
Merge pull request #2628 from rust-lang/tshepang/sembr
sembr src/contributing.md and improve it a bit
2 parents 18b1767 + 743b803 commit dca1727

File tree

2 files changed

+135
-99
lines changed

2 files changed

+135
-99
lines changed

src/doc/rustc-dev-guide/ci/sembr/src/main.rs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static REGEX_IGNORE: LazyLock<Regex> =
2727
static REGEX_IGNORE_END: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"(\.|\?|;|!)$").unwrap());
2828
static REGEX_IGNORE_LINK_TARGETS: LazyLock<Regex> =
2929
LazyLock::new(|| Regex::new(r"^\[.+\]: ").unwrap());
30-
static REGEX_SPLIT: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"(\.|\?|;|!)\s+").unwrap());
30+
static REGEX_SPLIT: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"(\.|[^r]\?|;|!)\s+").unwrap());
3131

3232
fn main() -> Result<()> {
3333
let cli = Cli::parse();
@@ -92,7 +92,7 @@ fn display(header: &str, paths: &[PathBuf]) {
9292

9393
fn ignore(line: &str, in_code_block: bool) -> bool {
9494
in_code_block
95-
|| line.contains("e.g.")
95+
|| line.to_lowercase().contains("e.g.")
9696
|| line.contains("i.e.")
9797
|| line.contains('|')
9898
|| line.trim_start().starts_with('>')
@@ -174,7 +174,9 @@ fn test_sembr() {
174174
must! be; split? and. normalizes space
175175
1. ignore numbered
176176
ignore | tables
177-
ignore e.g. and i.e.
177+
ignore e.g. and
178+
ignore i.e. and
179+
ignore E.g. too
178180
- ignore. list
179181
* ignore. list
180182
```
@@ -191,7 +193,9 @@ and.
191193
normalizes space
192194
1. ignore numbered
193195
ignore | tables
194-
ignore e.g. and i.e.
196+
ignore e.g. and
197+
ignore i.e. and
198+
ignore E.g. too
195199
- ignore. list
196200
* ignore. list
197201
```
@@ -269,3 +273,19 @@ hi again.
269273
let processed = lengthen_lines(&processed, 50);
270274
assert_eq!(expected, processed);
271275
}
276+
277+
#[test]
278+
fn test_sembr_question_mark() {
279+
let original = "\
280+
o? whatever
281+
r? @reviewer
282+
r? @reviewer
283+
";
284+
let expected = "\
285+
o?
286+
whatever
287+
r? @reviewer
288+
r? @reviewer
289+
";
290+
assert_eq!(expected, comply(original));
291+
}

0 commit comments

Comments
 (0)