You can use IntelliJ’s inspections mechanism for this:
- Navigate to Analyze->Run Inspection by Name
- Search for the “Local variable or parameter can be final” warning
- Make sure that “Report method parameters” is the only option checked.
- Select the root of the tree (it should read Local variable or parameter can be final”
- Click ALT+ENTER and select “make final”. This should add the
final
modifier in all the missing places.
Once you’ve done this, you may want to enable this inspection in your IDE so it warns you about making further mistakes:
- Navigate to File->Settings->Editor->Inspections
- Search for the “Local variable or parameter can be final” warning
- Make sure that “Report method parameters” is the only option checked.