From b9dc369286c758697d8aaca60388b2ef6f26ea64 Mon Sep 17 00:00:00 2001 From: Niklas Hargarter Date: Tue, 11 Jun 2024 13:53:07 +0200 Subject: [PATCH] Doc: Add reasoning for replace vs strip in variable_redefinition --- troubadix/plugins/variable_redefinition_in_foreach.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/troubadix/plugins/variable_redefinition_in_foreach.py b/troubadix/plugins/variable_redefinition_in_foreach.py index 07b26e86..e4d70267 100644 --- a/troubadix/plugins/variable_redefinition_in_foreach.py +++ b/troubadix/plugins/variable_redefinition_in_foreach.py @@ -31,6 +31,11 @@ def check_content( for foreach_match in FOREACH_PATTERN.finditer(file_content): identifier = foreach_match.group("ident") + + # replace instead of strip, because the iterator can contain + # whitespace as part of the expression. + # Saving from further strip calls + # make_list( bar , foo ) iterator = foreach_match.group("iter").replace(" ", "") if make_list_match := MAKE_LIST_PATTERN.fullmatch(iterator):