Home > Back-end >  How to configure Intellij idea code formatting to according my example
How to configure Intellij idea code formatting to according my example

Time:09-18

I have butiful code in my tests

public void createEntity(String jsonString) {   
    response = getBaseRequestWithCurrentCookie()
            .given().
                    body(jsonString).
                    contentType(ContentType.JSON)
            .when().
                    post()
            .then().
                    log().ifError().
                    extract().response();
}

But how to configure intellij Idea code style(for Java) so that it doesn't align it ?

public void createEntity(String jsonString) {
    response = getBaseRequestWithCurrentCookie()
            .given().
            body(jsonString).
            contentType(ContentType.JSON)
            .when().
            post()
            .then().
            log().ifError().
            extract().response();
}

CodePudding user response:

  1. Add builder method names to Settings (Preferences on macOS) | Editor | Code Style | Java | Wrapping and Braces | Chained method calls | Builder methods
  2. Enable Settings (Preferences on macOS) | Editor | Code Style | Java | Wrapping and Braces | Chained method calls | Keep builder methods indents option:

enter image description here

  • Related