palantir-java-format icon indicating copy to clipboard operation
palantir-java-format copied to clipboard

Improvement: Add instrumentation to allow warning on files that take long to format

Open MTelling opened this issue 5 months ago • 0 comments

Before this PR

We have noticed the formatter becomes really slow on functions that nest a lot, causing some files to take +10 seconds to format. A simple refactor can often fix these issues but it can be hard to identify and enforce that files are kept in a shape that formatter formats quickly.

This PR adds instrumentation to file formatting and, if enabled, prints errors to the console for files that exceed the specified threshold.

After this PR

==COMMIT_MSG== Add instrumentation to allow warning on files that take long to format ==COMMIT_MSG==

Possible downsides?

I'd rather fix the formatter here but that might take a lot more time and in places where we've seen issues, the code could use a refactor anyway (deeply nested code is not very pretty).

MTelling avatar Jan 22 '24 18:01 MTelling