Sort arguments of RefasterRuleCollectionTestCase#elidedTypesAndStaticImports#850
Conversation
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
|
Kudos, SonarCloud Quality Gate passed! |
| methodInvocationTree.getArguments(); | ||
|
|
||
| ImmutableList<? extends ExpressionTree> desiredArgumentOrdering = | ||
| actualArgumentsOrdering.stream() |
There was a problem hiding this comment.
Should we group argument types togther before sorting ?
i.e: Group & sort method invocation lexicographically > group & sort identifiers lexicographically, etc...
There was a problem hiding this comment.
One tip for the ordering, in lexicographical sorting, the capital letters A-Z come before the a-z 😄.
Characters are sorted in lexicographic order. Sorting is case sensitive, that is, uppercase letters appear before lowercase letter in sorted data.
Should we group argument types togther before sorting ?
Do you have an example of the case you mean? In any case, it sounds like something we should have a test case for 😉.
There was a problem hiding this comment.
Do you have an example of the case you mean?
My thought was (As an example)
- Group & sort Objects (Strings for eg).
- Group & sort Class statemens (
*.class). - Group & sort method arguments.
- Group & sort primitives.
Essentially turning
ImmutableSet.of(List.class, "A", assertDoesNotThrow(() -> null), Iterables.class, "a", 1)
to
ImmutableSet.of("A", "a", List.class, Iterables.class, assertDoesNotThrow(() -> null),1)
| methodInvocationTree.getMethodSelect())), | ||
| ")")); | ||
|
|
||
| fixBuilder.merge(SuggestedFix.replace(methodInvocationTree, suggestion)); |
There was a problem hiding this comment.
Curious why running ./apply-error-prone-suggestions.sh did not fix the *(Input|Otput) tests here 🤔
There was a problem hiding this comment.
So what we are doing in the RefasterRuleCollection, is reporting things "in" the output file, that is what we are also verifying in the refaster-test-support/src/test/resources/tech/picnic/errorprone/refaster/test/NonSortedElidedTypesAndStaticImportsTestRulesTestOutput.java file.
So e.g. in the MatchInWrongMethodRulesTest input file we try to see what is wrong and we report that in the MatchInWrongMethodRulesTest output file, while not doing anything with the content itself, we only add a warning as a comment.
So in the NonSortedElidedTypesAndStaticImportsTestRulesTestOutput file we should not change the output to be correct, we only need a nice comment explaining what is wrong. Instead of
/* ERROR: Unexpected token. */
(which also signals something is wrong and the code we add has likely a bug)
It should add something like:
/*
* ERROR: The entries of the `elidedTypesAndStaticImports` method are not sorted lexicographically. The method should look like this:
* public ImmutableSet<Object> elidedTypesAndStaticImports() {
* return ImmutableSet.of(
Assertions.class,
..... (a method with correct sorting)
*/
This thing is not a "regular" BugPattern. It tries to guide a developer when writing TestInput & TestOutput files by giving this warning :).
There was a problem hiding this comment.
Thanks for explanation 🙇 🙇
There was a problem hiding this comment.
I gave some context that should make some things a bit clearer, if there are any questions let us know 😄.
Nice that you opened another PR @mohamedsamehsalah 🚀 !
.../picnic/errorprone/refaster/test/NonSortedElidedTypesAndStaticImportsTestRulesTestInput.java
Outdated
Show resolved
Hide resolved
| methodInvocationTree.getArguments(); | ||
|
|
||
| ImmutableList<? extends ExpressionTree> desiredArgumentOrdering = | ||
| actualArgumentsOrdering.stream() |
There was a problem hiding this comment.
One tip for the ordering, in lexicographical sorting, the capital letters A-Z come before the a-z 😄.
Characters are sorted in lexicographic order. Sorting is case sensitive, that is, uppercase letters appear before lowercase letter in sorted data.
Should we group argument types togther before sorting ?
Do you have an example of the case you mean? In any case, it sounds like something we should have a test case for 😉.
...-test-support/src/main/java/tech/picnic/errorprone/refaster/test/RefasterRuleCollection.java
Outdated
Show resolved
Hide resolved
| methodInvocationTree.getMethodSelect())), | ||
| ")")); | ||
|
|
||
| fixBuilder.merge(SuggestedFix.replace(methodInvocationTree, suggestion)); |
There was a problem hiding this comment.
So what we are doing in the RefasterRuleCollection, is reporting things "in" the output file, that is what we are also verifying in the refaster-test-support/src/test/resources/tech/picnic/errorprone/refaster/test/NonSortedElidedTypesAndStaticImportsTestRulesTestOutput.java file.
So e.g. in the MatchInWrongMethodRulesTest input file we try to see what is wrong and we report that in the MatchInWrongMethodRulesTest output file, while not doing anything with the content itself, we only add a warning as a comment.
So in the NonSortedElidedTypesAndStaticImportsTestRulesTestOutput file we should not change the output to be correct, we only need a nice comment explaining what is wrong. Instead of
/* ERROR: Unexpected token. */
(which also signals something is wrong and the code we add has likely a bug)
It should add something like:
/*
* ERROR: The entries of the `elidedTypesAndStaticImports` method are not sorted lexicographically. The method should look like this:
* public ImmutableSet<Object> elidedTypesAndStaticImports() {
* return ImmutableSet.of(
Assertions.class,
..... (a method with correct sorting)
*/
This thing is not a "regular" BugPattern. It tries to guide a developer when writing TestInput & TestOutput files by giving this warning :).
24a8c9b to
faaee6e
Compare
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
|
Kudos, SonarCloud Quality Gate passed! |
faaee6e to
1593ff2
Compare
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
1593ff2 to
0e90279
Compare
|
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |











This PR is split into two commits:
Suggested commit message: