Use `yamllint` config to prevent `empty-values` & use new `yaml-files` setting
myii opened this issue · comments
This has come up before and there was a reminder of it here:
Having empty values in pillar.example
(or any of the YAML files) is never a good idea, leading to confusion and rendering errors. Values should be set explicitly, with it being easy to set null if that's what's really required.
With yamllint
now active in our repos, this can easily be enforced from its configuration file:
rules:
+ empty-values:
+ forbid-in-block-mappings: true
+ forbid-in-flow-mappings: true
+
line-length:
# Increase from default of `80`
# Based on https://github.com/PyCQA/flake8-bugbear#opinionated-warnings (`B950`)
max: 88
Propagating this is straightforward using the ssf-formula
.
So I've run some tests across all of the relevant formulas using myii/ssf-formula#27. As you can see from that page, 8 out of the nearly 40 formulas have issues. The rest pass the yamllint
with this rule included. Clicking through to the Travis run via. the red crosses shows that about 4 of those would be relatively easy to solve (just a handful of values to fix). So in my opinion, this rule is worth enforcing now, with the fixes made to these 8 formulas as well. Any comments about this before I go ahead with this?
Hello.
So in my opinion, this rule is worth enforcing now, with the fixes made to these 8 formulas as well.
I agree. I'm really happy to see how the formulas improve.
Regards.
Thanks, @baby-gnu. I'll just wait to see if there any other responses before taking the next step (if applicable).
OK for me
@daks Excellent, that's good enough for me. I'll get something rolled out soon, the only thing that will delay me a little is getting the fixes included as well.
@myii it could the occasion to improve documentation about accepted values (bool, int, string, array, hast, null)
@n-rodriguez Do you mean from a YAML angle or across the SaltStack Formulas organisation? At the current time, my opinion is that as long as it's valid YAML, that's fine. There are cases where null
is required, so that's good as well but it should be set explicitly rather than implicitly. I've seen that empty values are being used as an empty string and that's not the case, so the idea here is to prevent that misunderstanding going forward. If you can suggest any specific documentation, that would be great, though.
Generally, there's more good news. The latest release of yamllint
has introduced the yaml-files
setting, which means that we no longer have to list all of the files to be checked by yamllint
. This configuration option will work across all of our repos:
yaml-files:
- '*.yaml'
- '*.yml'
- '.yamllint'
- '*.example'
- 'test/**/*.sls'
So I'm planning to include this at the same time.
The latest release of
yamllint
has introduced theyaml-files
setting, which means that we no longer have to list all of the files to be checked byyamllint
.
great!
The PRs have all been created. A few have been marked as WIP
where the extra work needs to be done but most are ready to go.
🎉 This issue has been resolved in version 3.3.1 🎉
The release is available on GitHub release
Your semantic-release bot 📦🚀