Add rule `call-expression-wrapping`, and improve wrapping in `chain-method-continuation` and `function-literal` (#3253)
Improve wrapping of complicated lines where chained methods are combined with call expressions containing arguments that potentially are chained methods. Now that the rule execution order is changed to process all rules on the same AST Node, before proceeding to the next AST Node, it became possible to improve the wrapping of constructs like below.
```
// Assume that the last allowed character is
// at the X character on the right X
val foo = Bar.buildernnnnnnnnnnnnnnnnnnnnnnnnnnnnnn().baz(1).build()
val foo1 = requireNotNull(bar.filter { it == "bar" }) { "some message" }
val foo2 = requireNotNull(bar?.filter { it == "bar" }) { "some message" }
```
which is now formatted as:
```
// Assume that the last allowed character is
// at the X character on the right X
val foo =
Bar
.buildernnnnnnnnnnnnnnnnnnnnnnnnnnnnnn()
.baz(1)
.build()
val foo1 =
requireNotNull(bar.filter { it == "bar" }) {
"some message"
}
val foo2 =
requireNotNull(bar?.filter { it == "bar" }) {
"some message"
}
```
Closes #2451.editorconfig supportplain, json, html and checkstyleFollow steps below for a quick start with latest ktlint release.
Step 1: Install with brew
brew install ktlint
See download and verification from GitHub or other package managers for alternative ways of installing ktlint. Or, use one of the integrations like maven and gradle plugins.
Step 2: Lint and format your code
All files with extension .kt and .kts in the current directory and below will be scanned. Problems will be fixed automatically when possible.
ktlint --format # or ktlint -F
See cli usage for a more extensive description on using ktlint.
User guide
This project is not affiliated with nor endorsed by JetBrains.
All code, unless specified otherwise, is licensed under the MIT license.
Copyright (c) 2019 Pinterest, Inc.
Copyright (c) 2016-2019 Stanley Shyiko.