From 34d6e5702d21ae3d0a2a5b01817ef4c01a57745b Mon Sep 17 00:00:00 2001 From: Hoang Tung Dinh Date: Tue, 10 Sep 2024 18:09:31 +0200 Subject: [PATCH] Add warning message when more than one rules are registered to check (#31) Signed-off-by: hoangtungdinh <11166240+hoangtungdinh@users.noreply.github.com> --- qc_baselib/result.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/qc_baselib/result.py b/qc_baselib/result.py index a5a0b6e..eaf1a1f 100644 --- a/qc_baselib/result.py +++ b/qc_baselib/result.py @@ -8,6 +8,7 @@ from typing import Union, List, Set from lxml import etree from .models import IssueSeverity, result +import logging REPORT_OUTPUT_FORMAT = "xqar" DEFAULT_REPORT_VERSION = "0.0.1" @@ -281,6 +282,16 @@ def register_rule( checker = self._get_checker(bundle=bundle, checker_id=checker_id) checker.addressed_rule.append(rule) + number_of_addressed_rules = len(checker.addressed_rule) + if number_of_addressed_rules > 1: + logging.warning( + f"There are {number_of_addressed_rules} rules registered to the check" + f" {checker_id}. A check should address exactly one rule, unless there" + " is a strong reason not to. See the following document for more" + " information:" + " https://github.com/asam-ev/qc-framework/blob/main/doc/manual/checker_library.md#check-characteristics" + ) + return rule.rule_uid def register_issue(