Search code examples
javacoding-stylefinal

Batch refactoring to make Java method arguments final


I'm looking around for a way to perform batch refactoring on a complete Java application. In this namely make method arguments final where it's not the case yet.

Does somebody in here knows about such a tool ? Or something that parses Java source and that can be extended with such changes.


Solution

  • You can do a bulk change in IntelliJ to change every field, local variable or parameter which can be final to be final.

    Do a Code Analysis with the option, and "Apply Fix" globally, make sure it still compiles as it doesn't always get it 100% right in odd cases.