warpnet / salt-lint

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

False positive for content -> contents (218) #252

Closed hafkensite closed 3 years ago

hafkensite commented 3 years ago

Describe the bug The new TypoContentsRule rule assumes all instances of 'content' should be 'contents', but for file.line the parameter is actually called 'content'.

To Reproduce Run version 0.6.0 on code like this:

gitlab-runner-listen-address:
  file.line:
    - name: /etc/gitlab-runner/config.toml
    - content: 'listen_address = "0.0.0.0:9252"'
    - match: '^listen_address = .*'

Expected behavior The 218 rule only matches cases where its actually a typo.

Desktop (please complete the following information):

hbokh commented 3 years ago

Can confirm - with output regarding @hafkensite his lines:

$ salt-lint salt/gitlab-runner/init.sls
Examining salt/gitlab-runner/init.sls of type sls
[218] "content" looks like a typo. Did you mean "contents"?
salt/gitlab-runner/init.sls:49
    - content: 'listen_address = "0.0.0.0:9252"'
jbouter commented 3 years ago

@roaldnefs @jay7x I suggest we change the typo-catching rule to only apply on states we have verified.

jbouter commented 3 years ago

Fixed in #253 and removed in the latest release (v0.6.1). Thanks for alerting us @hafkensite and @hbokh!

Once we've got the time, we'll work on implementing a better check that targets only specific states, in which we know content will fail and contents should be set.

jay7x commented 3 years ago

Thank you for fixing this.. I didn't know there is a case when content is valid.. What I hate in SaltStack is inconsistency :(