This commit is contained in:
Dan Parizher 2025-12-16 16:40:21 -05:00 committed by GitHub
commit be309f8d99
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 150 additions and 0 deletions

View File

@ -41,3 +41,27 @@ def foo(x):
# TODO: A todo with a random number, 5431 # TODO: A todo with a random number, 5431
# TODO: here's a TODO on the last line with no link # TODO: here's a TODO on the last line with no link
# Valid Jira-style patterns (should pass)
# TODO: Move this part to the other place RFFU-6877
# TODO: Fix this (AIRFLOW-123)
# TODO: Update config (SUPERSET-456)
# TODO: PROJ-123: Another Jira-style example with colon
# TODO: ABC-456: Fix bug with colon
# Invalid patterns that should still trigger TD003 (should fail)
# TODO: PROJ-123 Another Jira-style example
# TODO: Fix bug ABC-123
# TODO: Implement feature XYZ-456
# TODO: Update documentation DEF-789
# TODO: Refactor code GHI-101112
# TODO: Single letter project key A-1
# TODO: No hyphen pattern ABC123
# TODO: Lowercase project key abc-123
# TODO: Mixed case project key AbC-123
# TODO: Just a random word with hyphen and number random-123
# TODO: Number before letters 123-ABC
# TODO: Multiple hyphens ABC-123-456
# TODO: Empty project key -123
# TODO: This is about PROJ-123 server config (ID in middle of sentence)
# TODO: Working on PROJ-123 and PROJ-456 (multiple IDs)

View File

@ -102,6 +102,10 @@ impl Violation for MissingTodoAuthor {
/// ///
/// # TODO(charlie): this comment has an issue code (matches the regex `[A-Z]+\-?\d+`) /// # TODO(charlie): this comment has an issue code (matches the regex `[A-Z]+\-?\d+`)
/// # SIXCHR-003 /// # SIXCHR-003
///
/// # TODO(charlie): PROJ-123 this comment has a Jira-style issue ID on the same line
///
/// # TODO(charlie): Fix bug ABC-456 another Jira-style example
/// ``` /// ```
#[derive(ViolationMetadata)] #[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.269")] #[violation_metadata(stable_since = "v0.0.269")]
@ -251,6 +255,9 @@ static ISSUE_LINK_TODO_LINE_REGEX_SET: LazyLock<RegexSet> = LazyLock::new(|| {
RegexSet::new([ RegexSet::new([
r"\s*(http|https)://.*", // issue link r"\s*(http|https)://.*", // issue link
r"\s*#\d+.*", // issue code - like "#003" r"\s*#\d+.*", // issue code - like "#003"
r"\s*[A-Z]{2,}-\d+\s*$", // Jira-style issue code at end of line - like "RFFU-6877"
r"\s*\([A-Z]{2,}-\d+\)", // Jira-style issue code in parentheses - like "(RFFU-6877)"
r"\s*[A-Z]{2,}-\d+\s*:", // Jira-style issue code followed by colon - like "RFFU-6877:"
]) ])
.unwrap() .unwrap()
}); });

View File

@ -61,4 +61,123 @@ TD003 Missing issue link for this TODO
42 | 42 |
43 | # TODO: here's a TODO on the last line with no link 43 | # TODO: here's a TODO on the last line with no link
| ^^^^ | ^^^^
44 |
45 | # Valid Jira-style patterns (should pass)
|
TD003 Missing issue link for this TODO
--> TD003.py:53:3
|
52 | # Invalid patterns that should still trigger TD003 (should fail)
53 | # TODO: PROJ-123 Another Jira-style example
| ^^^^
54 | # TODO: Fix bug ABC-123
55 | # TODO: Implement feature XYZ-456
|
TD003 Missing issue link for this TODO
--> TD003.py:58:3
|
56 | # TODO: Update documentation DEF-789
57 | # TODO: Refactor code GHI-101112
58 | # TODO: Single letter project key A-1
| ^^^^
59 | # TODO: No hyphen pattern ABC123
60 | # TODO: Lowercase project key abc-123
|
TD003 Missing issue link for this TODO
--> TD003.py:59:3
|
57 | # TODO: Refactor code GHI-101112
58 | # TODO: Single letter project key A-1
59 | # TODO: No hyphen pattern ABC123
| ^^^^
60 | # TODO: Lowercase project key abc-123
61 | # TODO: Mixed case project key AbC-123
|
TD003 Missing issue link for this TODO
--> TD003.py:60:3
|
58 | # TODO: Single letter project key A-1
59 | # TODO: No hyphen pattern ABC123
60 | # TODO: Lowercase project key abc-123
| ^^^^
61 | # TODO: Mixed case project key AbC-123
62 | # TODO: Just a random word with hyphen and number random-123
|
TD003 Missing issue link for this TODO
--> TD003.py:61:3
|
59 | # TODO: No hyphen pattern ABC123
60 | # TODO: Lowercase project key abc-123
61 | # TODO: Mixed case project key AbC-123
| ^^^^
62 | # TODO: Just a random word with hyphen and number random-123
63 | # TODO: Number before letters 123-ABC
|
TD003 Missing issue link for this TODO
--> TD003.py:62:3
|
60 | # TODO: Lowercase project key abc-123
61 | # TODO: Mixed case project key AbC-123
62 | # TODO: Just a random word with hyphen and number random-123
| ^^^^
63 | # TODO: Number before letters 123-ABC
64 | # TODO: Multiple hyphens ABC-123-456
|
TD003 Missing issue link for this TODO
--> TD003.py:63:3
|
61 | # TODO: Mixed case project key AbC-123
62 | # TODO: Just a random word with hyphen and number random-123
63 | # TODO: Number before letters 123-ABC
| ^^^^
64 | # TODO: Multiple hyphens ABC-123-456
65 | # TODO: Empty project key -123
|
TD003 Missing issue link for this TODO
--> TD003.py:64:3
|
62 | # TODO: Just a random word with hyphen and number random-123
63 | # TODO: Number before letters 123-ABC
64 | # TODO: Multiple hyphens ABC-123-456
| ^^^^
65 | # TODO: Empty project key -123
66 | # TODO: This is about PROJ-123 server config (ID in middle of sentence)
|
TD003 Missing issue link for this TODO
--> TD003.py:65:3
|
63 | # TODO: Number before letters 123-ABC
64 | # TODO: Multiple hyphens ABC-123-456
65 | # TODO: Empty project key -123
| ^^^^
66 | # TODO: This is about PROJ-123 server config (ID in middle of sentence)
67 | # TODO: Working on PROJ-123 and PROJ-456 (multiple IDs)
|
TD003 Missing issue link for this TODO
--> TD003.py:66:3
|
64 | # TODO: Multiple hyphens ABC-123-456
65 | # TODO: Empty project key -123
66 | # TODO: This is about PROJ-123 server config (ID in middle of sentence)
| ^^^^
67 | # TODO: Working on PROJ-123 and PROJ-456 (multiple IDs)
|
TD003 Missing issue link for this TODO
--> TD003.py:67:3
|
65 | # TODO: Empty project key -123
66 | # TODO: This is about PROJ-123 server config (ID in middle of sentence)
67 | # TODO: Working on PROJ-123 and PROJ-456 (multiple IDs)
| ^^^^
| |