xref: /Lucene/help/formatting.txt (revision c94b035df86f4fc1f8c6a0340c8bbf02b7af8ef0)
1*c94b035dSDawid WeissCode formatting
2*c94b035dSDawid Weiss===============
3*c94b035dSDawid Weiss
4*c94b035dSDawid WeissStarting with (LUCENE-9564) Java code is enforced to comply with
5*c94b035dSDawid Weissgoogle-java-format conventions. In theory you shouldn't worry about
6*c94b035dSDawid Weisswhat the convention actually looks like - write the code in any way
7*c94b035dSDawid Weissyou like and then run:
8*c94b035dSDawid Weiss
9*c94b035dSDawid Weiss./gradlew tidy
10*c94b035dSDawid Weiss
11*c94b035dSDawid Weissprior to running your regular precommit checks. This will reformat
12*c94b035dSDawid Weissyour code so that it complies with the convention and passes gradle
13*c94b035dSDawid Weiss'check' task.
14*c94b035dSDawid Weiss
15*c94b035dSDawid WeissIMPORTANT: There is *no* way to mark sections of the code as excluded
16*c94b035dSDawid Weissfrom formatting. This is by design and cannot be altered. In vast
17*c94b035dSDawid Weissmajority of cases the formatter will do a great job of cleaning up the
18*c94b035dSDawid Weisscode. Occasionally you may want to rewrite the code (introduce a local
19*c94b035dSDawid Weissvariable orreshape code paths) so that it's easier to read after
20*c94b035dSDawid Weissautomatic formatting.
21