error-prone-support
error-prone-support copied to clipboard
Sort entries of `RefasterRuleCollectionTestCase#elidedTypesAndStaticImports`
Problem
For every Refaster Rule collection we have a corresponding *Test{Input,Output}.java
file where we test the Refaster rules.
These test classes implement the RefasterRuleCollectionTestCase
interface that contains the elidedTypesAndStaticImports
method. This method exists to ensure that the same import statements are (still) required in the *TestOutput
file. Without this, the import(s) could become unused due to the patching of Refaster rules (and therefore removed when running the formatter).
We highly value consistency and therefore always sort the arguments that are passed to the ImmutableSet#of
(see example below).
To enforce this, I propose to make changes to the RefasterRuleCollection
class and verify the sorting of these arguments there.
If the sorting is incorrect, it should suggest the correct order as fix.
Description of the proposed new feature
- [x] Support a stylistic preference.
- [ ] Avoid a common gotcha, or potential problem.
I would like to rewrite the following code:
@Override
public ImmutableSet<?> elidedTypesAndStaticImports() {
return ImmutableSet.of(Lists.class, Iterables.class);
}
to:
@Override
public ImmutableSet<?> elidedTypesAndStaticImports() {
return ImmutableSet.of(Iterables.class, Lists.class);
}
Considerations
This check is rather specific to Error Prone Support itself.
The content of the ImmutableSet
can be basically everything, that might make the sorting a bit challenging?
Maybe we should go one step further and ensure that the expression of the elidedTypesAndStaticImports
is always return ImmutableSet.of(...);
?
Participation
This request can be picked up by anyone willing to work on it.