Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion PythonScripts/audit_translations/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Handles parsing of rule files and unicode files to extract rule information.
"""

import re
from pathlib import Path
from typing import Any

Expand Down Expand Up @@ -127,7 +128,7 @@ def parse_unicode_file(content: str, data: Any) -> list[RuleInfo]:

def has_audit_ignore(content: str) -> bool:
"""Check if the rule content contains an audit-ignore comment"""
return "# audit-ignore" in content
return re.search(r"#\s*audit-ignore\b", content) is not None


def find_untranslated_text_entries(node: Any) -> list[UntranslatedEntry]:
Expand Down
8 changes: 8 additions & 0 deletions PythonScripts/audit_translations/tests/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ def test_detects_audit_ignore_comment(self):
"""Ensure detects audit ignore comment."""
assert has_audit_ignore("- name: foo\n # audit-ignore\n tag: bar")

def test_detects_audit_ignore_with_extra_spaces(self):
"""Ensure detects audit ignore when the comment has extra spaces."""
assert has_audit_ignore("- name: foo\n # audit-ignore\n tag: bar")

def test_detects_audit_ignore_with_tab_after_hash(self):
"""Ensure detects audit ignore when the comment uses a tab after the hash."""
assert has_audit_ignore("- name: foo\n #\taudit-ignore\n tag: bar")

def test_detects_inline_audit_ignore(self):
"""Ensure detects inline audit ignore."""
assert has_audit_ignore("- name: foo # audit-ignore")
Expand Down
Loading