Giter Site home page Giter Site logo

Comments (6)

HuGanghui avatar HuGanghui commented on June 15, 2024

I do a test to familiar with SuppressionPatchXpathFilter/SuppressionXpathSingleFilter

cat Test.java

package checkstyle_demo.PatchSuppression.PatchFilterTest.XpathPatchFilter;


class FileOne {
    public void MyMethod() {}
}

class FileTwo {
    public void MyMethod() {}
}

class FileThree {
    public void MyMethod() {}
}

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="com.github.checkstyle.patchfilter.SuppressionPatchFilter">-->
        <!--<property name="file" value="/Users/hgh/Downloads/my_file/IDEA_workspace/Leetcode_maven/engineering_ability/src/main/java/checkstyle_demo/PatchSuppression/MethodCount/patch.txt"/>-->
    <!--</module>-->
    <!--<module name="com.puppycrawl.tools.checkstyle.filters.SuppressionPatchFilter">-->
        <!--<property name="file" value="/Users/hgh/Downloads/my_file/IDEA_workspace/Leetcode_maven/engineering_ability/src/main/java/checkstyle_demo/PatchSuppression/PatchFilterTest/guava-patch-c34f584-31999ae.txt"/>-->
    <!--</module>-->

    <module name="TreeWalker">

        <module name="MethodName"/>

        <module name="SuppressionXpathSingleFilter">
            <property name="checks" value="MethodName"/>
            <property name="query" value="(/CLASS_DEF[@text='FileOne']/OBJBLOCK/
            METHOD_DEF[@text='MyMethod']/IDENT)|
            (/CLASS_DEF[@text='FileTwo']/OBJBLOCK/METHOD_DEF[@text='MyMethod']/IDENT)"/>
        </module>

    </module>

    <!-- as we run on regression even on non-compiled files we need to skip exceptions on them -->
    <module name="SuppressionSingleFilter">
        <property name="message" value="Exception occurred while parsing"/>
        <property name="checks" value="Checker"/>
    </module>

</module>

java $RUN_LOCALE -jar /Users/hgh/Desktop/checkstyle/target/checkstyle-8.34-SNAPSHOT-all.jar -c config.xml Test.java

Starting audit...
[ERROR] /Users/hgh/Downloads/my_file/IDEA_workspace/Leetcode_maven/engineering_ability/src/main/java/checkstyle_demo/PatchSuppression/PatchFilterTest/XpathPatchFilter/Test.java:5:17: Name 'MyMethod' must match pattern '^[a-z][a-zA-Z0-9]*$'. [MethodName]
[ERROR] /Users/hgh/Downloads/my_file/IDEA_workspace/Leetcode_maven/engineering_ability/src/main/java/checkstyle_demo/PatchSuppression/PatchFilterTest/XpathPatchFilter/Test.java:9:17: Name 'MyMethod' must match pattern '^[a-z][a-zA-Z0-9]*$'. [MethodName]
[ERROR] /Users/hgh/Downloads/my_file/IDEA_workspace/Leetcode_maven/engineering_ability/src/main/java/checkstyle_demo/PatchSuppression/PatchFilterTest/XpathPatchFilter/Test.java:13:17: Name 'MyMethod' must match pattern '^[a-z][a-zA-Z0-9]*$'. [MethodName]
Checkstyle ends with 3 errors.
Audit done.

but it should be one violation right? Why the SuppressionXpathSingleFilter does not have effect, please tell me if I am incorrect in some steps.

from patch-filters.

rdiachenko avatar rdiachenko commented on June 15, 2024

@HuGanghui please read - https://checkstyle.sourceforge.io/cmdline.html and try to fix yourself.

Tip: some options might be useful.

from patch-filters.

HuGanghui avatar HuGanghui commented on June 15, 2024

While mentors are busy to analyze report and make decision on what to do. Student should implement the same filter(line >only) but for Treewalker and generate report on guava for google-checks.xml config. - https://github.com/checkstyle/patch->filters/issues/6

according to doc, the same filter(line only), do we need to use current patch filter (line) to test checks belong to Treewalker?

from patch-filters.

romani avatar romani commented on June 15, 2024

@HuGanghui , we should not use already implemented SuppressionPatchFilter at all.
You create completely new Filter, some functionality might overlap but it is ok.
New filter should be located under TreeWalker in config and should be similar to https://github.com/checkstyle/checkstyle/blob/master/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionXpathFilter.java#L501 plus ability to consider patch details.

from patch-filters.

HuGanghui avatar HuGanghui commented on June 15, 2024

@romani OK, I got it.

from patch-filters.

baratali avatar baratali commented on June 15, 2024

Implemeneted in #90

from patch-filters.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.