Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That's a pretty awesome read, and the approach is pretty flexible.

I've written simple code using the AST-visitor approach to enforce some common-standards on code within our company. Simple things like ensuring that when we use Troposphere to generate AWS cloudformation templates we always setup some specific values. (For example I wrote a checker to ensure that every time an ECR instance is created we must enable ScanOnPush, or every time we declare a security-group we must have a comment "[cloudformation] ..." with it - so that manual edits stand out.)



Thanks!

The stuff that ASTs let you do really flexibly is almost always lost to people because they're not aware of it. A lot of other developers would try to do this with string or regex matching, and that often leads to painful experiences.


Agreed. Simple checks like these are trivial:

A call to function "Foo" Must always have an argument matching the regexp "/blah/". Otherwise raise an error.

And they're so lightweight you can add them to any CI/CD/automation steps in your repository. Once you get a few things like that, or validating naming-standards, you can roll them up into a simple "linter".




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: