google / error-prone

Catch common Java mistakes as compile-time errors

Home Page:https://errorprone.info

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Patching no longer works for experimental checks like StatementSwitchToExpressionSwitch

PhilippWendler opened this issue · comments

On my code base, running Error Prone with -Xep:StatementSwitchToExpressionSwitch:WARN -XepOpt:StatementSwitchToExpressionSwitch:EnableDirectConversion=true produces findings.

However, if I want to enable patching and pass -Xep:StatementSwitchToExpressionSwitch:WARN -XepOpt:StatementSwitchToExpressionSwitch:EnableDirectConversion=true -XepPatchChecks:StatementSwitchToExpressionSwitch -XepPatchLocation:..., no findings are shown and no error-prone.patch is generated anymore since 2.26.0.

If I go back to Error Prone 2.25.0, producing patches for StatementSwitchToExpressionSwitch works as expected with these command-line parameters. Version 2.26.0 and 2.27.1 both disable StatementSwitchToExpressionSwitch if I ask for patches from it.

I suspect that this is due to #4028 and that other experimental (disabled by default) checks suffer from the same problem, but I did not test this.

IMHO Error Prone could just enable an experimental check if it is used with -XepPatchChecks, even if it is not enabled explicitly, but I am also fine with having to pass both -Xep:StatementSwitchToExpressionSwitch:WARN and -XepPatchChecks:StatementSwitchToExpressionSwitch.

I still cannot get patching to work for StatementSwitchToExpressionSwitch on Error Prone 2.29.1. As soon as I pass -XepPatchChecks:StatementSwitchToExpressionSwitch -XepPatchLocation:..., the check does not produce any findings anymore, but it does if I do not ask for patches.