Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

var-spacing: fix multiline nested JSON false positive #1672

Conversation

simonkeyd
Copy link
Contributor

@simonkeyd simonkeyd commented Jul 16, 2021

This PR improves the testing on E206 rule, adds a false positive task in test case and finally fixes multiline nested JSON false positive.

Fixes: #1671

@simonkeyd simonkeyd requested a review from ssbarnea as a code owner July 16, 2021 15:11
Copy link
Member

@ssbarnea ssbarnea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that is a really useful fix, just be sure all jobs are reporting green.

@ssbarnea ssbarnea added the bug label Jul 16, 2021
VariableHasSpacesRule testing was limited to ensuring that the number of
error was matching an expected number. This could have potential
limitation where for example a commit prevents an real linting error
from being raised and in the same time raises an invalid one.

This commit aims at improving this rule's testing by ensuring that
errors are raised only on a controlled set of lines.

Related to: ansible#1671
This commit adds 4 new tasks in example playbook used for
VariableHasSpacesRule testing.

One of these rule is a nested multiline JSON object which has its
opening and closing brackets spanned on different lines. And this rule
raises false positive error.

Related to ansible#1671
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 ansible#1671
@simonkeyd simonkeyd force-pushed the pr/1671-fix-multiline-nested-json-false-positive branch from c278af1 to b463caf Compare July 17, 2021 23:42
@simonkeyd
Copy link
Contributor Author

@ssbarnea I just fixed the CI. PR is all set.

@ssbarnea ssbarnea changed the title E206: Fix multiline nested JSON false positive var-spacing: fix multiline nested JSON false positive Jul 18, 2021
@ssbarnea ssbarnea merged commit 04d68a0 into ansible:master Jul 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

E206 VariableHasSpacesRule: Fix multiline nested JSON false positive
2 participants