Best practices are important. Having some amount of consistency in the code base makes it more readable and easier to update.
However, when a script has a lot of problems concerning best practices we could lose what's really important: The script logic
Enter the Indeni script parser. Open it, paste your script and see if you missed anything in terms of best practices:
I believe this will keep our PR's much more clean and our poor IKE new-comers less devastated from what to the uninitiated might seem like petty remarks.
It currently has checks for the META section, the COMMENTS section and the AWK parser. It's not perfect, it does not check everything, but it's something. Test it here:
The parse functions are templated (a bit like the indeni Scala rules) so adding a new one is quite simple. Just add a function to the function array at the top of the script:
The new function must have this.testName, this.reason, this.severity ("error" or "warning"), this.applyToSections (could contain "yaml", "awk", "meta" or "comments" right now, but it's easy to add support for more).
Then to the logic. The mark function is where the magic happens. It takes the string of a section and returns marked segments. How you choose to to the marking is up to you but I'd advise looking at the other examples and copy in the beginning.
- You have to paste a full script for it to work.
- It updates as you type, so you can literally see all your troubles go away. :)
- Please note that the checks are based on what I think it good practice, but many people might disagree on some of these things. If you do, please do let me know and we can discuss it here.
Want to contribute? Clone it on Github and submit a pull request:
Feedback most welcome.