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

jinja[readability]: Require/Fix | be surrounded by spaces #2120

Closed
cidrblock opened this issue May 11, 2022 · 2 comments · Fixed by #2306
Closed

jinja[readability]: Require/Fix | be surrounded by spaces #2120

cidrblock opened this issue May 11, 2022 · 2 comments · Fixed by #2306
Assignees
Labels
new rule A request for a new rule

Comments

@cidrblock
Copy link
Contributor

The | should be surrounded by spaces for readability:

Bad:

          - ansible_facts.network_resources.bfd_interfaces|symmetric_difference(result.after)|length

Good:

          - ansible_facts.network_resources.bfd_interfaces | symmetric_difference(result.after) | length
@cidrblock cidrblock added the new rule A request for a new rule label May 11, 2022
nirmal-j-patel added a commit to nirmal-j-patel/ansible-lint that referenced this issue May 27, 2022
Created a new class FilterSurroundedBySpacesRule which checks whether
the | character is surrounded by white spaces. Added experimental tag to
the rule.

Addresses ansible#2120
@cidrblock
Copy link
Contributor Author

RE reformatting, we can use jinja's internals to ensure the meaning isn't changed

@ssbarnea ssbarnea changed the title Rule/formatting request: Require/Fix | be surrounded by spaces jinja[readability]: Require/Fix | be surrounded by spaces Jul 20, 2022
@ssbarnea
Copy link
Member

Kudos for @bcoca for suggesting:

2 things, instantiate a templating instance, but don't template, force just tokenization, then create your own concat function to reassemble the tokens with proper formatting

@ssbarnea ssbarnea self-assigned this Jul 28, 2022
ssbarnea added a commit to ssbarnea/ansible-lint that referenced this issue Aug 18, 2022
This change rewrites jinja2 rule to make it use jinaja lex parser and
avoid use of regexes for parsing, as they cause too many false
positives.

Fixes: ansible#2301 ansible#2285 ansible#2241 ansible#2209 ansible#2208 ansible#2120
ssbarnea added a commit to ssbarnea/ansible-lint that referenced this issue Aug 18, 2022
This change rewrites jinja2 rule to make it use jinaja lex parser and
avoid use of regexes for parsing, as they cause too many false
positives.

Fixes: ansible#2301 ansible#2285 ansible#2241 ansible#2209 ansible#2208 ansible#2120
ssbarnea added a commit to ssbarnea/ansible-lint that referenced this issue Aug 18, 2022
This change rewrites jinja2 rule to make it use jinaja lex parser and
avoid use of regexes for parsing, as they cause too many false
positives.

Fixes: ansible#2301 ansible#2285 ansible#2241 ansible#2209 ansible#2208 ansible#2120
ssbarnea added a commit to ssbarnea/ansible-lint that referenced this issue Aug 20, 2022
This change rewrites jinja2 rule to make it use jinaja lex parser and
avoid use of regexes for parsing, as they cause too many false
positives.

Fixes: ansible#2301 ansible#2285 ansible#2241 ansible#2209 ansible#2208 ansible#2120
ssbarnea added a commit to ssbarnea/ansible-lint that referenced this issue Aug 20, 2022
This change rewrites jinja2 rule to make it use jinaja lex parser and
avoid use of regexes for parsing, as they cause too many false
positives.

Fixes: ansible#2301 ansible#2285 ansible#2241 ansible#2209 ansible#2208 ansible#2120
ssbarnea added a commit to ssbarnea/ansible-lint that referenced this issue Aug 20, 2022
This change rewrites jinja2 rule to make it use jinaja lex parser and
avoid use of regexes for parsing, as they cause too many false
positives.

Fixes: ansible#2301 ansible#2285 ansible#2241 ansible#2209 ansible#2208 ansible#2120
ssbarnea added a commit to ssbarnea/ansible-lint that referenced this issue Aug 20, 2022
This change rewrites jinja2 rule to make it use jinaja lex parser and
avoid use of regexes for parsing, as they cause too many false
positives.

Fixes: ansible#2301 ansible#2285 ansible#2241 ansible#2209 ansible#2208 ansible#2120
ssbarnea added a commit to ssbarnea/ansible-lint that referenced this issue Aug 20, 2022
This change rewrites jinja2 rule to make it use jinaja lex parser and
avoid use of regexes for parsing, as they cause too many false
positives.

Fixes: ansible#2301 ansible#2285 ansible#2241 ansible#2209 ansible#2208 ansible#2120
ssbarnea added a commit to ssbarnea/ansible-lint that referenced this issue Aug 20, 2022
This change rewrites jinja2 rule to make it use jinaja lex parser and
avoid use of regexes for parsing, as they cause too many false
positives.

Fixes: ansible#2301 ansible#2285 ansible#2241 ansible#2209 ansible#2208 ansible#2120
ssbarnea added a commit to ssbarnea/ansible-lint that referenced this issue Aug 20, 2022
This change rewrites jinja2 rule to make it use jinaja lex parser and
avoid use of regexes for parsing, as they cause too many false
positives.

Fixes: ansible#2301 ansible#2285 ansible#2241 ansible#2209 ansible#2208 ansible#2120
ssbarnea added a commit to ssbarnea/ansible-lint that referenced this issue Aug 21, 2022
This change rewrites jinja2 rule to make it use jinaja lex parser and
avoid use of regexes for parsing, as they cause too many false
positives.

Fixes: ansible#2301 ansible#2285 ansible#2241 ansible#2209 ansible#2208 ansible#2120
ssbarnea added a commit to ssbarnea/ansible-lint that referenced this issue Aug 21, 2022
This change rewrites jinja2 rule to make it use jinaja lex parser and
avoid use of regexes for parsing, as they cause too many false
positives.

Fixes: ansible#2301 ansible#2285 ansible#2241 ansible#2209 ansible#2208 ansible#2120
ssbarnea added a commit to ssbarnea/ansible-lint that referenced this issue Aug 21, 2022
This change rewrites jinja2 rule to make it use jinaja lex parser and
avoid use of regexes for parsing, as they cause too many false
positives.

Fixes: ansible#2301 ansible#2285 ansible#2241 ansible#2209 ansible#2208 ansible#2120
ssbarnea added a commit to ssbarnea/ansible-lint that referenced this issue Aug 21, 2022
This change rewrites jinja2 rule to make it use jinaja lex parser and
avoid use of regexes for parsing, as they cause too many false
positives.

Fixes: ansible#2301 ansible#2285 ansible#2241 ansible#2209 ansible#2208 ansible#2120
ssbarnea added a commit to ssbarnea/ansible-lint that referenced this issue Aug 22, 2022
This change rewrites jinja2 rule to make it use jinaja lex parser and
avoid use of regexes for parsing, as they cause too many false
positives.

Fixes: ansible#2301 ansible#2285 ansible#2241 ansible#2209 ansible#2208 ansible#2120
ssbarnea added a commit that referenced this issue Aug 22, 2022
This change rewrites jinja2 rule to make it use jinaja lex parser and
avoid use of regexes for parsing, as they cause too many false
positives.

Fixes: #2301 #2285 #2241 #2209 #2208 #2120
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new rule A request for a new rule
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants