Introduce UnvalidatedEnumValueOfInvocation check#2031
Conversation
|
Suggested commit message: |
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
c1ce1f0 to
918a7b1
Compare
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
|
I will try to resolve mutation test reports when I have the time. |
The term "unchecked" is overloaded in Java (unchecked casts, unchecked exceptions). Use "unvalidated" to more precisely describe the intent.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
| " }", | ||
| " }", | ||
| "", | ||
| " if (d instanceof D(B deconstructedB)) {", |
There was a problem hiding this comment.
There are also potential cases which I ignored on purpose such as:
enum A {ONE};
enum B {ONE, TWO};
record D(B b) {}
D d = new D(B.ONE);
switch (d) {
case D(B deconstructedB) when B == ONE -> ..
case D(B deconstructedB) when B == TWO -> ..
};I think this will complicate things even further. Should we place it inside the ignored part?
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
| " Enum.valueOf(null, getClass().getSimpleName());", | ||
| " List.of(\"\").stream().map(A::valueOf);", | ||
| "", | ||
| " // Colon-style fall-through: `case FOUR` reaches the invocation, but only the", |
There was a problem hiding this comment.
Placed here to be explicit about the ignored case, if you see an easy way to implement it or that it is possible, let me know.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
| " // BUG: Diagnostic matches: MISSING_VALUE", | ||
| " consume(A.valueOf(B.FOUR.name()));", | ||
| " // BUG: Diagnostic matches: MISSING_VALUE", | ||
| " consume(Enum.valueOf(A.class, B.FIVE.name()));", |
There was a problem hiding this comment.
- Switch Cases are valid
- Types match
- Symbols do not match
- Value from the provided enum is a MemberSelectTree which is not present in A.class
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
|
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |



Context
Enum.valueOfmethod usage may lead to runtime exceptions when the provided argument is not checked against all possible values of method owner.Example:
Scope
Of course it is not able to capture all possible checks on
bbefore supplying it intoA.valueOf. Therefore scope will be limited to following checks.Above checks should also consider the polymorphic variant of
valueOf: