Inspectopedia
 
2024.3

If-Null return/break/... foldable to '?:'

Info
New
Last modified: 03 December 2024

Reports an if expression that checks variable being null or not right after initializing it that can be converted into an elvis operator in the initializer.

Example:

The quick-fix converts the if expression with an initializer into an elvis expression: