Comments (6)
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.
@HuGanghui please read - https://checkstyle.sourceforge.io/cmdline.html and try to fix yourself.
Tip: some options might be useful.
from patch-filters.
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.
@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.
@romani OK, I got it.
from patch-filters.
Implemeneted in #90
from patch-filters.
Related Issues (20)
- Implement checkNameForContextStrategyByTokenOrAncestorSet HOT 30
- Add more details in pom.xml and publish patch-filters to maven repository? HOT 3
- List checks that will miss some violations when only use supportContextStrategyChecks property HOT 3
- Add more javadoc annotation in import private methods HOT 1
- Rename SuppressionPatchXpathFilter to SuppressionJavaPatchFilter HOT 4
- Reorganize test resources by check module HOT 4
- Update checkstyle dependency from 8.33 to 8.35 HOT 1
- Make checkNamesForContextStrategyByTokenOrAncestorSet and checkNamesForContextStrategyByTokenOrParentSet work together HOT 1
- Update README.md to add checkNamesForContextStrategyByTokenOrAncestorSet property HOT 1
- FUTURE: Checks under neverSuppressedChecks group should give more precise violations
- FUTURE: Gather ideas for column strategy HOT 4
- FUTURE: Combine checkNamesForContextStrategyByTokenOrParentSet and checkNamesForContextStrategyByTokenOrAncestorSet properties
- upgrade to Checkstyle 10.4 HOT 3
- upgrade to checkstyle 10.3.3 HOT 1
- upgrade to checkstyle 10.3.4 HOT 1
- Report on files being validated against HOT 7
- Share in documentaiton ability to validate few last commits
- patch-filters doesn't work on Windows OS HOT 9
- Missing Generate Patch Tests HOT 3
- Patch File doesn't include Unstaged Changes HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from patch-filters.