mirror of https://github.com/astral-sh/ruff
Expand Jira-style issue ID detection in TD003
Updated the regex patterns to recognize Jira-style issue IDs at the end of lines, followed by spaces, and within parentheses. Added new test cases to ensure broader coverage and updated snapshot outputs to reflect the improved detection.
This commit is contained in:
parent
eee916e1b6
commit
c76df50d9d
|
|
@ -42,17 +42,17 @@ def foo(x):
|
||||||
|
|
||||||
# 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: Move this part to the other place RFFU-6877
|
||||||
|
|
||||||
# TODO: PROJ-123 Another Jira-style example
|
# TODO: PROJ-123 Another Jira-style example
|
||||||
|
|
||||||
# TODO: Valid Jira-style issue IDs (should pass)
|
|
||||||
# TODO: Fix bug ABC-123
|
# TODO: Fix bug ABC-123
|
||||||
# TODO: Implement feature XYZ-456
|
# TODO: Implement feature XYZ-456
|
||||||
# TODO: Update documentation DEF-789
|
# TODO: Update documentation DEF-789
|
||||||
# TODO: Refactor code GHI-101112
|
# TODO: Refactor code GHI-101112
|
||||||
|
# TODO: Fix this (AIRFLOW-123)
|
||||||
|
# TODO: Update config (SUPERSET-456)
|
||||||
|
|
||||||
# TODO: Invalid patterns that should still trigger TD003 (should fail)
|
# Invalid patterns that should still trigger TD003 (should fail)
|
||||||
# TODO: Single letter project key A-1
|
# TODO: Single letter project key A-1
|
||||||
# TODO: No hyphen pattern ABC123
|
# TODO: No hyphen pattern ABC123
|
||||||
# TODO: Lowercase project key abc-123
|
# TODO: Lowercase project key abc-123
|
||||||
|
|
@ -61,3 +61,5 @@ def foo(x):
|
||||||
# TODO: Number before letters 123-ABC
|
# TODO: Number before letters 123-ABC
|
||||||
# TODO: Multiple hyphens ABC-123-456
|
# TODO: Multiple hyphens ABC-123-456
|
||||||
# TODO: Empty project key -123
|
# 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)
|
||||||
|
|
|
||||||
|
|
@ -248,7 +248,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+.*", // Jira-style issue code - like "RFFU-6877"
|
r"\s*[A-Z]{2,}-\d+\s*$", // Jira-style issue code at end of line - like "RFFU-6877"
|
||||||
|
r"\s*[A-Z]{2,}-\d+\s", // Jira-style issue code followed by space - like "RFFU-6877 "
|
||||||
|
r"\s*\([A-Z]{2,}-\d+\)", // Jira-style issue code in parentheses - like "(RFFU-6877)"
|
||||||
])
|
])
|
||||||
.unwrap()
|
.unwrap()
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -62,35 +62,13 @@ TD003 Missing issue link for this TODO
|
||||||
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 |
|
44 |
|
||||||
45 | # TODO: Move this part to the other place RFFU-6877
|
45 | # Valid Jira-style patterns (should pass)
|
||||||
|
|
|
||||||
|
|
||||||
TD003 Missing issue link for this TODO
|
|
||||||
--> TD003.py:49:3
|
|
||||||
|
|
|
||||||
47 | # TODO: PROJ-123 Another Jira-style example
|
|
||||||
48 |
|
|
||||||
49 | # TODO: Valid Jira-style issue IDs (should pass)
|
|
||||||
| ^^^^
|
|
||||||
50 | # TODO: Fix bug ABC-123
|
|
||||||
51 | # TODO: Implement feature XYZ-456
|
|
||||||
|
|
|
||||||
|
|
||||||
TD003 Missing issue link for this TODO
|
|
||||||
--> TD003.py:55:3
|
|
||||||
|
|
|
||||||
53 | # TODO: Refactor code GHI-101112
|
|
||||||
54 |
|
|
||||||
55 | # TODO: Invalid patterns that should still trigger TD003 (should fail)
|
|
||||||
| ^^^^
|
|
||||||
56 | # TODO: Single letter project key A-1
|
|
||||||
57 | # TODO: No hyphen pattern ABC123
|
|
||||||
|
|
|
|
||||||
|
|
||||||
TD003 Missing issue link for this TODO
|
TD003 Missing issue link for this TODO
|
||||||
--> TD003.py:56:3
|
--> TD003.py:56:3
|
||||||
|
|
|
|
||||||
55 | # TODO: Invalid patterns that should still trigger TD003 (should fail)
|
55 | # Invalid patterns that should still trigger TD003 (should fail)
|
||||||
56 | # TODO: Single letter project key A-1
|
56 | # TODO: Single letter project key A-1
|
||||||
| ^^^^
|
| ^^^^
|
||||||
57 | # TODO: No hyphen pattern ABC123
|
57 | # TODO: No hyphen pattern ABC123
|
||||||
|
|
@ -100,7 +78,7 @@ TD003 Missing issue link for this TODO
|
||||||
TD003 Missing issue link for this TODO
|
TD003 Missing issue link for this TODO
|
||||||
--> TD003.py:57:3
|
--> TD003.py:57:3
|
||||||
|
|
|
|
||||||
55 | # TODO: Invalid patterns that should still trigger TD003 (should fail)
|
55 | # Invalid patterns that should still trigger TD003 (should fail)
|
||||||
56 | # TODO: Single letter project key A-1
|
56 | # TODO: Single letter project key A-1
|
||||||
57 | # TODO: No hyphen pattern ABC123
|
57 | # TODO: No hyphen pattern ABC123
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
|
@ -152,6 +130,17 @@ TD003 Missing issue link for this TODO
|
||||||
63 | # TODO: Empty project key -123
|
63 | # TODO: Empty project key -123
|
||||||
|
|
|
|
||||||
|
|
||||||
|
TD003 Missing issue link for this TODO
|
||||||
|
--> TD003.py:62:3
|
||||||
|
|
|
||||||
|
60 | # TODO: Just a random word with hyphen and number random-123
|
||||||
|
61 | # TODO: Number before letters 123-ABC
|
||||||
|
62 | # TODO: Multiple hyphens ABC-123-456
|
||||||
|
| ^^^^
|
||||||
|
63 | # TODO: Empty project key -123
|
||||||
|
64 | # TODO: This is about PROJ-123 server config (ID in middle of sentence)
|
||||||
|
|
|
||||||
|
|
||||||
TD003 Missing issue link for this TODO
|
TD003 Missing issue link for this TODO
|
||||||
--> TD003.py:63:3
|
--> TD003.py:63:3
|
||||||
|
|
|
|
||||||
|
|
@ -159,4 +148,6 @@ TD003 Missing issue link for this TODO
|
||||||
62 | # TODO: Multiple hyphens ABC-123-456
|
62 | # TODO: Multiple hyphens ABC-123-456
|
||||||
63 | # TODO: Empty project key -123
|
63 | # TODO: Empty project key -123
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
64 | # TODO: This is about PROJ-123 server config (ID in middle of sentence)
|
||||||
|
65 | # TODO: Working on PROJ-123 and PROJ-456 (multiple IDs)
|
||||||
|
|
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue