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

Feature - Option to remove associated whitespace for SuggestedFix.Builder replace and delete #2500

Open
tnterdan opened this issue Aug 16, 2021 · 0 comments · May be fixed by #2524
Open

Feature - Option to remove associated whitespace for SuggestedFix.Builder replace and delete #2500

tnterdan opened this issue Aug 16, 2021 · 0 comments · May be fixed by #2524

Comments

@tnterdan
Copy link

OK so I want to start out by saying I understand the philosophy behind error-prone and it not wanting to replace the usage of a tool like a code formatter.

That said, there are some minor issues that a code formatter can't solve.

Lets say I had some code like the following and we found an unused variable, as an example bug checker:

public class Person {
  private String favoritePhrase = "Hello World!";
  private int favoriteFlavor = "Strawberry"; // unused
  private int favoriteNumber = 45;

  private double height = 4.5;
  private double weight = 100;
  ...
}

OK so error prone analyzes my code and gives me something like the following output:

public class Person {
  private String favoritePhrase = "Hello World!";
  
  private int favoriteNumber = 45;

  private double height = 4.5;
  private double weight = 100;
  ...
}

But now the code has lost its organization. favorite related fields now have an extra line break between them, and a code formatter can't detect this to clean it up.

I would love for this to be a configurable option for error prone, to allow for cleanup of that extra whitespace, but please let me know if this is something out of scope for error-prone to do.

Happy to submit a PR myself, but I will need to check with y'all first if my corporate Google CLA is good for error-prone, since it wasn't specifically signed for error-prone.

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

Successfully merging a pull request may close this issue.

1 participant