What option/entry-point should ansible-lint use for the format/rewrite/transforms feature? #1910
-
OverviewI want to introduce a feature to NB: This is and must be opt-in. In order to fix any issues identified by rules, we will have to read each YAML file with Before #1828 can be finalized (which will allow me to work on other PRs), we have to decide what interface to use for these features. UX ProposalsNB: I would have merged some cells in these charts, but markdown doesn't support that, so I duplicated the contents. 🤷♂️ Each of the comments/charts is a UX propsoal. Please
In particular: Is it better to use Vote TallyCurrent winner marked with 🏆.
edit: I had all the propsals in the top-level description. I moved them to comments so each proposal can have it's own thread of conversation. edit2: I tried to quote all the UX-relevant discussion from #1828. Sorry if I missed something. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 10 replies
-
|
today | #1828 | possible future PR | future PR(s) | ||
---|---|---|---|---|---|
Feature \ CLI | ansible-lint |
ansile-lint --fmt-yaml |
ansible-lint --fmt-yaml --skip-lint |
ansile-lint --transform [ --fmt-yaml ] |
|
Lint ansible content | YAML | ✔️ | ✔️ | ✔️ * |
|
Lint ansible content | Jinja2 | ✔️ | ✔️ | ✔️ * |
|
Reformat files | YAML | ✔️ | ✔️ | ✅ ^ + |
|
Reformat files | Jinja2 | ✅ ^ - |
|||
Transform files (fix or simplify fixing lint issues) |
YAML | ✔️ | |||
Transform files (fix or simplify fixing lint issues) |
Jinja2 | ✔️ |
-
*
Transforms require lint results to identify what to fix -
^
Transforms must reformat any transformed files -
+
Reformatting YAML files without lint errors is optional -
-
Reformatting JInja Templates can be lossy with whitespace because AST does not preserve chomped whitespace (like{%-
or-%}
or{{-
or-}}
). So, only Jinja templates with identified issues get reformatted.
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
today | #1828 | future PR(s) | ||
---|---|---|---|---|
Feature \ CLI | ansible-lint |
ansile-lint --write |
ansile-lint --write |
|
Lint ansible content | YAML | ✔️ | ✔️ | ✔️ * |
Lint ansible content | Jinja2 | ✔️ | ✔️ | ✔️ * |
Reformat files | YAML | ✔️ | ✅ ^ |
|
Reformat files | Jinja2 | ✅ ^ - |
||
Transform files (fix or simplify fixing lint issues) |
YAML | ✔️ | ||
Transform files (fix or simplify fixing lint issues) |
Jinja2 | ✔️ |
-
*
Transforms require lint results to identify what to fix -
^
Transforms must reformat any transformed files -
⚠️ Reformatting YAML files without lint errors is NOT optional.--write
will always rewrite all YAML files even if no lint errors are detected. -
-
Only Jinja templates with identified lint errors get reformatted.
Beta Was this translation helpful? Give feedback.
-
|
today | #1828 | future PR(s) | ||
---|---|---|---|---|
Feature \ CLI | ansible-lint |
ansile-fmt |
ansile-fmt |
|
Lint ansible content | YAML | ✔️ | ✔️ * |
|
Lint ansible content | Jinja2 | ✔️ | ✔️ * |
|
Reformat files | YAML | ✔️ | ✅ ^ |
|
Reformat files | Jinja2 | ✅ ^ - |
||
Transform files (fix or simplify fixing lint issues) |
YAML | ✔️ | ||
Transform files (fix or simplify fixing lint issues) |
Jinja2 | ✔️ |
-
*
Transforms require lint results to identify what to fix.ansible-fmt
could skip reporting the issues however. To find out what's left, runansible-lint
separately. -
^
Transforms must reformat any transformed files -
⚠️ Reformatting YAML files without lint errors is NOT optional.--write
will always rewrite all YAML files even if no lint errors are detected. -
-
Only Jinja templates with identified lint errors get reformatted.
Beta Was this translation helpful? Give feedback.
-
@bcoca said in #1828 (comment):
I think we could extend the |
Beta Was this translation helpful? Give feedback.
--write
optionansible-lint
ansile-lint
--write
ansile-lint
--write
*
*
^
^
-
(fix or simplify fixing lint issues)
(fix or simplify fixing lint issues)
*
Transforms require lint results to identify what to fix^
Transforms must reformat any transformed files--write
will always rewrite all YAML files even if no lint errors are detected.-
Only Jinja templates with identified lint e…