diff --git a/oelint_adv/__main__.py b/oelint_adv/__main__.py index 649dc5a8..efa1da38 100644 --- a/oelint_adv/__main__.py +++ b/oelint_adv/__main__.py @@ -341,7 +341,7 @@ def run(args): def rule_applicable(rule): if isinstance(rule, Rule): - res = not _rule_file or rule.ID in _rule_file + res = not _rule_file or any(x in _rule_file for x in rule.get_ids()) # pragma: no cover res &= rule.ID not in get_suppressions() else: res = not _rule_file or rule in _rule_file diff --git a/tests/test_user_interface.py b/tests/test_user_interface.py index 41f506a9..84003f46 100644 --- a/tests/test_user_interface.py +++ b/tests/test_user_interface.py @@ -649,6 +649,34 @@ def test_rulefile(self, input_): issues = [x[1] for x in run(_args)] assert(any(issues)) + @pytest.mark.parametrize('input_', + [ + { + 'oelint adv-test.bb': + ''' + A = "1" + ''', + }, + ], + ) + def test_rulefile_subids_only(self, input_): + # local imports only + from oelint_adv.__main__ import run + + _rule_file = { + "oelint.var.mandatoryvar.DESCRIPTION": "error", + "oelint.var.mandatoryvar.LICENSE": "error", + "oelint.var.mandatoryvar.SRC_URI": "error" + } + + _cstfile = self._create_tempfile('rules.json', json.dumps(_rule_file)) + + _args = self._create_args( + input_, extraopts=['--rulefile={file}'.format(file=_cstfile)]) + issues = [x[1] for x in run(_args)] + assert(not any(any(x.startswith(y) for y in _rule_file.keys()) for x in issues)) + + @pytest.mark.parametrize('input_', [ { @@ -687,7 +715,7 @@ def test_rulefile_filtering2(self, input_): _args = self._create_args( input_, extraopts=['--rulefile={file}'.format(file=_cstfile)]) issues = [x[1] for x in run(_args)] - assert(not any(issues)) + assert(not any("oelint.var.mandatoryvar.DESCRIPTION" in x for x in issues)) @pytest.mark.parametrize('input_', [