From a5266e1c19d279e558f0c68e0709423d75f67ddf Mon Sep 17 00:00:00 2001 From: Alexandre Bard Date: Tue, 3 Dec 2024 13:22:38 +0000 Subject: [PATCH] oelint.file.underscores: accept dashes in version numbers The initial code is complaining about dashes in the version part of the filename for no really good reason. Signed-off-by: Alexandre Bard --- oelint_adv/rule_base/rule_file_underscores.py | 5 ++--- tests/test_class_oelint_file_underscores.py | 10 +++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/oelint_adv/rule_base/rule_file_underscores.py b/oelint_adv/rule_base/rule_file_underscores.py index 7343c1f4..56658a46 100644 --- a/oelint_adv/rule_base/rule_file_underscores.py +++ b/oelint_adv/rule_base/rule_file_underscores.py @@ -19,12 +19,11 @@ def check(self, _file: str, stash: Stash) -> List[Tuple[str, int, str]]: if _ext in ['.bb']: # pragma: no cover if stash.IsPackageGroup(_file) or stash.IsImage(_file): return [] - _sep = [x for x in _basename if x in ['_', '-']] - _us = [x for x in _sep if x == '_'] + _us = [x for x in _basename if x == '_'] if len(_us) > 1: res += self.finding(_file, 1, override_msg='Filename should not contain more than one \'_\'') - elif not _us or _sep[-1] != '_': + elif not _us: res += self.finding( _file, 1, override_msg='Filename should contain at least one \'_\' in the end') return res diff --git a/tests/test_class_oelint_file_underscores.py b/tests/test_class_oelint_file_underscores.py index b567ad1b..2c7d9a25 100644 --- a/tests/test_class_oelint_file_underscores.py +++ b/tests/test_class_oelint_file_underscores.py @@ -10,7 +10,7 @@ class TestClassOelintFileUnderscores(TestBaseClass): @pytest.mark.parametrize('input_', [ { - 'oelint_adv-test.bb': + 'oelint_adv_test-1.2.3.bb': 'VAR = "1"', }, { @@ -30,6 +30,14 @@ def test_bad(self, input_, id_, occurrence): @pytest.mark.parametrize('occurrence', [0]) @pytest.mark.parametrize('input_', [ + { + 'oelint_adv-test.bb': + 'VAR = "1"', + }, + { + 'oelint-adv_test-1.2.3.bb': + 'VAR = "1"', + }, { 'oelint_adv_test.bb': 'inherit core-image',