diff --git a/oelint_adv/rule_base/rule_var_misspell.py b/oelint_adv/rule_base/rule_var_misspell.py index 975ab5f1..758374fd 100644 --- a/oelint_adv/rule_base/rule_var_misspell.py +++ b/oelint_adv/rule_base/rule_var_misspell.py @@ -4,6 +4,7 @@ from oelint_parser.cls_item import Variable from oelint_parser.constants import CONSTANTS from oelint_parser.helper_files import get_valid_package_names +from oelint_parser.helper_files import get_valid_named_resources class VarMisspell(Rule): @@ -12,7 +13,7 @@ def __init__(self): severity='warning', message='') - def get_best_match(self, item, _list, minconfidence=0.8): + def get_best_match(self, item, _list, minconfidence=0.5): _dict = sorted([(SequenceMatcher(None, item, k).ratio(), k) for k in _list], key=lambda x: x[0], reverse=True) if _dict and _dict[0][0] >= minconfidence: @@ -24,6 +25,7 @@ def check(self, _file, stash): items = stash.GetItemsFor(filename=_file, classifier=Variable.CLASSIFIER, attribute=Variable.ATTR_VAR) _all = stash.GetItemsFor(filename=_file) + _extras = [f'SRCREV_{x}' for x in get_valid_named_resources(stash, _file)] for i in items: _cleanvarname = i.VarName for pkg in get_valid_package_names(stash, _file, strippn=True): @@ -34,6 +36,8 @@ def check(self, _file, stash): _cleanvarname.rsplit(pkg, 1)) # pragma: no cover if _cleanvarname in CONSTANTS.VariablesKnown: continue + if _cleanvarname in _extras: + continue _used = False for a in _all: if a == i: diff --git a/tests/test_class_oelint_vars_misspell.py b/tests/test_class_oelint_vars_misspell.py index 60fdf77d..aff4fe41 100644 --- a/tests/test_class_oelint_vars_misspell.py +++ b/tests/test_class_oelint_vars_misspell.py @@ -58,6 +58,17 @@ def test_bad(self, input_, id_, occurrence): INITSCRIPT_PARAMS_${PN}-foo = "bar" ''', }, + { + 'oelint_adv_test.bb': + ''' + FOO:qemux86 = "1" + + SRC_URI = "git://github.com/znc/znc.git;name=znc;branch=master;protocol=https \\ + git://github.com/jimloco/Csocket.git;destsuffix=git/third_party/Csocket;name=Csocket;branch=master;protocol=https" + SRCREV_znc = "bf253640d33d03331310778e001fb6f5aba2989e" + SRCREV_Csocket = "e8d9e0bb248c521c2c7fa01e1c6a116d929c41b4" + ''', + }, ], ) def test_good(self, input_, id_, occurrence):