Skip to content

Commit

Permalink
Add warning message when more than one rules are registered to check (#…
Browse files Browse the repository at this point in the history
…31)

Signed-off-by: hoangtungdinh <11166240+hoangtungdinh@users.noreply.github.com>
  • Loading branch information
hoangtungdinh authored Sep 10, 2024
1 parent e2fec27 commit 34d6e57
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions qc_baselib/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 34d6e57

Please sign in to comment.