Skip to content

Commit 1dfdc29

Browse files
michalsieronpriv-kweihmann
authored andcommitted
oelint.vars.pathhardcode: Skip regex if path not in line
As it turns out, checking if searched path is present in line before we do the search with regex, can cut down time by another 50%. Signed-off-by: Michal Sieron <michalwsieron@gmail.com>
1 parent 45d297c commit 1dfdc29

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

oelint_adv/rule_base/rule_vars_pathhardcode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def check(self, _file: str, stash: Stash) -> List[Tuple[str, int, str]]:
5757
pre = '(' + '|'.join(['^', "'", '"', ' ', r'\$\{D\}', '=']) + ')'
5858
ext = '(' + '|'.join([' ', '/', '"', r'\*', '$']) + ')'
5959
for line in i.get_items():
60-
if line.strip().startswith('#'):
60+
if line.strip().startswith('#') or k not in line:
6161
continue
6262
_match = RegexRpl.search(pre + k + ext, line)
6363
if _match and k not in _matches:

0 commit comments

Comments
 (0)