Refactored luacheck.format

Use less closures and more static functions.