Enhanced 'for' with a record pattern can be used
Reports local variable declarations and accessors to record components that can be replaced with pattern variables in enhanced `for` statements, which are usually more compact.
Example:
Can be replaced with:
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.
ForEachWithRecordPatternCanBeUsed- 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 Nesting depth limit option to specify the maximum number of nested deconstruction patterns to report
Use the Maximum number of record components to deconstruct option to specify the maximum number of components, which a record can contain to be used in deconstruction patterns
Use the Maximum number of not-used record components option to specify the maximum number of components, which are not used in
forstatement
This inspection depends on the Java feature 'Record patterns in for-each loops', which is available since Java X.
New in 2023.1
Inspection options
Here you can find the description of settings available for the Enhanced 'for' with a record pattern can be used inspection, and the reference of their default values.
- Nesting depth limit
Default value:
2- Maximum number of record components to deconstruct
Default value:
5- Maximum number of not-used record components
Default value:
0
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: |