Skip to content

Commit 6c748db

Browse files
committed
Issue #451: add multiple MatchXpath to checkstyle config
1 parent 173404a commit 6c748db

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

config/checkstyle-checks.xml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,57 @@
366366
<property name="ignoreCase" value="true"/>
367367
</module>
368368
<module name="InnerAssignment"/>
369+
<module name="MatchXpath">
370+
<property name="query" value="//CLASS_DEF[@text!='Checker' and @text!='Main']
371+
//LITERAL_CATCH//METHOD_CALL[.//IDENT[@text = 'printStackTrace']]/.."/>
372+
<message key="matchxpath.match" value="Avoid using 'printStackTrace'."/>
373+
</module>
374+
<module name="MatchXpath">
375+
<property name="query" value="//METHOD_DEF/MODIFIERS//
376+
ANNOTATION[./IDENT[@text='Test']]/ANNOTATION_MEMBER_VALUE_PAIR
377+
[./IDENT[@text='expected']]"/>
378+
<message key="matchxpath.match" value="Avoid using 'expected' attribute in Test annotation."/>
379+
</module>
380+
<module name="MatchXpath">
381+
<property name="query" value="//ANNOTATION[./IDENT[@text='Issue']]"/>
382+
<message key="matchxpath.match" value="Avoid using @Issue annotation."/>
383+
</module>
384+
<module name="MatchXpath">
385+
<property name="id" value="noUsageOfGetFileContentsMethod"/>
386+
<property name="query" value="//CLASS_DEF[
387+
./EXTENDS_CLAUSE[./IDENT[@text='AbstractCheck'
388+
or @text='AbstractJavadocCheck'
389+
or @text='AbstractSuperCheck'
390+
or @text='AbstractClassCouplingCheck'
391+
or @text='AbstractNameCheck'
392+
or @text='AbstractParenPadCheck']]
393+
and .//METHOD_CALL[.//IDENT[@text = 'getFileContents']]]"/>
394+
<message key="matchxpath.match" value="Avoid using getFileContents method in
395+
AbstractCheck subclasses."/>
396+
</module>
397+
<!-- until https://github.com/checkstyle/checkstyle/issues/5234 -->
398+
<module name="MatchXpath">
399+
<property name="id" value="MatchXPathBranchContains"/>
400+
<property name="query" value="//METHOD_CALL//DOT[.//IDENT[@text = 'branchContains']]"/>
401+
<message key="matchxpath.match"
402+
value="Avoid using deprecated method 'DetailAst.branchContains()'."/>
403+
</module>
404+
<module name="MatchXpath">
405+
<property name="query" value="//COMMENT_CONTENT[contains(@text, '@noinspection')
406+
and not(contains(@text, '@noinspectionreason'))]"/>
407+
<message key="matchxpath.match"
408+
value="'@noinspection' Javadoc tags should be accompanied by a
409+
'@noinspectionreason' tag, explaining why we suppressed inspection."/>
410+
</module>
411+
<module name="MatchXpath">
412+
<property name="id" value="exampleTestsExtendAbstractExamplesModuleTestSupport"/>
413+
<property name="query"
414+
value="//CLASS_DEF[./IDENT[ends-with(@text, 'ExamplesTest')]
415+
and ./MODIFIERS/LITERAL_PUBLIC
416+
and ./EXTENDS_CLAUSE/IDENT[not(@text='AbstractExamplesModuleTestSupport')]]"/>
417+
<message key="matchxpath.match"
418+
value="All example test classes should extend AbstractExamplesModuleTestSupport."/>
419+
</module>
369420
<module name="MissingCtor">
370421
<!--
371422
we will not use that fanatic validation, extra code is not good

0 commit comments

Comments
 (0)