Reuse existing static code validators #1328
Replies: 5 comments 9 replies
-
Hi @bastelfreak. Adding this to our weekly discussion this Friday. |
Beta Was this translation helpful? Give feedback.
-
Hey @bastelfreak, just wanted to shed some light on the reason as to why we have two separate validators here. Just to clarify, rake tasks used to and still are our current official validation method and we still recommend them as best practices. The reason why PDK has "re-invented" the wheel in this scenario is because, years ago, we were planning to replace rake tasks with the new system you can see in PDK, so that ultimately PDK would manage validation in all modules CI for us. However, due to unforeseen circumstances, we could not complete this project and it has been sitting idle for quite some time. Hope this helps to clarify the situation. |
Beta Was this translation helpful? Give feedback.
-
Hi, Are there plans for this? |
Beta Was this translation helpful? Give feedback.
-
@rwaffen debugged a problem today that relates to this topic: Now pdk doesn't use the rake tasks but calls puppet-lint directly:
Now if you've a line longer than 140 chars, puppetlabs_spec_helper/the rake task accepts it, pdk doesn't. This leads to inconsistencies. Because of that I think pdk should reuse the existing tasks instead of reinventing the logic. |
Beta Was this translation helpful? Give feedback.
-
@gavindidrichsen @LukasAud @davidsandilands do you have an update here? This came up at a PE customer today. there are some checks in puppet-syntax that would have catched a customer problem, but since pdk doesn't use that, pdk didn't notice it. |
Beta Was this translation helpful? Give feedback.
-
For over a decade, we've had existing tools to do static code checks and syntax validation. Some of them are grouped in puppet-syntax. It does:
Besides that there are other tools. metadata-json-lint does... linting and syntax check for metadata.json. puppet-lint provides support for puppet DSL linting and rubocop lints ruby files. The checks are mostly configured in https://github.com/puppetlabs/puppetlabs_spec_helper/blob/main/lib/puppetlabs_spec_helper/rake_tasks.rb
best practice in the community is to call those rake tasks. Even the Puppet CI does it: https://github.com/puppetlabs/puppetlabs-stdlib/actions/runs/8241458864/job/22544040246#step:5:1
PDK doesn't do that. Instead it reinvents the wheel: https://github.com/puppetlabs/pdk/tree/main/lib/pdk/validate/puppet
I think this doesn't make much sense and it's also dangerous. pdk is typically run locally but not in CI. But pdk locally will report different results compared to CI pipelines. Also the current approach adds a huge maintainer burden because checks have to be maintained in multiple places.
Beta Was this translation helpful? Give feedback.
All reactions