

Personally, I prefer to have my Ktlint check run before my code is committed, as it ensures I don’t end up committing code style violations. It can also help you ensure that your code goes through a Ktlint check before being committed or pushed, especially when working in a team.

This article describes how you can automate your Ktlint check and save yourself the stress of having to manually run checks by making use of Git pre-commit/pre-push hook. If you haven’t checked it, feel free to check it out if need be, so you get a prior understanding of why and what is being done in this article. I created and made use of a sample android project available on GitHub. In a previous article, I talked about how to set up and make use of Ktlint in your android project.
