Inspectopedia Help

Too long same methods chain

Reports long Reactive Streams transformation chains.

Each operator method call, such as map() or filter(), creates some objects for those operators. Calling a long chain of operators on each subscription, for each stream element, may cause performance overhead. To avoid it, combine a long chain of calls into one operator call wherever possible.

Example:

Flux.just(1, 2, 3) .map(it -> it + 1) .map(it -> it + 2) .map(it -> it + 3)

After the quick-fix is applied:

Flux.just(1, 2, 3) .map(it -> it + 1 + 2 + 3)

New in 2019.3

Inspection options

Option

Type

Default

The longest allowed same methods chain length

Number

2

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Reactive Streams, 233.SNAPSHOT

Last modified: 13 July 2023