Skip to content

Issue #13672: Kill mutation for Xpath-2#13771

Merged
romani merged 1 commit intocheckstyle:masterfrom
Kevin222004:Xpath2
Sep 25, 2023
Merged

Issue #13672: Kill mutation for Xpath-2#13771
romani merged 1 commit intocheckstyle:masterfrom
Kevin222004:Xpath2

Conversation

@Kevin222004
Copy link
Copy Markdown
Contributor

@Kevin222004 Kevin222004 commented Sep 23, 2023

Issue #13672: Kill mutation for Xpath-2


Mutation

Test

@romani
Copy link
Copy Markdown
Member

romani commented Sep 24, 2023

know ATTRIBUTE and ANCESTOR_OR_SELF will never be at root

it might be nonsense but user can write it (as mistake or mistake of xpath generation) but we would rather return no result than exception.
same with Regexp, there are uncountable amount of ways to make nonsense, and we do not block users to make it.

can you share CLI output that we do not throw excpeption on cases when such axis are used at root ?

@Kevin222004
Copy link
Copy Markdown
Contributor Author

OK, I was wrong about ANCESTOR_OR_SELF After re-thinking I have found this test will convert this in InputBased and kill Mutation

I am also re-thinking for ATTRIBUTE axis

kevin@kevin-Inspiron-15-5510:~/Desktop/check_style$ cat Test.java 
package com.puppycrawl.tools.checkstyle.filters.suppressionxpathfilter;

public class Test {

    char a = '&'; // filtered violation
}
 kevin@kevin-Inspiron-15-5510:~/Desktop/check_style$ cat config.xml 
<?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="IllegalTokenText">
            <property name="format" value="[^a-zA-z0-9]*"/>
            <property name="tokens" value="CHAR_LITERAL"/>
        </module>
        <module name="SuppressionXpathFilter">
            <property name="file" value="/home/kevin/Desktop/check_style/Suppression-Xpath.xml" />
        </module>
    </module>
</module>
kevin@kevin-Inspiron-15-5510:~/Desktop/check_style$ cat Suppression-Xpath.xml 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suppressions PUBLIC
        "-//Checkstyle//DTD SuppressionXpathFilter Experimental Configuration 1.2//EN"
        "https://checkstyle.org/dtds/suppressions_1_2_xpath_experimental.dtd">
<suppressions>
    <suppress-xpath
            files="Test.java"
            checks="IllegalTokenTextCheck"
            query="//ancestor-or-self::*"/>
</suppressions>
kevin@kevin-Inspiron-15-5510:~/Desktop/check_style$ java -jar /home/kevin/Downloads/checkstyle-10.12.3-all.jar -c config.xml Test.java
Starting audit...
Audit done.
kevin@kevin-Inspiron-15-5510:~/Desktop/check_style$ 

@romani
Copy link
Copy Markdown
Member

romani commented Sep 25, 2023

I am also re-thinking for ATTRIBUTE axis

I don't see test for this, what are your thoughts on this?

@Kevin222004
Copy link
Copy Markdown
Contributor Author

After re-thinking on ATTRIBUTE I don't find any test case. The attribute is used only as a ElementNode

Copy link
Copy Markdown
Member

@romani romani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok to merge if ci pass

@romani romani merged commit 9db32f1 into checkstyle:master Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants