Generally I'm of the opinion that git hooks are not the right place to place linters or formatters.
For a JVM language, it means that you'll spin up a JVM for each step (and you can well have 15 formatters + linters in your stack).
So, the formatter better lives in a dev-only part of your codebase, so it's always loaded, interacting with your codebase using _runtime insights_ otherwise impossible to gather, and it's easily hackable.
I've authored this kind of solution in the past. It works great, and a proper CI pipeline (i.e. including linters) kills the other half of the problem.
For a JVM language, it means that you'll spin up a JVM for each step (and you can well have 15 formatters + linters in your stack).
So, the formatter better lives in a dev-only part of your codebase, so it's always loaded, interacting with your codebase using _runtime insights_ otherwise impossible to gather, and it's easily hackable.
I've authored this kind of solution in the past. It works great, and a proper CI pipeline (i.e. including linters) kills the other half of the problem.