Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve Pitest for profile coding-2 #12331

Closed
Kevin222004 opened this issue Oct 22, 2022 · 12 comments
Closed

Resolve Pitest for profile coding-2 #12331

Kevin222004 opened this issue Oct 22, 2022 · 12 comments

Comments

@Kevin222004
Copy link
Collaborator

Kevin222004 commented Oct 22, 2022

Related to #7797

kill mutation:-
part - 1

<mutation unstable="false">
<sourceFile>ExplicitInitializationCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.ExplicitInitializationCheck</mutatedClass>
<mutatedMethod>isZero</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_1</mutator>
<description>RemoveSwitch 1 mutation</description>
<lineContent>switch (type) {</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>ExplicitInitializationCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.ExplicitInitializationCheck</mutatedClass>
<mutatedMethod>isZero</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_2</mutator>
<description>RemoveSwitch 2 mutation</description>
<lineContent>switch (type) {</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>ExplicitInitializationCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.ExplicitInitializationCheck</mutatedClass>
<mutatedMethod>isZero</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_5</mutator>
<description>RemoveSwitch 5 mutation</description>
<lineContent>switch (type) {</lineContent>
</mutation>

and
part - 2
<mutation unstable="false">
<sourceFile>FinalLocalVariableCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.FinalLocalVariableCheck</mutatedClass>
<mutatedMethod>leaveToken</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_2</mutator>
<description>RemoveSwitch 2 mutation</description>
<lineContent>switch (ast.getType()) {</lineContent>
</mutation>

and
part - 3
<mutation unstable="false">
<sourceFile>ModifiedControlVariableCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck</mutatedClass>
<mutatedMethod>leaveToken</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_10</mutator>
<description>RemoveSwitch 10 mutation</description>
<lineContent>switch (ast.getType()) {</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>ModifiedControlVariableCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck</mutatedClass>
<mutatedMethod>leaveToken</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_11</mutator>
<description>RemoveSwitch 11 mutation</description>
<lineContent>switch (ast.getType()) {</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>ModifiedControlVariableCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck</mutatedClass>
<mutatedMethod>leaveToken</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_12</mutator>
<description>RemoveSwitch 12 mutation</description>
<lineContent>switch (ast.getType()) {</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>ModifiedControlVariableCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck</mutatedClass>
<mutatedMethod>leaveToken</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_13</mutator>
<description>RemoveSwitch 13 mutation</description>
<lineContent>switch (ast.getType()) {</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>ModifiedControlVariableCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck</mutatedClass>
<mutatedMethod>leaveToken</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_14</mutator>
<description>RemoveSwitch 14 mutation</description>
<lineContent>switch (ast.getType()) {</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>ModifiedControlVariableCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck</mutatedClass>
<mutatedMethod>leaveToken</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_15</mutator>
<description>RemoveSwitch 15 mutation</description>
<lineContent>switch (ast.getType()) {</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>ModifiedControlVariableCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck</mutatedClass>
<mutatedMethod>leaveToken</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_16</mutator>
<description>RemoveSwitch 16 mutation</description>
<lineContent>switch (ast.getType()) {</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>ModifiedControlVariableCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck</mutatedClass>
<mutatedMethod>leaveToken</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_2</mutator>
<description>RemoveSwitch 2 mutation</description>
<lineContent>switch (ast.getType()) {</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>ModifiedControlVariableCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck</mutatedClass>
<mutatedMethod>leaveToken</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_7</mutator>
<description>RemoveSwitch 7 mutation</description>
<lineContent>switch (ast.getType()) {</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>ModifiedControlVariableCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck</mutatedClass>
<mutatedMethod>leaveToken</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_8</mutator>
<description>RemoveSwitch 8 mutation</description>
<lineContent>switch (ast.getType()) {</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>ModifiedControlVariableCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck</mutatedClass>
<mutatedMethod>leaveToken</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_9</mutator>
<description>RemoveSwitch 9 mutation</description>
<lineContent>switch (ast.getType()) {</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>ModifiedControlVariableCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck</mutatedClass>
<mutatedMethod>visitToken</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_10</mutator>
<description>RemoveSwitch 10 mutation</description>
<lineContent>switch (ast.getType()) {</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>ModifiedControlVariableCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck</mutatedClass>
<mutatedMethod>visitToken</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_11</mutator>
<description>RemoveSwitch 11 mutation</description>
<lineContent>switch (ast.getType()) {</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>ModifiedControlVariableCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck</mutatedClass>
<mutatedMethod>visitToken</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_12</mutator>
<description>RemoveSwitch 12 mutation</description>
<lineContent>switch (ast.getType()) {</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>ModifiedControlVariableCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck</mutatedClass>
<mutatedMethod>visitToken</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_13</mutator>
<description>RemoveSwitch 13 mutation</description>
<lineContent>switch (ast.getType()) {</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>ModifiedControlVariableCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck</mutatedClass>
<mutatedMethod>visitToken</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_14</mutator>
<description>RemoveSwitch 14 mutation</description>
<lineContent>switch (ast.getType()) {</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>ModifiedControlVariableCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck</mutatedClass>
<mutatedMethod>visitToken</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_15</mutator>
<description>RemoveSwitch 15 mutation</description>
<lineContent>switch (ast.getType()) {</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>ModifiedControlVariableCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck</mutatedClass>
<mutatedMethod>visitToken</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_16</mutator>
<description>RemoveSwitch 16 mutation</description>
<lineContent>switch (ast.getType()) {</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>ModifiedControlVariableCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck</mutatedClass>
<mutatedMethod>visitToken</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_2</mutator>
<description>RemoveSwitch 2 mutation</description>
<lineContent>switch (ast.getType()) {</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>ModifiedControlVariableCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck</mutatedClass>
<mutatedMethod>visitToken</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_7</mutator>
<description>RemoveSwitch 7 mutation</description>
<lineContent>switch (ast.getType()) {</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>ModifiedControlVariableCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck</mutatedClass>
<mutatedMethod>visitToken</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_8</mutator>
<description>RemoveSwitch 8 mutation</description>
<lineContent>switch (ast.getType()) {</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>ModifiedControlVariableCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck</mutatedClass>
<mutatedMethod>visitToken</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_9</mutator>
<description>RemoveSwitch 9 mutation</description>
<lineContent>switch (ast.getType()) {</lineContent>
</mutation>

@romani
Copy link
Member

romani commented Oct 23, 2022

I recommend to keep each mutation separately to not block easy mutations.

Or at least send separate PRs

@Kevin222004
Copy link
Collaborator Author

Kevin222004 commented Jan 9, 2023

@romani @rnveach for https://checkstyle.org/config_coding.html#FinalLocalVariable

cat Test.java
class Test {

    Test(int a) {
    }

}
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
        "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
        "https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
    <module name="TreeWalker">
        <module name="FinalLocalVariableCheck">
        <property name="tokens" value="PARAMETER_DEF" />
        </module>
    </module>
</module>   
output
kevin@inspiron-15-5510:~/Desktop/check_style$ java -jar checkstyle-10.6.0-all.jar -c config.xml Test.java
Starting audit...
[ERROR] /home/kevin/Desktop/check_style/Test.java:3:14: Variable 'a' should be declared final. [FinalLocalVariable]
Audit done.
Checkstyle ends with 1 errors.

I have a doubt here should we really expect violation in constructor here

@rnveach
Copy link
Member

rnveach commented Jan 9, 2023

@Kevin222004 Why do you doubt?
https://checkstyle.org/config_coding.html#FinalLocalVariable_Description
https://checkstyle.org/config_coding.html#FinalLocalVariable_Examples

The check can be configured to also check that unchanged parameters are declared final.
static int foo(int x, int y) { //violations, parameters should be final

@Kevin222004
Copy link
Collaborator Author

Kevin222004 commented Jan 9, 2023

it might be lack of my knowledge i have not seen this type of code before that's why

class Test {

    Test(final int a) {
    }

}

@nrmancuso
Copy link
Member

it might be lack of my knowledge i have not seen this type of code before that's why

Yes, in general, modifiers on parameters have fallen out of favor, especially with the advent of static analysis/IDEs that will flag reassigned parameters for you. However, this code is still valid.

Kevin222004 added a commit to Kevin222004/checkstyle that referenced this issue Jan 9, 2023
Kevin222004 added a commit to Kevin222004/checkstyle that referenced this issue Jan 9, 2023
@romani
Copy link
Member

romani commented Jan 9, 2023

Code can exist in real code, there might be some crazy reason to keep it like this.
Check need to point on this code, user will decide how to resolve code or suppress this violation.

Kevin222004 added a commit to Kevin222004/checkstyle that referenced this issue Jan 11, 2023
Kevin222004 added a commit to Kevin222004/checkstyle that referenced this issue Jan 11, 2023
Kevin222004 added a commit to Kevin222004/checkstyle that referenced this issue Jan 11, 2023
@Kevin222004
Copy link
Collaborator Author

Kevin222004 commented Jan 11, 2023

@rnveach in this issue all the mutation except

<suppressedMutations>
<mutation unstable="false">
<sourceFile>ExplicitInitializationCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.ExplicitInitializationCheck</mutatedClass>
<mutatedMethod>isZero</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_1</mutator>
<description>RemoveSwitch 1 (case value 138)</description>
<lineContent>switch (type) {</lineContent>
</mutation>

and
<mutation unstable="false">
<sourceFile>ExplicitInitializationCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.ExplicitInitializationCheck</mutatedClass>
<mutatedMethod>isZero</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_2</mutator>
<description>RemoveSwitch 2 (case value 139)</description>
<lineContent>switch (type) {</lineContent>
</mutation>

has been killed can you please help with this
this is the different one may be,

according to pit the

private static boolean isZero(DetailAST expr) {
final int type = expr.getType();
final boolean isZero;
switch (type) {
case TokenTypes.NUM_FLOAT:
case TokenTypes.NUM_DOUBLE:
case TokenTypes.NUM_INT:
case TokenTypes.NUM_LONG:
final String text = expr.getText();
isZero = Double.compare(CheckUtil.parseDouble(text, type), 0.0) == 0;
break;
default:
isZero = false;
}
return isZero;
}

in this method case value 138 and 139 is mutated but their is no any token type defined in code which value is 138 and 139

@rnveach
Copy link
Member

rnveach commented Jan 11, 2023

Does it look related to hcoles/pitest#1137 . Does the specific cases go in the default?

@Kevin222004
Copy link
Collaborator Author

Kevin222004 commented Jan 11, 2023

Yes it is looking somewhere like hcoles/pitest#1137. the two extra cases which are not available in code they are not giving test failure in default as well in without default case

@nrmancuso
Copy link
Member

@Kevin222004 what do we have left to do to close this issue?

@Kevin222004
Copy link
Collaborator Author

Kevin222004 commented Jan 15, 2023

@nrmancuso According to the issue description part-2 and part-3 has been done but in part 1
this two #12331 (comment) are left not sure this is pitest bug or what 🙃

@romani
Copy link
Member

romani commented Sep 5, 2023

there is not such survivals any more in project, see referenced commits or PR in project on how it was fixed

@romani romani closed this as completed Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

No branches or pull requests

4 participants