-
Notifications
You must be signed in to change notification settings - Fork 676
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
Modify VariableHasSpacesRule to check for spaces around filters #2180
Modify VariableHasSpacesRule to check for spaces around filters #2180
Conversation
I am personally inclined to prefer extending the already existing rule that checks for spaces around jinka2 vars to also cover filters instead of a new rule. How hard it would be to adapt to existing rule? |
@ssbarnea I agree with you that it makes sense to modify the existing rule. I am assuming you are talking about modifying this rule: https://github.com/ansible/ansible-lint/blob/main/src/ansiblelint/rules/var_spacing.py If so, I believe using regex lookahead and lookbehind functionality can identify if there are spaces surrounding |. The following regex appears to work well: I would like get your feedback on the following questions:
Thank you. |
Yes. As part of rule refactoring we will likely rename its IDs to No need to to worry about backwards compatibility as there is a place where we have aliases for old rule-id, that map to current ones, so we can avoid breaking config files. @cognifloyd WDYT about his? I am asking you as it sounds as a good idea to keep the jinja2 stuff in a single place. |
@nirmal-j-patel Can you please update var-spacing rule and avoid creating a new rule? |
b21989b
to
0c8875f
Compare
@ssbarnea I have updated the pull request so that var-spacing rule is updated instead of creating a new rule. Do the proposed changes look acceptable? A couple actions are failing. I can try to fix the issues if the current approach seems good. Thank you. |
Combining them makes sense. Jinja formatting is analogous to the So, I like the idea of a |
@nirmal-j-patel Yes, I think these changes are going in the right direction. Please continue :) and thank you! |
agreeing with @cognifloyd here, IMO, makes for a much more readable task, TY |
Modify VariableHasSpacesRule to check for spaces around the filter character |.
Addresses #2120