diff --git a/README.md b/README.md index 2bac378f..0f2d22bc 100644 --- a/README.md +++ b/README.md @@ -458,16 +458,17 @@ You can find an example file [here](docs/.oelint.cfg.example) You can suppress one or more checks on a line by line basis ```bitbake -# nooelint: [,,...] +# nooelint: [,,...][ comment] ``` suppresses all the specified IDs for the next line. Multiple IDs can be separated by commas. +You can add a comment after the ids and separated by at least a single space. ### Example ```bitbake -# nooelint: oelint.vars.insaneskip +# nooelint: oelint.vars.insaneskip - this is an acceptable risk here INSANE_SKIP:${PN} = "foo" ``` diff --git a/oelint_adv/core.py b/oelint_adv/core.py index 3daaf3a0..f1b4d8d0 100644 --- a/oelint_adv/core.py +++ b/oelint_adv/core.py @@ -204,7 +204,7 @@ def group_run(group: List[Tuple], if item.Origin not in inline_supp_map: # pragma: no cover inline_supp_map[item.Origin] = {} inline_supp_map[item.Origin][item.InFileLine] = [ - x.strip() for x in m.group('ids').split(',') if x] + x.strip() for x in re.split(r',|\s+', m.group('ids')) if x] state.inline_suppressions = {**state.inline_suppressions, **inline_supp_map} @@ -237,10 +237,13 @@ def group_run(group: List[Tuple], lvl='debug', msg='Applied automatic fixes')) if any(isinstance(x, FileNotApplicableInlineSuppression) for x in rules): + known_ids = list(itertools.chain(*[x.get_ids() for x in rules])) for _file, _lineobj in inline_supp_map.items(): for _line, _ids in _lineobj.items(): for _id in _ids: if not state.get_inline_suppression_seen(_file, _line, _id): + if _id not in known_ids: + continue obj = FileNotApplicableInlineSuppression(state) issues += obj.finding(_file, _line, override_msg=obj.Msg.format(id=_id)) diff --git a/tests/test_class_oelint_inlinesupp.py b/tests/test_class_oelint_inlinesupp.py index 9cb0e4cc..46c66b68 100644 --- a/tests/test_class_oelint_inlinesupp.py +++ b/tests/test_class_oelint_inlinesupp.py @@ -12,14 +12,14 @@ class TestClassOelintNAInlineSuppression(TestBaseClass): { 'oelint_adv_test.bb': ''' - # nooelint: foo.bar.baz + # nooelint: oelint.var.badimagefeature A = "2" ''', }, { 'oelint_adv_test.bb': ''' - # nooelint: oelint.vars.mispell, foo.bar.baz + # nooelint: oelint.vars.mispell, oelint.var.badimagefeature SRR_URI = "2" ''', }, diff --git a/tests/test_inlinesuppressions.py b/tests/test_inlinesuppressions.py index 563e1c88..32ae3db6 100644 --- a/tests/test_inlinesuppressions.py +++ b/tests/test_inlinesuppressions.py @@ -162,3 +162,20 @@ def test_inlinesuppressions_multiple_scope(self, input_): def test_inlinesuppressions_remove_empty(self, input_): self.check_for_id(self._create_args(input_), 'oelint.var.badimagefeature', 0) + + @pytest.mark.parametrize('input_', + [ + { + 'oelint adv-test.bb': + ''' + # nooelint: oelint.var.badimagefeature.allow-empty-password - this is a comment + IMAGE_FEATURES:append = " \ + allow-empty-password \ + " + ''', + }, + ], + ) + def test_inlinesuppressions_with_comment(self, input_): + self.check_for_id(self._create_args(input_), + 'oelint.var.badimagefeature', 0)