Skip to content

Commit

Permalink
E206: Fix multiline nested JSON false positive
Browse files Browse the repository at this point in the history
When using a nested JSON object spanned on multiple lines in a Jinja2
context ansible-lint raises a false positive E206 error.

This commit extends the regex in charge of excluding false positive JSON
objects so that it handles multiline matching.

Fixes #1671
  • Loading branch information
simonkeyd committed Jul 17, 2021
1 parent 21e389f commit b463caf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/ansiblelint/rules/VariableHasSpacesRule.py
Expand Up @@ -20,7 +20,7 @@ class VariableHasSpacesRule(AnsibleLintRule):
version_added = 'v4.0.0'

bracket_regex = re.compile(r"{{[^{\n' -]|[^ '\n}-]}}", re.MULTILINE | re.DOTALL)
exclude_json_re = re.compile(r"[^{]{'\w+': ?[^{]{.*?}}")
exclude_json_re = re.compile(r"[^{]{'\w+': ?[^{]{.*?}}", re.MULTILINE | re.DOTALL)

def matchtask(
self, task: Dict[str, Any], file: Optional[Lintable] = None
Expand Down

0 comments on commit b463caf

Please sign in to comment.