Skip to content

Commit

Permalink
feat: solve "toDog" false positive (#44)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
Lum-CBayer and pre-commit-ci[bot] authored Nov 18, 2024
1 parent 6159e88 commit 9526f2e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dev_tools/check_jira_reference_in_todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
def line_has_incorrect_todo(line: str) -> bool:
return (
not re.compile(r"^.*(?=TODO\([A-Z]+\-[0-9]+\)\:).*").search(line)
if re.compile(r"^.*(?=(?i:to-?do)|TO DO)(?!todo[\w-]+|toDouble|tOdometry)").search(line)
if re.compile(r"^.*(?=(?i:to-?do)|TO DO)(?!(?i:to-?do)[\w-]+)").search(line)
else False
)

Expand Down
16 changes: 8 additions & 8 deletions tests/test_check_jira_reference_in_todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,7 @@


@pytest.mark.parametrize("content", ["TODO(ABC-1234):", "# TODO(ABC-1234):", "TODO(ABC-1234): remove code"])
def test_line_has_incorrect_todo_for_no_incorrect_todo(content: str) -> None:
assert not line_has_incorrect_todo(content)


@pytest.mark.parametrize(
"content", ["todoom", "todo-color", "toDouble()", "setOdometry()", "getOdometry", "to download"]
)
def test_line_has_incorrect_todo_for_no_undetected_todo(content: str) -> None:
def test_line_has_incorrect_todo_for_correct_todo(content: str) -> None:
assert not line_has_incorrect_todo(content)


Expand All @@ -42,6 +35,13 @@ def test_line_has_incorrect_todo_for_incorrect_todo(content: str) -> None:
assert line_has_incorrect_todo(content)


@pytest.mark.parametrize(
"content", ["todoom", "todo-color", "toDouble()", "setOdometry()", "getOdometry", "to download", "toDog"]
)
def test_line_has_incorrect_todo_for_non_jira_todos(content: str) -> None:
assert not line_has_incorrect_todo(content)


@pytest.mark.parametrize("content", ["TODO(ABC-1234):", "# TODO(ABC-1234):", "TODO(ABC-1234): remove code"])
def test_find_files_with_correct_jira_reference_in_todo(fs: FakeFilesystem, content: str) -> None:
fs.create_file(Path("Repo/file.py"), contents=content)
Expand Down

0 comments on commit 9526f2e

Please sign in to comment.