palantir / palantir-java-format

A modern, lambda-friendly, 120 character Java formatter.
Apache License 2.0
426 stars 45 forks source link

Allow overriding the formatter config (avoid breaking long method names into new lines) #942

Open mauriciogeneroso opened 11 months ago

mauriciogeneroso commented 11 months ago

What happened?

The formatter should allow the users to set a config file and override the default formatting. There is a special case where I'd like to override the formatter config to avoid breaking long method names into new lines and it is not possible.

In Java, sometimes we have long method names for testing, and the formatter is formatting the method name to a new line:

    @Test
    void
            i_am_a_long_method_name_that_will_break_into_a_new_line_but_I_should_not_and_allow_something_to_override_it_and_customize_according_what_the_users_want() {}

What did you want to happen?

The formatter should allow to override configurations via config file. We could have properties like line-length-limit: X and then break to new line only when the method name is bigger than what is set in the config.

The expected output I'd like to get from the above example is:

@Test
void i_am_a_long_method_name_that_will_break_into_a_new_line_but_I_should_not_and_allow_something_to_override_it_and_customize_according_what_the_users_want() {}