Chained method calls
Reports method calls whose target is another method call. The quick-fix suggests to introduce a local variable.
Example:
After the quick-fix is applied:
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.
ChainedMethodCall- 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.
Use the inspection options to toggle warnings for the following cases:
chained method calls in field initializers, for instance,
private final int i = new Random().nextInt();chained method calls operating on the same type, for instance,
new StringBuilder().append("x: ").append(new X()).append("y: ").append(new Y()).toString();.
Inspection ID: ChainedMethodCall
Inspection options
Here you can find the description of settings available for the Chained method calls inspection, and the reference of their default values.
- Ignore chained method calls in field initializers
Option ID:
m_ignoreFieldInitializationsDefault value:
Selected- Ignore calls to methods returning the same type as their enclosing class
Option ID:
ignoreSelfTypesDefault value:
Selected
Suppressing Inspection
You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:
More detailed instructions as well as other ways and options that you have can be found in the product documentation:
Inspection Details | |
|---|---|
By default bundled with: |