Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I apply multiple quick fixes for Checkstyle problems of the same type?

The Eclipse Checkstyle plugin offers two ways to auto-correct issues:

  1. Right-click on an individual source file and select "Apply Checkstyle Corrections".

  2. 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:

Checkstyle errors

If I select the two errors relating to missing braces and try and quick-fix the pair of them, it will not work.

like image 514
Duncan Jones Avatar asked Sep 25 '12 09:09

Duncan Jones


1 Answers

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.

like image 151
Snekse Avatar answered Nov 13 '22 13:11

Snekse