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

[Bug] fix HideUtilityClassConstructor check to skip main method and SpringBootApplication annotation check #626

Merged
merged 1 commit into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,11 @@
<property name="packageAllowed" value="true"/>
<property name="protectedAllowed" value="true"/>
</module>
<!--SuppressionXpathFilter:跳过main方法&SpringBootApplication注释检查-->
<module name="SuppressionXpathFilter">
<property name="file" value="suppressions.xml"/>
<property name="optional" value="false"/>
</module>
<!-- 检查类成员对外可见性,只有Static final的可以是public对外访问-->
<module name="HideUtilityClassConstructor"/>
<!-- Utility类(只有静态成员和方法的类)不能有公有构造函数 -->
Expand Down
16 changes: 16 additions & 0 deletions suppressions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?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 for any classes that contain method named "main" -->
<suppress-xpath checks="HideUtilityClassConstructor"
query="//CLASS_DEF[//METHOD_DEF[./IDENT[@text='main']]]"/>

<!-- Suppress for any classes that are annotated with "SpringBootApplication" -->
<suppress-xpath checks="HideUtilityClassConstructor"
query="//CLASS_DEF[//MODIFIERS/ANNOTATION[./IDENT[@text='SpringBootApplication']]]"/>

</suppressions>