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

Feature Request: Identify poorly indented states (e.g. only using one space instead of two) #246

Open myii opened 3 years ago

myii commented 3 years ago

Is your feature request related to a problem? Please describe.

salt-lint should catch poorly indented states.

https://github.com/saltstack-formulas/haproxy-formula/blob/958c2d9249b276d1844605091608e02dc3601512/haproxy/config.sls#L4-L19

haproxy.config:
 file.managed:
   - name: {{ config_file }}
   - source: {{ haproxy.config_file_source }}
   - template: jinja
   - user: {{ haproxy.user }}
   - group: {{ haproxy.group }}
   - mode: 644
   - require_in:
     - service: haproxy.service
   - watch_in:
     - service: haproxy.service
   {% if salt['pillar.get']('haproxy:overwrite', default=True) == False %}
   - unless:
     - test -e {{ config_file }}
   {% endif %}

Describe the solution you'd like

Run salt-lint on the above file and it will pass. salt-lint has been enabled for this repository for a long time now, here's the last run:

https://gitlab.com/saltstack-formulas/haproxy-formula/-/jobs/914490845#L171

Check Salt files using salt-lint.........................................Passed
- hook id: salt-lint
- duration: 0.13s
Examining test/salt/salt/hosts/init.sls of type state
Examining haproxy/service.sls of type state
Examining haproxy/init.sls of type state
Examining /tmp/tmpvfw2xbmk.sls of type state
Examining haproxy/install.sls of type state
Examining haproxy/templates/haproxy.jinja of type state
Examining test/salt/pillar/hosts.sls of type state
Examining haproxy/config.sls of type state
Examining haproxy/map.jinja of type state

Examining haproxy/config.sls of type state should show a failure.

roaldnefs commented 3 years ago

Thanks @myii for your feature request!

This might automatically be detected by allowing yamllint to run on the states stripped of any Jinja (#240).

myii commented 3 years ago

Thanks @myii for your feature request!

This might automatically be detected by allowing yamllint to run on the states stripped of any Jinja (#240).

@roaldnefs Yes, that definitely will work. #240 would be a fantastic addition to salt-lint.

Thanks for the prompt reply!