Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a warning message when multiple rules are registered to a check #31

Merged
merged 1 commit into from
Sep 10, 2024
Merged
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
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