Hotkey in Eclipse to fix Checkstyle warnings "Parameter xxx must be final"

Is there a keyboard shortcut to fix all warning issues Parameter xxx should be final

? In my application, the same warning is shown 134 times. See the below code:

@Override
public void onSuccess(Object result) { // Parameter result should be final    
}

      

Is there a shortcut to address this warning?

I am using Eclipse Luna.

+3


source to share


2 answers


  • To see the tab with problems, go to menu Window

    > Show View

    >Problems

  • Right click on the warning in the Problems tab (for example, "Parameter result should be final")

  • Select "Quick Fix"

  • In the "Quick Fix" window that opens, select the type of fix

  • Click Select All to select all files that need to be fixed.

  • Click Finish to apply the fix.



+2


source


FYI, in Eclipse you can also configure the "Save Action" to automatically apply the modifier final

to all parameters, if possible.

Go to Window -> Preferences -> Java -> Editor -> Save Actions and click "Configure" next to "More Actions". Then, on the Code Style tab, select "use the final" modifier if possible and select the Option check box.



This can help keep your code safe in the future. Save actions can also be applied to the entire workspace at once using the Cleanup function available in Java → Code Style → Cleanup.

+3


source







All Articles