On the classification, scope, and general usefulness of the no-tabs
rule
#1653
Replies: 2 comments 8 replies
-
From https://yaml.org/spec/1.2/spec.html#id2775170 and https://yaml.org/spec/1.2/spec.html#id2777534: "To maintain portability, tab characters must not be used in indentation, since different systems treat tabs differently. Note that most modern editors may be configured so that pressing the tab key results in the insertion of an appropriate number of spaces. The amount of indentation is a presentation detail and must not be used to convey content information."
That's just to rule out any |
Beta Was this translation helpful? Give feedback.
-
In fact polls are supported via https://github.com/apps/polls ;) IMHO, the need to use tabs in yaml files is so low that I prefer to always escape them when needed, even using file-templates in order to avoid use of tabs inside yaml. Too often I seen bugs related to them, including accidental conversion of them to spaces. From my point of view using noqa to silence a false-positive is an acceptable cost. |
Beta Was this translation helpful? Give feedback.
-
Apparently, the
no-tabs
rule causes considerable grief with arguably very limited benefit, considering that any syntactic/formatting issues with TAB characters are handled by the relevant parsers long before the actual rule has a chance to check for TABs.Consequently, I don't think that the classification (or tag) for this rule as "formatting" is correct.
Since the rule is checking for TABs in parsed and syntactically correct key and values,
my first suggestion is to change the tag for this rule to. say,
experimental
.As for the scope of the rule, although YAML does allow TABs in both keys and values,
I can see that having TABs in keys for Ansible is never meaningful; so, checking that makes
sense, but having TABs in values (or "payloads" as someone else put it) can happen in a variety
of valid scenarios. Unfortunately, the
lineinfile
module on theallow_list
is only one of manypotential use cases. The most obvious and very similar one being
blockinfile
, but snippetsfrom any code or configuration that requires TABs (e.g. Linux kernel code,
Makefile
s,named.conf
, etc.) could easily end up invars:
as well. In my mind,ansible-lint
has nobusiness checking values, since the chances of false positive are close to 1.
Based on the above, my second suggestion is to limit TAB-checking to keys.
Personally, I find that this rule is unnecessarily taking sides in yet another holy war.
What's next? Checking for
# vim:.*
stanzas? 😈Personally, I've yet to see an example of this rule alerting on a true positive, which is why I'm wondering
about the general opinion about the usefulness of this particular rule. As far as I can tell, polls are not supported here, although GitHub does have an app for that; so, I'll just number the options and hope to receive feedback in comments with the relevant number.
Beta Was this translation helpful? Give feedback.
All reactions