piranha
piranha copied to clipboard
PiranhaJava - Doesn't add required space while removing parentheses
Piranha changed return(true);
to returntrue;
.
This is sort of related to #35 - in the sense that PiranhaJava doesn't validate the parens/spaces of the output generated.
This error probably would not have occured if the code had been Google Java formatted.
However, I thought I will bring it to your attention, since this is a case of Piranha introducing a "bug" instead of erring on the side of caution, like #35
Thanks for the report! Seems like we should either fix this bug or document that we assume proper (GJF) formatting
@pranavsb can you please provide the input source code to replicate this.
Hi @swayamraina
Just use a dummy method with the given statement. Like this:
public boolean someMethod() {
return(true);
}
It's not necessary to add someMethod
to Piranha config.
Btw, Piranha also simplifies if(true)
by default, with no config.
@mkr-plse IMO it would be better to remove all constant returning methods and substitute the values to variables. But i believe this would require to build the multi-pass layer (https://github.com/uber/piranha/issues/58)
Till then we can fix this issue by checking spacing before doing any fixes. Thoughts?
- I think Piranha should discard refactoring code related to existing boolean constants, unless specified as an input option.
- If the input option is specified and the boolean constant is assigned or returned from a method, in the short term, code need not be updated.
- Long term, this will be resolved with #58.
I don't think the spacing should be updated here because the match will fail due to the presence of a boolean constant.
agreed. But this isaue is valid when the app is passed through piranha multiple times.
on first pass, piranha reduces the feature flag in a method to a method that returns true (reducing to the above code) or false. on second pass, piranha resuces the above code to produce an output which produces compilation error.