warpnet / salt-lint

A command-line utility that checks for best practices in SaltStack.
https://salt-lint.readthedocs.io/en/latest/
MIT License
152 stars 39 forks source link

Add check for proper nested dict indentation #282

Closed sblaisot closed 2 years ago

sblaisot commented 2 years ago

Is your feature request related to a problem? Please describe. Nested dicts should be over-indented (this is required by yaml). See https://docs.saltproject.io/en/latest/topics/troubleshooting/yaml_idiosyncrasies.html#nested-dictionaries

We should add a check in salt-lint to ensure proper over-indentation of context or defaults elements or data parameter of debconf.set (and maybe others I'm not aware of)

See Note in https://docs.saltproject.io/en/latest/ref/states/all/salt.states.debconfmod.html#available-functions

Describe the solution you'd like

ID:
  file.managed:
    - source: salt://path/to/source
    - template: jinja
    - context:
      somevar: somevalue

should fail the new test while

ID:
  file.managed:
    - source: salt://path/to/source
    - template: jinja
    - context:
        somevar: somevalue

should success

jbouter commented 2 years ago

Hi @sblaisot 👋🏻 !

Thanks for your great suggestion! It's definitely a good idea to check on correctly indented dicts. However, we're sadly a bit short on time at the moment, so it might take a while for us to get around to this. However, feel free to submit a PR!

sblaisot commented 2 years ago

thanks @jbouter

I would like to take a look at this but I'm wondering how to implement multiline rules. Is there already an example of multiline rules?

sblaisot commented 2 years ago

ok, I found an exemple with CmdRunQuietRule so I opened PR #284