Search code examples
javaintellij-ideapmd

Auto-fixing pmd errors. Is it possible?


I just inherited a bunch of code from another developer and our company instituted some new code style rules. So now I have 300 pmd errors saying "Parameter 'blablahlblah' is not assigned and could be declared final". I really don't want to do all of these by hand and I just need to put a "final" modifier in front of every variable that is causing this pmd error. Is there any easy way to do this besides writing some script to consume the pmd output and modify the source files accordingly? I'm using IntelliJ, also. Maybe that can help me?


Solution

  • Use Analyze | Inspect Code, it will give you the list of results grouped by inspection, quick fix can be often applied to the whole group of the results, so you can add final to all the places this inspection finds in one click.