Closed The-Judge closed 1 year ago
In some sense, I would say all linting is subjective (otherwise it's a syntax check).
But I think a casing
sub-rule, and maybe others that cover various aspects of var-naming
, could be a good idea.
Have a look at https://redhat-cop.github.io/automation-good-practices/#_naming_things, it is mentioned in a few PRs and tickets
The regex used for this rule is user-configurable, but not documented. We'll fix that.
WRT to subrules, I personally like the idea, I'm sure a PR for it would be welcomed.
Summary
var-naming seems to enforce personal preferences on variable naming, that are neither required nor recommended by Ansible, nor is a rationale provided in the docs; not even in the doc referenced in that RTD-Page (creating valid variable names). Also, the check seems not to be configurable to change this behavior.
What makes absolute sense is that it enforces stuff that is plain wrong in Ansible, like using
-
instead of_
or using special characters. But no Ansible Doc I know (or is referenced by Ansible-lint) declares Uppercase variable names wrong. The only indicator that this may be considered best practice is that the examples in creating valid variable names do it like that. But:Examples != Rules
.CamelCase may not look very nice to some people, but nowhere it is stated that you may not use that in Ansible variable names. That's why I state this is personal preference being enforced here.
Other Ansible-lint rules offer sub-rules that can be enabled/disabled individually; such as name, which has
name[casing]
,name[prefix]
,name[template]
, ...Issue Type
OS / ENVIRONMENT
STEPS TO REPRODUCE
var-naming
rule in ansible-lintDesired Behavior
The module should do one of the following things:
var-naming[casing]
).My favorited solution by far would be option 2.
Actual Behavior
See
STEPS TO REPRODUCE