Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applying suggestions from multiple related bugchecks in sequence #4088

Closed
jeandersonbc opened this issue Sep 14, 2023 · 1 comment
Closed

Comments

@jeandersonbc
Copy link

jeandersonbc commented Sep 14, 2023

Hello,

Is it possible to apply suggestions from multiple related bugchecks in a specific order in in a single run?

Example:

Given:

  • BugCheckA: moves initialized fields to constructor
  • BugCheckB: introduce parameter to constructor
  • Initial code snipped:
class A {
  private int a;
  private int b = 1;
  A(int a) {
      this.a = a;
  }
  public static void main(String[] args) {
      A obj = new A(2);
  }
}

Then:

  • Apply BugCheckA resulting in
class A {
 private int a;
 private int b;
 A(int a) {
     this.a = a;
     this.b = 1;
 }
 public static void main(String[] args) {
     A obj = new A(2);
 }
}

Note that b is now initialized inside the constructor instead of the field declaration

  • Apply BugCheckB resulting in
class A {
 private int a;
 private int b;
 A(int a, int b) {
     this.a = a;
     this.b = b;
 }
 public static void main(String[] args) {
     A obj = new A(2, 1);
 }
}

Note that the constructor now has an extra parameter and the object initialization was updated.

Desired

While I'm aware that ErrorProne can be used to inline suggestions when configured with

-XepPatchChecks:BugCheckA,BugCheckB -XepPatchLocation:IN_PLACE

I noticed that I needed two separate runs for each check instead of one.
Is there a way ask ErroProne to run these related bugchecks in a specific order in a single run? (Or maybe, have a "meta"-bugcheck that is composed by these checks?)

Thanks in advance!
Cheers 👋

@jeandersonbc
Copy link
Author

Closing as the answer was mentioned in another issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant