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):