Skip to content

Commit 0134871

Browse files
Allow list for refers_to rule (#23)
Signed-off-by: Thomas Sedlmayer <tsedlmayer@pmsfit.de>
1 parent d22aa4a commit 0134871

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

qc_ositrace/checks/osirules/osirules_checker.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -405,17 +405,17 @@ def check_message_against_rules(
405405
description=f"Field '{field.name}' value {value.value} in message '{message.DESCRIPTOR.full_name}' does not refer to any existing message.",
406406
)
407407
else:
408-
# Check if referred message matches the expected type
409-
expected_type = f"""osi3.{rule['refers_to'].strip("'")}"""
410-
if referred_message.DESCRIPTOR.full_name != expected_type:
408+
# Check if referred message matches one of the expected types
409+
expected_types = ["osi3." + t for t in rule['refers_to']] if isinstance(rule['refers_to'], list) else ["osi3." + rule['refers_to']]
410+
if referred_message.DESCRIPTOR.full_name not in expected_types:
411411
register_issue(
412412
result,
413413
message,
414414
index,
415415
time,
416416
rule_uid,
417417
IssueSeverity.ERROR,
418-
description=f"Field '{field.name}' value {value.value} in message '{message.DESCRIPTOR.full_name}' refers to message '{referred_message.DESCRIPTOR.full_name}', which does not match the expected type '{expected_type}'.",
418+
description=f"Field '{field.name}' value {value.value} in message '{message.DESCRIPTOR.full_name}' refers to message '{referred_message.DESCRIPTOR.full_name}', which does not match one of the expected types '{expected_types}'.",
419419
)
420420

421421
# Recursively check nested messages

0 commit comments

Comments
 (0)