Search code examples
coding-styleformatteamcityappcode

Automatic code beautifier with Continuous Integration TeamCity


In my team, we use Objective-C and Swift, and we use AppCode reformatting feature, which is very nice. I was wondering it there is an automatic way of adding a step in the build configuration in TeamCity, in order to reformat the source code automatically.

The problem is that sometimes, developers forget to reformat the source code before submit the pull request.

It would be fantastic a script or tool that helped us to share the same code style formatting.


Solution

  • Reformatting source code in any CI would require to do commit from build.
    In TeamCity there no such functionality, see related issue. It can be done manually, though. That would require to use agent-side checkout and some manual build steps to reformat code and to commit/push changes, since there

    I'd recommend enable Reformat code and Optimize imports features in Before Submit section of Submit dialog in AppCode.
    Also you could use some code style checker as part of CI build. And/or push hook on git server (if you use git) which would reject push if code is misformatted.