Inspectopedia 2024.3 Help

Simplifiable collector

Reports collectors that can be simplified.

In particular, some cascaded groupingBy() collectors can be expressed by using a simpler toMap() collector, which is also likely to be more performant.

Example:

Collectors.groupingByConcurrent(String::length, Collectors.collectingAndThen(Collectors.maxBy(String::compareTo), Optional::get));

After the quick-fix is applied:

Collectors.toConcurrentMap(String::length, Function.identity(), BinaryOperator.maxBy(String::compareTo));

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

SimplifyCollector
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | Java | Verbose or redundant code constructs

This inspection depends on the Java feature 'Stream and Optional API', which is available since Java 8.

New in 2017.1

Inspection Details

By default bundled with:

IntelliJ IDEA 2024.3, Qodana for JVM 2024.3,

Can be installed with plugin:

Java, 243.23126

Last modified: 03 December 2024