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

rulefile: enabled use of subids only #443

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion oelint_adv/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 29 additions & 1 deletion tests/test_user_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_',
[
{
Expand Down Expand Up @@ -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_',
[
Expand Down