Skip to content

ConstructorCallMutator on Exhaustive switch #1442

@romani

Description

@romani

consider this commit https://github.com/checkstyle/checkstyle/pull/18580/changes

https://github.com/checkstyle/checkstyle/blob/master/src/main/java/com/puppycrawl/tools/checkstyle/api/SeverityLevel.java

private static String renderSeverityLevel(SeverityLevel severityLevel) {
        return switch (severityLevel) {
            case IGNORE -> "none";
            case INFO -> "note";
            case WARNING -> "warning";
            case ERROR -> "error";
        };
}

mutation:

    <sourceFile>SarifLogger.java</sourceFile>
    <mutatedClass>com.puppycrawl.tools.checkstyle.SarifLogger</mutatedClass>
    <mutatedMethod>renderSeverityLevel</mutatedMethod>
    <mutator>org.pitest.mutationtest.engine.gregor.mutators.ConstructorCallMutator</mutator>
    <description>removed call to java/lang/MatchException::&lt;init&gt;</description>
    <lineContent>return switch (severityLevel) {</lineContent>

as this is Exhaustive switch, compiler do validation, is there a way to avoid mutation ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions