Skip to content

Commit 0dbfa8d

Browse files
TD003: remove issue code length restriction (#15175)
Co-authored-by: Micha Reiser <micha@reiser.io>
1 parent 1218bc6 commit 0dbfa8d

File tree

3 files changed

+34
-28
lines changed

3 files changed

+34
-28
lines changed

crates/ruff_linter/resources/test/fixtures/flake8_todos/TD003.py

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
# TODO: this comment has an issue
66
# TDO-3870
77

8+
# TODO: the link has an issue code of the minimum length
9+
# T-001
10+
11+
# TODO: the issue code can be arbitrarily long
12+
# ABCDEFGHIJKLMNOPQRSTUVWXYZ-001
13+
814
# TDO003 - errors
915
# TODO: this comment has no
1016
# link after it

crates/ruff_linter/src/rules/flake8_todos/rules/todos.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl Violation for MissingTodoAuthor {
9191
/// # TODO(charlie): this comment has a 3-digit issue code
9292
/// # 003
9393
///
94-
/// # TODO(charlie): this comment has an issue code of (up to) 6 characters, then digits
94+
/// # TODO(charlie): this comment has an issue code (matches the regex `[A-Z]+\-?\d+`)
9595
/// # SIXCHR-003
9696
/// ```
9797
#[derive(ViolationMetadata)]
@@ -228,7 +228,7 @@ static ISSUE_LINK_REGEX_SET: LazyLock<RegexSet> = LazyLock::new(|| {
228228
RegexSet::new([
229229
r"^#\s*(http|https)://.*", // issue link
230230
r"^#\s*\d+$", // issue code - like "003"
231-
r"^#\s*[A-Z]{1,6}\-?\d+$", // issue code - like "TD003"
231+
r"^#\s*[A-Z]+\-?\d+$", // issue code - like "TD003"
232232
])
233233
.unwrap()
234234
});

crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-todo-link_TD003.py.snap

+26-26
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,48 @@
22
source: crates/ruff_linter/src/rules/flake8_todos/mod.rs
33
snapshot_kind: text
44
---
5-
TD003.py:9:3: TD003 Missing issue link on the line following this TODO
5+
TD003.py:15:3: TD003 Missing issue link on the line following this TODO
66
|
7-
8 | # TDO003 - errors
8-
9 | # TODO: this comment has no
7+
14 | # TDO003 - errors
8+
15 | # TODO: this comment has no
99
| ^^^^ TD003
10-
10 | # link after it
10+
16 | # link after it
1111
|
1212

13-
TD003.py:12:3: TD003 Missing issue link on the line following this TODO
13+
TD003.py:18:3: TD003 Missing issue link on the line following this TODO
1414
|
15-
10 | # link after it
16-
11 |
17-
12 | # TODO: here's a TODO with no link after it
15+
16 | # link after it
16+
17 |
17+
18 | # TODO: here's a TODO with no link after it
1818
| ^^^^ TD003
19-
13 | def foo(x):
20-
14 | return x
19+
19 | def foo(x):
20+
20 | return x
2121
|
2222

23-
TD003.py:25:3: TD003 Missing issue link on the line following this TODO
23+
TD003.py:31:3: TD003 Missing issue link on the line following this TODO
2424
|
25-
23 | # TDO-3870
26-
24 |
27-
25 | # TODO: here's a TODO without an issue link
25+
29 | # TDO-3870
26+
30 |
27+
31 | # TODO: here's a TODO without an issue link
2828
| ^^^^ TD003
29-
26 | # TODO: followed by a new TODO with an issue link
30-
27 | # TDO-3870
29+
32 | # TODO: followed by a new TODO with an issue link
30+
33 | # TDO-3870
3131
|
3232

33-
TD003.py:29:9: TD003 Missing issue link on the line following this TODO
33+
TD003.py:35:9: TD003 Missing issue link on the line following this TODO
3434
|
35-
27 | # TDO-3870
36-
28 |
37-
29 | # foo # TODO: no link!
35+
33 | # TDO-3870
36+
34 |
37+
35 | # foo # TODO: no link!
3838
| ^^^^ TD003
39-
30 |
40-
31 | # TODO: here's a TODO on the last line with no link
39+
36 |
40+
37 | # TODO: here's a TODO on the last line with no link
4141
|
4242

43-
TD003.py:31:3: TD003 Missing issue link on the line following this TODO
43+
TD003.py:37:3: TD003 Missing issue link on the line following this TODO
4444
|
45-
29 | # foo # TODO: no link!
46-
30 |
47-
31 | # TODO: here's a TODO on the last line with no link
45+
35 | # foo # TODO: no link!
46+
36 |
47+
37 | # TODO: here's a TODO on the last line with no link
4848
| ^^^^ TD003
4949
|

0 commit comments

Comments
 (0)