Addresses some of the issues I raised in https://github.com/Homebrew/homebrew-core/pull/19127#issue-263566817. Would still like to work out a way to check `File.exist?`-style language inside the `test do` block exclusively but for now it's better to be too conservative on the audit than to be overly-zealous and flag too much.
Homebrew's Formula API
This is the (partially) documented public API for Homebrew.
The main class you should look at is the {Formula} class (and classes linked from there). That's the class that's used to create Homebrew formulae (i.e. package descriptions). Assume anything else you stumble upon is private.
You may also find the Formula Cookbook and Ruby Style Guide helpful in creating formulae.
Good luck!