The Eclipse Checkstyle plugin offers two ways to auto-correct issues:
Right-click on an individual source file and select "Apply Checkstyle Corrections".
Right-click on problem marker and select "Quick Fix".
If I select multiple markers of the same type and attempt to quick fix all of them, Eclipse states:
The selected problems do not have a common applicable quick fix.
Is there a way for me to execute multiple Checkstyle corrections of the same type in a more efficient manner?
(See related question: How can I easily fix Checkstyle errors?)
To give an example, consider the following code:
/**
* Example to demonstrate check-style quick fix.
*/
public final class CheckStyle {
/**
* Example constructor with no if braces.
*
* @param arg an argument
*/
public CheckStyle(final String arg) {
if (arg == null)
throw new RuntimeException("Arg is null.");
if (arg.isEmpty())
throw new RuntimeException("Arg is empty.");
}
}
When checked against Sun's checkstyle configuration, three errors are picked up:
If I select the two errors relating to missing braces and try and quick-fix the pair of them, it will not work.
Just a guess here, but I think the answer is to file a bug/feature request with the cs-eclipse plug-in team. The message Eclipse is giving you seems to indicate it's a special case that would need to be handled by the developer.
If you do submit a ticket, let us know. I'd like to watch it. I think it would be a useful feature.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With