PicnicSupermarket / error-prone-support

Error Prone extensions: extra bug checkers and a large battery of Refaster rules.
https://error-prone.picnic.tech
MIT License
198 stars 39 forks source link

Rewrite `buildDescription(tree).addFix(fix).build()` to `describeMatch(tree, fix)` #369

Open rickie opened 1 year ago

rickie commented 1 year ago

Problem

In commit https://github.com/google/error-prone/commit/570f0bf23af457aa323b0efcd8e1ba182eddbb13 the DescribeMatch BugChecker got removed from Error Prone with the explanation that it got ported to Refaster. As we cannot see these kind of changes, we have to write these Refaster rules ourselves 😄.

Description of the proposed new feature

I would like to rewrite the following code:

return buildDescription(tree).addFix(fix).build();

to:

return describeMatch(tree, fix);

Considerations

In the test code of the deleted BugChecker there is an edge case where it shouldn't propose a fix in the abstract class BugChecker { itself. However, to be honest, I don't think we need to take this case into account.

We might need to introduce a new Refaster rule collection for this Refaster rule or list it under AssortedRules.

Stephan202 commented 1 year ago

I looked into this a few months ago, but for some reason this doesn't seem to work with Refaster as one would expect. My code is here; perhaps I overlooked something? (I did not yet attach a debugger.)